r238 - in branches/rewrite: doc src tests

Marco Presi partial-mirror-devel@lists.alioth.debian.org
Wed, 22 Sep 2004 01:21:41 -0600


Author: zufus
Date: Wed Sep 22 01:21:40 2004
New Revision: 238

Modified:
   branches/rewrite/doc/HACKING
   branches/rewrite/src/Dists.py
   branches/rewrite/tests/dists.py
Log:
I am not sure which methods belong to Dists and to Backends..


Modified: branches/rewrite/doc/HACKING
==============================================================================
--- branches/rewrite/doc/HACKING	(original)
+++ branches/rewrite/doc/HACKING	Wed Sep 22 01:21:40 2004
@@ -17,12 +17,14 @@
 Dists - handle creation of dists dir into the partial-mirror.
   |
   +---------> RemoteDists - download index files (Packages.gz,
-  |			    Sources.gz, Release, sum files,...) from remote repository
+  |			    Sources.gz, Release, sum files,...) from
+  |			    remote repository
   |
   +---------> LocalDists  - move index files (Packages.gz,
-			    Sources.gz, Release, sum files,...) from local repository
+			    Sources.gz, Release, sum files,...) from
+			    local repository
 
-Pool - handle creation of dists dir into the partial-mirror.
+Pool - handle creation of "pool"s dir into the partial-mirror.
   |
   +---------> RemotePool - download packages from remote repository
   |

Modified: branches/rewrite/src/Dists.py
==============================================================================
--- branches/rewrite/src/Dists.py	(original)
+++ branches/rewrite/src/Dists.py	Wed Sep 22 01:21:40 2004
@@ -22,10 +22,37 @@
 
 class Dists:
     """
-    This class provides methods to create backendss dirs into the
+    This class provides methods to create dist dirs into the
     partial-mirror
     """
 
+    self._files = [Packages.gz,
+                   Sources.gz,
+                   Release]
+
     def __init__(self, backend, mirror_dir = "/var/cache/debpartial-mirror/"):
         self.dir = mirror_dir + backend
 
+
+    def _check(self, path):
+        """ Check if directories for this backend are already created """
+        if not os.path.exists (path):
+            return False
+
+    def check(self):
+        """ Check backend structure """
+        if not self._check(self.dir):
+                print "Dir %s not found" % directory
+
+    def create(self, path):
+        """ Create dist dir """
+        print "Attempt to create %s" % path
+        try:
+            os.mkdir (path)
+            return "ok"
+        except OSError, (errno,strerror):
+            if errno in self._errors:
+                return strerror
+
+
+    

Modified: branches/rewrite/tests/dists.py
==============================================================================
--- branches/rewrite/tests/dists.py	(original)
+++ branches/rewrite/tests/dists.py	Wed Sep 22 01:21:40 2004
@@ -1,9 +1,11 @@
+#!/usr/bin/python
+
 from sys import path, stdout
 path.append("../src/")
 
-from Dists import *
+from Backends import *
 
-d = Dists("sarge")
-d.create()
+b = Backends("sarge")
+b.create()
 
-d.remove()
+b.remove()