-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathposthook
executable file
·37 lines (32 loc) · 1.02 KB
/
posthook
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
#!/usr/bin/env python2.7
# vim:ft=python
import sys
import os
import traceback
try:
from modules import posthandler
except ImportError:
logme = ">>> ImportError"
fh = open("/home/mp-torrent/pyrt/pyrt.log", "a")
fh.write("\n%s\n" % logme)
fh.close()
if __name__ == "__main__":
logme = ""
try:
filepath = sys.argv[1]
if not os.path.exists(filepath):
filepath = os.path.join("/home/mp-torrent/torrents/downloading/", os.path.basename(sys.argv[1]))
if not os.path.exists(filepath):
logme = ">>> posthook: <%s> doesn't exist" % filepath
else:
PH = posthandler.PostHandler()
logout = PH.checkNewFile(filepath)
if not logout:
logme = ">>> posthook: <%s> not in filter list" % os.path.basename(filepath)
else:
logme = logout
except:
logme += "\n%s" % traceback.format_exc()
fh = open("/home/mp-torrent/pyrt/pyrt.log", "a")
fh.write("\n%s\n" % logme)
fh.close()