mirror of
https://github.com/dbarzin/pandora-box.git
synced 2025-07-22 06:49:41 +02:00
add logs
This commit is contained in:
parent
015c7b5f24
commit
399e534b3d
1 changed files with 18 additions and 25 deletions
|
@ -22,6 +22,7 @@
|
||||||
import configparser
|
import configparser
|
||||||
import curses
|
import curses
|
||||||
import datetime
|
import datetime
|
||||||
|
import glob
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import queue
|
import queue
|
||||||
|
@ -409,7 +410,6 @@ def print_screen():
|
||||||
print_serial("")
|
print_serial("")
|
||||||
init_bar()
|
init_bar()
|
||||||
update_bar(0, flush=True)
|
update_bar(0, flush=True)
|
||||||
log("Ready.", flush=True)
|
|
||||||
logging.info(f'boxname="{boxname}", ' "pandora-box-start")
|
logging.info(f'boxname="{boxname}", ' "pandora-box-start")
|
||||||
|
|
||||||
|
|
||||||
|
@ -918,23 +918,14 @@ def move_to_script_folder():
|
||||||
|
|
||||||
# --------------------------------------
|
# --------------------------------------
|
||||||
|
|
||||||
|
|
||||||
def get_enabled_workers():
|
|
||||||
config_dir = Path("~/pandora/pandora/workers")
|
|
||||||
yml_files = list(config_dir.glob("*.yml"))
|
|
||||||
return [str(file.stem) for file in yml_files if file.stem is not None]
|
|
||||||
|
|
||||||
|
|
||||||
def wait_for_workers():
|
def wait_for_workers():
|
||||||
pandora = pypandora.PyPandora(root_url=pandora_root_url)
|
pandora = pypandora.PyPandora(root_url=pandora_root_url)
|
||||||
target_count = len(get_enabled_workers()) - 1
|
|
||||||
while True:
|
|
||||||
workers = pandora.get_enabled_workers()
|
workers = pandora.get_enabled_workers()
|
||||||
log(f"Workers ready : {len(workers)}/ {target_count}")
|
while not pandora.is_up:
|
||||||
if len(workers) >= target_count:
|
log(f"Waiting for Pandora", flush=True)
|
||||||
break
|
time.sleep(1)
|
||||||
time.sleep(2)
|
for worker in workers:
|
||||||
|
log(f"Worker: {worker}", flush=True)
|
||||||
|
|
||||||
# --------------------------------------
|
# --------------------------------------
|
||||||
|
|
||||||
|
@ -955,6 +946,10 @@ def startup():
|
||||||
logo = file1.readlines()
|
logo = file1.readlines()
|
||||||
# Print logo screen
|
# Print logo screen
|
||||||
print_screen()
|
print_screen()
|
||||||
|
# Wait for workers to start
|
||||||
|
wait_for_workers()
|
||||||
|
# Now Ready
|
||||||
|
log("Ready.", flush=True)
|
||||||
|
|
||||||
return "WAIT"
|
return "WAIT"
|
||||||
|
|
||||||
|
@ -1011,19 +1006,17 @@ def main(_):
|
||||||
"""Main entry point"""
|
"""Main entry point"""
|
||||||
print("main")
|
print("main")
|
||||||
try:
|
try:
|
||||||
# Wait for workers to start
|
|
||||||
# wait_for_workers()
|
|
||||||
# Enter the mail loop
|
# Enter the mail loop
|
||||||
state = "START"
|
state = "START"
|
||||||
while state != "STOP":
|
while state != "STOP":
|
||||||
state = loop(state)
|
state = loop(state)
|
||||||
except Exception as ex:
|
#except Exception as ex:
|
||||||
print({str(ex)})
|
# print({str(ex)})
|
||||||
log(f"Unexpected error: {str(ex)}", flush=True)
|
# log(f"Unexpected error: {str(ex)}", flush=True)
|
||||||
logging.info(
|
# logging.info(
|
||||||
f'boxname="{boxname}", '
|
# f'boxname="{boxname}", '
|
||||||
f'error="{str(ex)}"',
|
# f'error="{str(ex)}"',
|
||||||
exc_info=True)
|
# exc_info=True)
|
||||||
finally:
|
finally:
|
||||||
end_curses()
|
end_curses()
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue