From 8070d1dc7e284a925435fb1602979ae4bc271ab0 Mon Sep 17 00:00:00 2001 From: Kevin Reynolds Date: Tue, 20 Aug 2024 15:04:37 -0400 Subject: [PATCH] create if doesn't exist --- base/app/app.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/base/app/app.py b/base/app/app.py index 367b9c8..a3fa384 100644 --- a/base/app/app.py +++ b/base/app/app.py @@ -1,5 +1,6 @@ """Module fetching metadata and sending to SQS""" from threading import Thread +import os import time import sys import json @@ -12,13 +13,12 @@ import petname from flask import Flask, jsonify -state_base = "/var/lib/private/orijen-udf-base/" - def run_flask(app): """Function to run the Flask app on a separate thread.""" app.run(host='0.0.0.0', port=5123) def save_state(file, state): + os.makedirs(os.path.dirname(file), exist_ok=True) with open(file, 'w') as f: json.dump(state, f) @@ -30,7 +30,7 @@ def load_state(file): return {} def generate_petname(): - """Generates a pet name in the format 'adjective-animal'.""" + """Generates a pet name in the format 'adjective-animal'""" name = petname.Generate() save_state(state_base + "petname.json", name) return name @@ -227,6 +227,7 @@ def main(): """ Main Function """ + state_base = "/var/lib/private/orijen-udf-base/" metadata = query_metadata() labInfo = get_lab_info(metadata)