-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIOStatus_Log.py
20 lines (19 loc) · 1.01 KB
/
IOStatus_Log.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import os.path
import sys
lastmodified = ""
def WriteTxtFile(newprocess , oldprocess , ExpectedDate):
if lastmodified == "" or os.stat("ProcessMonitor/Status_Log.txt").st_mtime == lastmodified:
with open("ProcessMonitor/Status_Log.txt", 'a') as outtxt:
outtxt.write("the date of the change is {0}\n\n".format(ExpectedDate))
for proc in newprocess:
if proc not in oldprocess:
print ("the process {0} number {1} is create\n".format(proc.name , proc.pid))
outtxt.write("the process {0} number {1} is create\n".format(proc.name , proc.pid))
for proc in oldprocess:
if proc not in newprocess:
print ("the process {0} number {1} is stop working\n".format(proc.name , proc.pid))
outtxt.write("the process {0} number {1} is stop working\n".format(proc.name , proc.pid))
outtxt.write("\n")
else:
print "there was change in Status_Log file"
sys.exit(1)