-
Notifications
You must be signed in to change notification settings - Fork 0
/
IOprocessList.py
57 lines (51 loc) · 1.71 KB
/
IOprocessList.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
import os.path
import csv
import datetime
from Process import Process
import ProcessScanner
import IOStatus_Log
import sys
import platform
import FolderLock
lastmodified = ""
def WriteCsvFile():
list = ProcessScanner.ListOfProcess()
expecteddate = datetime.datetime.now().strftime("%y-%m-%d %H-%M")
if lastmodified == "" or os.stat("ProcessMonitor/processList.csv").st_mtime == lastmodified:
lastprocess = ReadLastScanner()
IOStatus_Log.WriteTxtFile(list , lastprocess , expecteddate)
with open("ProcessMonitor/processList.csv", 'ab') as outcsv:
writer = csv.writer(outcsv, delimiter=',')
for proc in list:
writer.writerow([proc.pid, proc.name, expecteddate])
else:
print "there was change in processList file"
sys.exit(1)
def ReadLastScanner():
process = []
date = ""
with open("ProcessMonitor/processList.csv", 'rb') as f:
reader = csv.reader(f)
for line in reversed(list(reader)):
p = Process(line[0],line[1])
if not process:
process.append(p)
date = line[2]
else:
if date == line[2]:
process.append(p)
else:
return process
return process
def CheckIfDateExist(date):
listofprocess = []
if platform.system() is "Windows":
FolderLock.OpenFolder()
with open("ProcessMonitor/processList.csv", 'rb') as f:
reader = csv.reader(f)
for line in reader:
if line[2] == date:
listofprocess.append(Process(line[0],line[1]))
if platform.system() is "Windows":
FolderLock.CloseFolder()
return listofprocess