Trying to get python bridge to work.
This commit is contained in:
@@ -9,10 +9,10 @@ os.makedirs(SECRET_PATH, exist_ok=True)
|
||||
LOGS_DIR = "logs/"
|
||||
PAGES_DIR = "pages/"
|
||||
CONFIG_DIR = "config/"
|
||||
SIGNALS_DIR = "signal/"
|
||||
SIGNALS_DIR = "signals/"
|
||||
### <-- Variables
|
||||
|
||||
os.chdir(web/)
|
||||
os.chdir('web')
|
||||
|
||||
class BridgeHandler(http.server.SimpleHTTPRequestHandler):
|
||||
def do_GET(self):
|
||||
@@ -39,18 +39,22 @@ class BridgeHandler(http.server.SimpleHTTPRequestHandler):
|
||||
|
||||
if self.path == '/discovery':
|
||||
# Store secrets in memory-backed filesystem
|
||||
with open(os.path.join(SECRET_PATH, "live.yaml"), "wb") as f:
|
||||
# We write to CONFIG_DIR so deploy.sh can find it easily
|
||||
os.makedirs(CONFIG_DIR, exist_ok=True)
|
||||
with open(os.path.join(CONFIG_DIR, "live.yaml"), "wb") as f:
|
||||
f.write(post_data)
|
||||
self.send_response(200)
|
||||
self.end_headers()
|
||||
# Signal Bash that discovery data is ready
|
||||
with open(os.path.join(SIGNALS_DIR, ".discovery_ready"), "w") as f: f.write("1")
|
||||
# Signal Bash that discovery data is ready and we can proceed to hardware detection
|
||||
os.makedirs(SIGNALS_DIR, exist_ok=True)
|
||||
with open(os.path.join(SIGNALS_DIR, "hw_detection_ready"), "w") as f: f.write("1")
|
||||
with open(os.path.join(SIGNALS_DIR, "configuration_ready"), "w") as f: f.write("1")
|
||||
|
||||
elif self.path == '/deploy':
|
||||
with open(os.path.join(CONFIG_DIR, "numbus.yaml"), "wb") as f:
|
||||
f.write(post_data)
|
||||
self.send_response(200)
|
||||
self.end_headers()
|
||||
with open(os.path.join(SIGNALS_DIR, ".deploy_signal"), "w") as f: f.write("1")
|
||||
with open(os.path.join(SIGNALS_DIR, "deployment_ready"), "w") as f: f.write("1")
|
||||
|
||||
http.server.HTTPServer(('localhost', 8088), BridgeHandler).serve_forever()
|
||||
Reference in New Issue
Block a user