-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlogFile.py
34 lines (28 loc) · 841 Bytes
/
logFile.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
#!/usr/bin/python
import os
import fnmatch
class log(object):
def __init__(self, name, time):
super(log, self).__init__()
self.name = name
self.time = long(time)
def getLogs(module):
dataPath = module.path
files = os.listdir(dataPath)
def compare(x, y):
stat_x = os.stat(dataPath + "/" + x)
stat_y = os.stat(dataPath + "/" + y)
if stat_x.st_mtime < stat_y.st_mtime:
return -1
elif stat_x.st_mtime > stat_y.st_mtime:
return 1
else:
return 0
files.sort(compare)
logs = []
for file in files:
if fnmatch.fnmatch(file, module.fileMatch):
fileName = os.path.join(dataPath, file)
log1 = log(fileName, os.stat(fileName).st_mtime * 1000)
logs.append(log1)
return logs