-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsync-files.py
41 lines (33 loc) · 1002 Bytes
/
sync-files.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
#! /usr/bin/python
import psutil
import sys
processName = ''
def main():
# If a process name was passed in then use it
if(sys.argv[1:]):
print(sys.argv[1:])
processName = sys.argv[1]
# Otherwise exit
else:
return
if checkIfProcessRunning(processName):
print('Yes ' + processName + ' process was running')
return
else:
print('No ' + processName + ' process was running')
def checkIfProcessRunning(processName):
'''
Check if there is any running process that contains
the given name processName.
'''
# Iterate over the all the running process
for proc in psutil.process_iter():
try:
# Check if process name contains the given name string.
if processName.lower() in proc.name().lower():
return True
except (psutil.NoSuchProcess, psutil.AccessDenied, psutil.ZombieProcess):
pass
return False
if __name__ == "__main__":
main()