소스 검색

begin tarcker manager

master
Robin Thoni 9 년 전
부모
커밋
e1f117a67c
1개의 변경된 파일31개의 추가작업 그리고 0개의 파일을 삭제
  1. 31
    0
      trackermanager.py

+ 31
- 0
trackermanager.py 파일 보기

@@ -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)

Loading…
취소
저장