determine app/server mode and running state
This commit is contained in:
parent
e4abc271ed
commit
dcc55d8aee
@ -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__":
|
||||
|
Loading…
Reference in New Issue
Block a user