/
verify_db.py
114 lines (70 loc) · 2.53 KB
/
verify_db.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
import datetime, shutil, os, os.path, time, calendar
import db_check
global move_date
def db_initialize():
action_date = calendar.timegm(time.gmtime())
db_check.newEntry(action_date, 'Check')
db_check.newEntry(action_date, 'Move')
def file_check(check_dir, save_dir, file_list):
action_date = calendar.timegm(time.gmtime())
modWindow = action_date - 86400
print 'The current time is: '
print time.ctime(action_date)
_dir = check_dir
_tran = save_dir
_files = os.listdir(_dir)
print '\nThe current files in folder ' + _dir + ' are:'
for f in _files:
print f
print '\nThe dates of the files are: '
for a in _files:
b = os.path.abspath(_dir + '/' + a)
modified = time.ctime(os.path.getmtime(b))
created = time.ctime(os.path.getctime(b))
print '\n' + b + ' was:'
print "last modified: %s" % modified
print "created: %s" % created
c = os.path.getmtime(b)
g = os.path.getctime(b)
if (c > modWindow) or (g > modWindow):
print a + ' will be moved'
'''
shutil.move(b, _tran)
'''
file_list.append(a)
print ''
db_check.newEntry(action_date, 'Check')
return file_list, action_date
def file_move(check_dir, save_dir, file_list):
global move_date
action_date = calendar.timegm(time.gmtime())
modWindow = action_date - 86400
print 'The current time is: '
print time.ctime(action_date)
move_date = []
db_check.viewLastMove(move_date)
print move_date
_dir = check_dir
_tran = save_dir
_files = os.listdir(_dir)
print '\nThe current files in folder ' + _dir + ' are:'
for f in _files:
print f
print '\nThe dates of the files are: '
for a in _files:
b = os.path.abspath(_dir + '/' + a)
modified = time.ctime(os.path.getmtime(b))
created = time.ctime(os.path.getctime(b))
print '\n' + b + ' was:'
print "last modified: %s" % modified
print "created: %s" % created
c = os.path.getmtime(b)
g = os.path.getctime(b)
if (c > modWindow) or (g > modWindow) or (c > move_date) or (g > move_date):
print a + ' will be moved'
shutil.move(b, _tran)
file_list.append(a)
print ''
db_check.newEntry(action_date, 'Move')
return file_list, action_date
if __name__ == "__main__": file_check(os.getcwd(), os.getcwd(), 'a')