Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 44 additions & 33 deletions node_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ def setup_nodejs_appium():


TMP_INI_FILE = None
_shutdown_event: asyncio.Event | None = None

"""Constants"""
AUTHENTICATION_TAG = "Authentication"
Expand All @@ -168,9 +169,8 @@ def kill_child_processes():
def signal_handler(sig, frame):
print("\n--- SIGINT received, quitting ---\n")
CommonUtil.run_cancelled = True
CommonUtil.ShutdownExecutor()
kill_child_processes()
os._exit(0)
if _shutdown_event is not None and not _shutdown_event.is_set():
_shutdown_event.set()


async def destroy_session():
Expand Down Expand Up @@ -1317,6 +1317,8 @@ def create_temp_ini_automation_log():


async def main():
global _shutdown_event

print_system_info_version()
load_dotenv()
adjust_python_path()
Expand Down Expand Up @@ -1352,7 +1354,10 @@ async def main():
asyncio.create_task(delete_old_automationlog_folders())
await destroy_session()

_shutdown_event = asyncio.Event()
signal.signal(signal.SIGINT, signal_handler)
if hasattr(signal, "SIGBREAK"):
signal.signal(signal.SIGBREAK, signal_handler)
print("Press Ctrl-C or Ctrl-Break to disconnect and quit.")

console = Console()
Expand Down Expand Up @@ -1388,39 +1393,45 @@ async def main():
log_dir=log_dir,
)
)
while True:
if STATE.reconnect_with_credentials is not None:
await destroy_session()
server_name = STATE.reconnect_with_credentials.server
api_key = STATE.reconnect_with_credentials.api_key
await set_new_credentials(server=server_name, api_key=api_key)

STATE.reconnect_with_credentials = None
server_name = (
ConfigModule.get_config_value(AUTHENTICATION_TAG, "server_address")
.strip('"')
.strip()
)
api = (
ConfigModule.get_config_value(AUTHENTICATION_TAG, "api-key")
.strip('"')
.strip()
)

if len(server_name) == 0 and len(api) == 0:
console.print(
"\n" + ":red_circle: " + "Zeuz Node is disconnected.",
style="bold red",
try:
while not _shutdown_event.is_set():
if STATE.reconnect_with_credentials is not None:
await destroy_session()
server_name = STATE.reconnect_with_credentials.server
api_key = STATE.reconnect_with_credentials.api_key
await set_new_credentials(server=server_name, api_key=api_key)

STATE.reconnect_with_credentials = None
server_name = (
ConfigModule.get_config_value(AUTHENTICATION_TAG, "server_address")
.strip('"')
.strip()
)
api = (
ConfigModule.get_config_value(AUTHENTICATION_TAG, "api-key")
.strip('"')
.strip()
)
console.print("Please log in to ZeuZ server and connect.")

asyncio.create_task(
Login(
server_name=server_name,
log_dir=log_dir,
if len(server_name) == 0 and len(api) == 0:
console.print(
"\n" + ":red_circle: " + "Zeuz Node is disconnected.",
style="bold red",
)
console.print("Please log in to ZeuZ server and connect.")

asyncio.create_task(
Login(
server_name=server_name,
log_dir=log_dir,
)
)
)
await asyncio.sleep(1)
await asyncio.sleep(1)
finally:
if _shutdown_event.is_set():
CommonUtil.run_cancelled = True
CommonUtil.ShutdownExecutor()
kill_child_processes()


asyncio.run(main())
Loading