From dcc55d8aeedd4a7af631930d75e55a5c4a80b433 Mon Sep 17 00:00:00 2001 From: "Fredrcik W. Warren" Date: Sun, 26 May 2024 21:59:54 -0600 Subject: [PATCH] determine app/server mode and running state --- pismotek-remote.py | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/pismotek-remote.py b/pismotek-remote.py index 6328a05..f1dd733 100644 --- a/pismotek-remote.py +++ b/pismotek-remote.py @@ -12,6 +12,9 @@ import time To "swap out" a portion of a window, use a Column element for that portion. Add multiple Columns on the same row and make only 1 of them active at a time + + Will determine if tvnserver is a running service or application + If it is not running it will be run in application mode """ # ----------- Utility functions ----------- @@ -102,15 +105,29 @@ def tab_yes(window): def tvn_get_state(): """ get current state of tvnserver - retrun stopped if does not exist """ - status = "stopped" + state = "stopped" service = get_service('tvnserver') if service: - status = service["status"] - return status + state = service["status"] + return state + +def get_tvnserver_info(): + """ + determine the state of tvnserver.exe + service running - can use as is + application running - can use as is + application stopped - need to start application + """ + mode = "application" + state = tvn_get_state() + if state == "running": + mode = "service" + elif "tvnserver.exe" in (p.name() for p in psutil.process_iter()): + state = "running" + return mode, state def main(): - tvn_state = tvn_get_state() - print(tvn_state) + tvn_mode, tvn_state = get_tvnserver_info() layout = build_layout() window = sg.Window('Pismotek', layout, size=(380, 350)) while True: @@ -121,8 +138,6 @@ def main(): tab_no(window) elif event == 'Yes': tab_yes(window) - # elif event == '-VNCCONNECT-': - # print("Woot") window.close() if __name__ == "__main__":