r273 - in branches/rewrite: . src

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


Author: otavio
Date: Tue Nov  9 17:44:37 2004
New Revision: 273

Modified:
   branches/rewrite/   (props changed)
   branches/rewrite/src/Dists.py
Log:
 r185@nurf:  otavio | 2004-11-10T00:41:10.358142Z
 Start to include download information.


Modified: branches/rewrite/src/Dists.py
==============================================================================
--- branches/rewrite/src/Dists.py	(original)
+++ branches/rewrite/src/Dists.py	Tue Nov  9 17:44:37 2004
@@ -18,16 +18,18 @@
 
 import os
 from Dir import *
-import Config
+from Download import *
 
 class Dists:
     """
     This class provides methods to manage dists on partial-mirrors
     """
 
-    def __init__(self, backend):
+    def __init__ (self, backend):
         self._backend = backend
         self._files = []
+        self._dir = Dir(backend["mirror_dir"], backend["name"])
+        self.got_files = []
 
     def _find_updates (self):
         """ Determine which files need updates.
@@ -35,7 +37,10 @@
         for f in self._files:
             if self._md5sum [f] == -1:
                 self._need_update.append(f)
-    
+
+    def update (self):
+        for f in self._files:
+            self._get(f)
 
 class RemoteDists (Dists):
     """
@@ -43,12 +48,25 @@
     """
     def __init__(self, backend):
         Dists.__init__(self, backend)
+        #files = ["Packages.gz", "Release"]
+        files = ["Release"]
+        #if backend["get_sources"]:
+        #files.append("Sources.gz")
         for c in backend["components"]:
             for d in backend["distributions"]:
                 for a in backend["architectures"]:
-                    for f in ["Packages.gz", "Sources.gz", "Release"]:
-                        self._files.append("%s/debian/%s/%s/binary-%s/%s" %
-                                          (backend["server"], d, c, a, f))
+                    for f in files:
+                        server = "%s/debian/%s/%s/binary-%s/%s" \
+                                 % (backend["server"], d, c, a, f)
+                        filename = "%s/debian/%s/%s/binary-%s/%s" \
+                                   % (backend["mirror_dir"] + backend["name"], d, c, a, f)
+                        self._files.append((server, filename))
+
+    def _get(self, file):
+        server, filename = file
+        self._dir.create(os.path.dirname(filename))
+        Download(server, filename)
+        self.got_files.append(filename)
         
 class LocalDists (Dists):
     """
@@ -60,6 +78,7 @@
             for d in backend["distributions"]:
                 for a in backend["architectures"]:
                     for f in ["Packages.gz", "Sources.gz", "Release"]:
-                        self._files.append("%s/debian/%s/%s/binary-%s/%s" %
-                                          (backend["mirror_dir"] + backend["name"], d, c, a, f))
-        print self._files
+                        self._files.append("%s/debian/%s/%s/binary-%s/%s" \
+                                           % (backend["mirror_dir"] + backend["name"], d, c, a, f))
+    def _get(self, file):
+        print "LocalDists::_get(self, file): Not implemented yet! %s" % file