Skip to content

Commit

Permalink
create if doesn't exist
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevin Reynolds committed Aug 20, 2024
1 parent e16765c commit 8070d1d
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions base/app/app.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Module fetching metadata and sending to SQS"""
from threading import Thread
import os
import time
import sys
import json
Expand All @@ -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)

Expand All @@ -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
Expand Down Expand Up @@ -227,6 +227,7 @@ def main():
"""
Main Function
"""
state_base = "/var/lib/private/orijen-udf-base/"

metadata = query_metadata()
labInfo = get_lab_info(metadata)
Expand Down

0 comments on commit 8070d1d

Please sign in to comment.