|
@@ -0,0 +1,31 @@
|
|
1
|
+#! /usr/bin/env python
|
|
2
|
+
|
|
3
|
+import copy
|
|
4
|
+import torrenttracker
|
|
5
|
+
|
|
6
|
+class TrackerManager:
|
|
7
|
+ trackers = []
|
|
8
|
+ next_trackers = []
|
|
9
|
+ def __init__(self, trackers):
|
|
10
|
+ self.trackers = trackers
|
|
11
|
+
|
|
12
|
+ def start(self):
|
|
13
|
+ for tracker in self.trackers:
|
|
14
|
+ tracker.start()
|
|
15
|
+
|
|
16
|
+ def resetNextTrackers(self):
|
|
17
|
+ self.next_trackers = copy.copy(self.tracker)
|
|
18
|
+
|
|
19
|
+ def getNextTracker(self):
|
|
20
|
+ if not any(self.next_trackers):
|
|
21
|
+ self.resetNextTrackers()
|
|
22
|
+ minTracker = self.next_trackers[0]
|
|
23
|
+ for tracker in self.next_trackers:
|
|
24
|
+ if tracker.getInterval() < minTracker.getInterval():
|
|
25
|
+ minTracker = tracker
|
|
26
|
+ return minTracker
|
|
27
|
+
|
|
28
|
+ def updateNextTracker(self):
|
|
29
|
+ tracker = self.getNextTracker()
|
|
30
|
+ tracker.interval(0, 0, 0)
|
|
31
|
+ self.next_trackers.remove(tracker)
|