forked from NSLS2/lsdc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwrapGui.py
executable file
·32 lines (28 loc) · 869 Bytes
/
wrapGui.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/opt/conda_envs/lsdc_dev/bin/python
"""
If lsdcGui is stopped abnormally, restart it!
"""
import os
from epics import PV
import db_lib
def check_pid(pid):
try:
os.kill(pid, 0)
except OSError:
return False
else:
return True
returnStat = (os.system("$LSDCHOME/lsdcGui.py"))
if (returnStat == 0):
exit(1) #a normal termination, no further work needed, else figure out who is master and restart
beamline = os.environ["BEAMLINE_ID"]
beamlineComm = db_lib.getBeamlineConfigParam(beamline,"beamlineComm")
controlMaster_pv = PV(beamlineComm + "zinger_flag")
for i in range (0,4):
if (returnStat == 0): #normal exit, else restart
break
currentMasterPid = controlMaster_pv.get()
if (check_pid(int(currentMasterPid))):
returnStat = (os.system("$LSDCHOME/lsdcGui.py"))
else:
returnStat = (os.system("$LSDCHOME/lsdcGui.py master"))