forked from SeattleTestbed/dist
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstop_all_seattle_processes.py
60 lines (42 loc) · 1.23 KB
/
stop_all_seattle_processes.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
"""
<Program Name>
impose_seattlestopper_lock.py
<Started>
December 25, 2009
<Author>
Zachary Boka
<Purpose>
Forces the seattle node manager and software updater to quit if they are
running.
"""
import runonce
import harshexit
locklist = ["seattlenodemanager", "softwareupdater.old", "softwareupdater.new"]
def main():
"""
<Purpose>
Kills all the seattle programs that are running.
<Arguments>
None.
<Exceptions>
None.
<Side Effects>
Kills all the seattle programs that are running.
<Returns>
None.
"""
for lockname in locklist:
lockstate = runonce.getprocesslock(lockname)
# If lockstate is a process pid, then we need to terminate it. Otherwise,
# that lock is not being held by a program that needs to be terminated.
if not lockstate == True and not lockstate == False:
# We got the pid, we can stop the process
harshexit.portablekill(lockstate)
# Now acquire the lock for ourselves, looping until we
# actually get it.
retrievedlock = runonce.getprocesslock(lockname)
while retrievedlock != True:
harshexit.portablekill(retrievedlock)
retrievedlock = runonce.getprocesslock(lockname)
if __name__ == '__main__':
main()