-
Notifications
You must be signed in to change notification settings - Fork 1
/
checknewfiles.py
51 lines (46 loc) · 2.15 KB
/
checknewfiles.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
import os
import time
from commands import *
dct = {}
create_logstring = "Init check"
Print.colored("Init...", "grey", "on_white")
while True:
for root, dirs, files in os.walk(Path.extend("Users", "mac", "Library", "Application Support", "Disk-O")):
time9.sleep(0.001)
for file in files:
path = Path.extend(root, file)
#print(path1)
#print(dct)
try:
if dct[path] != File.get_size(path):
dct[path] = File.get_size(path)
Print.colored(Time.dotted(), "Changed", os.path.split(path)[1], "yellow")
except FileNotFoundError:
Print.colored(Time.dotted(), "Removed", os.path.split(path)[1], "red")
dct.pop(path, None)
except KeyError as err:
try:
dct[path] = File.get_size(path)
Print.colored(Time.dotted(), create_logstring, os.path.split(path)[1], "green")
except FileNotFoundError:
#Print.colored("file not found", path1)
Print.rewrite(Time.dotted(), "Skip non-file", path)
pass
create_logstring = "Created"
for path, size in Dict.iterable(dct, copy_dict=True):
time9.sleep(0.001)
try:
#Print.debug("dct[path1]", dct[path1],
# "File.get_size(path1)", File.get_size(path1),
# "dct[path1] != File.get_size(path1)", dct[path1] != File.get_size(path1))
if dct[path] != File.get_size(path):
dct[path] = File.get_size(path)
Print.colored(Time.dotted(), "Changed", os.path.split(path)[1], "yellow")
except FileNotFoundError:
Print.colored(Time.dotted(), "Removed", os.path.split(path)[1], "red")
dct.pop(path, None)
except KeyError as err:
Print.colored(Time.dotted(), "Created", os.path.split(path)[1], "green")
dct[path] = File.get_size(path)
CLI.wait_update()
time9.sleep(2)