Browse Source

load error management

master
Robin Thoni 8 years ago
parent
commit
f6116f12ee
1 changed files with 9 additions and 3 deletions
  1. 9
    3
      fake-tracker.py

+ 9
- 3
fake-tracker.py View File

2
 
2
 
3
 from __future__ import print_function
3
 from __future__ import print_function
4
 import sys
4
 import sys
5
+import os
5
 import time
6
 import time
6
 import glob
7
 import glob
7
 import torrentfile
8
 import torrentfile
31
 run = True
32
 run = True
32
 while run:
33
 while run:
33
     for file in glob.glob(torrentsPath + "/*.torrent"):
34
     for file in glob.glob(torrentsPath + "/*.torrent"):
35
+        torrent = torrentfile.TorrentFile()
34
         try:
36
         try:
35
-            torrent = torrentfile.TorrentFile()
36
             torrent.readFile(file)
37
             torrent.readFile(file)
38
+        except:
39
+            os.remove(file)
40
+            warning("could not load", file)
41
+
42
+        try:
37
             if not any(x.getName() == torrent.getName()
43
             if not any(x.getName() == torrent.getName()
38
                     for x in manager.getTorrents()):
44
                     for x in manager.getTorrents()):
39
-                debug("Found", torrent.getName())
40
                 torrent.getTracker().start()
45
                 torrent.getTracker().start()
46
+                debug("started", torrent.getName())
41
                 manager.appendTorrent(torrent)
47
                 manager.appendTorrent(torrent)
42
         except:
48
         except:
43
-            warning("could not load or start", file)
49
+            warning("could not start", torrent.getName())
44
 
50
 
45
     count = len(manager.getTorrents())
51
     count = len(manager.getTorrents())
46
 
52
 

Loading…
Cancel
Save