-
Notifications
You must be signed in to change notification settings - Fork 3
/
setup.py
73 lines (61 loc) · 1.42 KB
/
setup.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
import os
import sys
from remote_caller import SCGIRequest
def main(schedule=False):
path = os.path.abspath(os.getcwd())
rtxmlrpc = SCGIRequest()
try:
if schedule:
interval, threshold = schedule
rtxmlrpc.send(
"schedule2",
(
"",
"low_diskspace",
"0",
interval,
"close_low_diskspace={}G".format(threshold),
),
)
rtxmlrpc.send("system.file.allocate.set", ("", "0"))
rtxmlrpc.send("execute.throw.bg", ("", "python3", path + "/server.py"))
rtxmlrpc.send(
"method.set_key",
(
"",
"event.download.inserted_new",
"checker",
"branch=((and,((not,((d.is_meta)))),((d.state)))),((dcheck))",
),
)
rtxmlrpc.send(
"method.set_key",
(
"",
"event.download.erased",
"checker_erase",
"execute.throw.bg=python3,{}/client.py,delete,$d.hash=,$d.name=,$d.directory=".format(path),
),
)
try:
rtxmlrpc.send(
"method.insert",
(
"",
"dcheck",
"simple",
"d.stop=",
"execute.throw.bg=python3,{}/client.py,$d.name=,$d.hash=,$d.directory=,$d.size_bytes=".format(path),
),
)
except Exception:
# Setup has ran before / Method already inserted
pass
print("\nSetup.py completed successfully. Disk checker (server.py) is now running in the background.")
except Exception as e:
print("\nSetup.py failed:", e)
if __name__ == "__main__":
if len(sys.argv) == 1:
main()
else:
main((sys.argv[1], sys.argv[2]))