determine app/server mode and running state

This commit is contained in:
Fredrcik W. Warren 2024-05-26 21:59:54 -06:00
parent e4abc271ed
commit dcc55d8aee

View File

@ -12,6 +12,9 @@ import time
To "swap out" a portion of a window, use a Column element for that portion. Add multiple Columns 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 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 ----------- # ----------- Utility functions -----------
@ -102,15 +105,29 @@ def tab_yes(window):
def tvn_get_state(): def tvn_get_state():
""" get current state of tvnserver - retrun stopped if does not exist """ """ get current state of tvnserver - retrun stopped if does not exist """
status = "stopped" state = "stopped"
service = get_service('tvnserver') service = get_service('tvnserver')
if service: if service:
status = service["status"] state = service["status"]
return 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(): def main():
tvn_state = tvn_get_state() tvn_mode, tvn_state = get_tvnserver_info()
print(tvn_state)
layout = build_layout() layout = build_layout()
window = sg.Window('Pismotek', layout, size=(380, 350)) window = sg.Window('Pismotek', layout, size=(380, 350))
while True: while True:
@ -121,8 +138,6 @@ def main():
tab_no(window) tab_no(window)
elif event == 'Yes': elif event == 'Yes':
tab_yes(window) tab_yes(window)
# elif event == '-VNCCONNECT-':
# print("Woot")
window.close() window.close()
if __name__ == "__main__": if __name__ == "__main__":