Browse Source

print time in debug/warnigs

master
Robin Thoni 9 years ago
parent
commit
c0ab025600
1 changed files with 7 additions and 4 deletions
  1. 7
    4
      fake-tracker.py

+ 7
- 4
fake-tracker.py View File

9
 import config
9
 import config
10
 
10
 
11
 def warning(*objs):
11
 def warning(*objs):
12
-        print("WARNING:", *objs, file=sys.stderr)
12
+    print(time.strftime("%d/%m/%Y %H:%M:%S"), "WARNING:", *objs, file=sys.stderr)
13
+
14
+def debug(*objs):
15
+    print(time.strftime("%d/%m/%Y %H:%M:%S"), *objs)
13
 
16
 
14
 if len(sys.argv) >= 2:
17
 if len(sys.argv) >= 2:
15
     config = config.Config(sys.argv[1])
18
     config = config.Config(sys.argv[1])
33
             torrent.readFile(file)
36
             torrent.readFile(file)
34
             if not any(x.getName() == torrent.getName()
37
             if not any(x.getName() == torrent.getName()
35
                     for x in manager.getTorrents()):
38
                     for x in manager.getTorrents()):
36
-                print("Found", torrent.getName())
39
+                debug("Found", torrent.getName())
37
                 torrent.getTracker().start()
40
                 torrent.getTracker().start()
38
                 manager.appendTorrent(torrent)
41
                 manager.appendTorrent(torrent)
39
         except:
42
         except:
50
     torrent = t['torrent']
53
     torrent = t['torrent']
51
     secs = t['time']
54
     secs = t['time']
52
     if secs > 0:
55
     if secs > 0:
53
-        print(torrent.getName() + ": Next update in " + str(secs) + " seconds")
56
+        debug(torrent.getName() + ": Next update in " + str(secs) + " seconds")
54
         time.sleep(secs)
57
         time.sleep(secs)
55
-    print("Updating", torrent.getName(),
58
+    debug("Updating", torrent.getName(),
56
             "ratio =", (torrent.getTracker().getUploaded() / float(torrent.getSize())))
59
             "ratio =", (torrent.getTracker().getUploaded() / float(torrent.getSize())))
57
     try:
60
     try:
58
         manager.updateTorrent()
61
         manager.updateTorrent()

Loading…
Cancel
Save