From 53271c333138ac6569416326ac25706e680cd1e3 Mon Sep 17 00:00:00 2001 From: Bernd Schoolmann Date: Sun, 2 Jun 2024 18:54:15 +0200 Subject: [PATCH] Implement mac main --- gui/src/macos/main.py | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/gui/src/macos/main.py b/gui/src/macos/main.py index 02ac8c7..cf8f94e 100644 --- a/gui/src/macos/main.py +++ b/gui/src/macos/main.py @@ -1,13 +1,30 @@ import sys import subprocess import os +import secrets +from src.services import goldwarden +from src.services import pinentry +import time root_path = os.path.abspath(os.path.join(os.path.dirname(os.path.abspath(__file__)), os.pardir, os.pardir)) def main(): - token = "abc" + token = secrets.token_hex(32) + if not os.environ.get("GOLDWARDEN_DAEMON_AUTH_TOKEN") == None: + token = os.environ["GOLDWARDEN_DAEMON_AUTH_TOKEN"] print("Starting Goldwarden GUI") + goldwarden.run_daemon_background(token) + time.sleep(1) + #pinentry.daemonize() if not "--hidden" in sys.argv: - p = subprocess.Popen(["python3", "-m", "src.gui.settings"], stdin=subprocess.PIPE, stdout=subprocess.PIPE, cwd=root_path, start_new_session=True) + p = subprocess.Popen(["python3", "-m", "src.gui.settings"], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=root_path, start_new_session=True) p.stdin.write(f"{token}\n".encode()) - p.stdin.flush() \ No newline at end of file + p.stdin.flush() + # print stdout + while True: + line = p.stderr.readline() + if not line: + break + print(line.decode().strip()) + while True: + time.sleep(60) \ No newline at end of file