r275 - in branches/rewrite: . src

Otavio Salvador partial-mirror-devel@lists.alioth.debian.org
Tue, 09 Nov 2004 17:45:52 -0700


Author: otavio
Date: Tue Nov  9 17:45:52 2004
New Revision: 275

Modified:
   branches/rewrite/   (props changed)
   branches/rewrite/src/Download.py
Log:
 r187@nurf:  otavio | 2004-11-10T00:43:32.233555Z
 Implement the display information object like static.


Modified: branches/rewrite/src/Download.py
==============================================================================
--- branches/rewrite/src/Download.py	(original)
+++ branches/rewrite/src/Download.py	Tue Nov  9 17:45:52 2004
@@ -21,7 +21,7 @@
 
 from Queue import Queue
 
-import DisplayInfo
+from DisplayInfo import *
 
 class DownloadQueue(Queue):
     counter = 0
@@ -35,11 +35,22 @@
     """ Implement a Download Thread and use a DisplayInfo class to
     notify the user about what it's currently doing."""
     _Lock = threading.Lock()
+
+    DisplayInfo = None
+    ProgressBar = None
     
-    def __init__(self, DisplayInfo):
-        self._DisplayInfo = DisplayInfo
-        self._ProgressBar = DisplayInfo.ProgressBar()
-        self._DisplayInfo.add(self.ProgressBar)
+    def __init__(self, info = None, progress = None):
+        if info == None:
+            self.DisplayInfo = TextDisplayInfo()
+        else:
+            self.DisplayInfo = info
+            
+        if progress == None:
+            self.ProgressBar = TextProgressBar()
+        else:
+            self.ProgressBar = progress
+
+        self.DisplayInfo.add(self.ProgressBar)
         threading.Thread.__init__(self)
         
     def run(self):
@@ -59,7 +70,7 @@
 
             self.url = url
 
-            self._ProgressBar.text = self.url
+            self.ProgressBar.text = self.url
 
             # Store counter information about it
             self._Lock.acquire()
@@ -77,9 +88,9 @@
             f.close()
 
     def progress(self, download_t, download_d, upload_t, upload_d):
-        self._ProgressBar.max = download_t
-        self._ProgressBar.current = download_d
-        self._DisplayInfo.refresh()
+        self.ProgressBar.max = download_t
+        self.ProgressBar.current = download_d
+        self.DisplayInfo.refresh()
 
 class Download:
     """ Download queue """
@@ -87,7 +98,7 @@
     """ Fetcher to use """
     fetchers = []
 
-    def __init__(self, uri, destine, max_threads=2):
+    def __init__(self, uri, destine, max_threads=1):
         self.queue.put((uri, destine))
 
         # Alloc all needed threads.