r224 - branches/rewrite/src
Marco Presi
partial-mirror-devel@lists.alioth.debian.org
Mon, 20 Sep 2004 17:47:02 -0600
Author: zufus
Date: Mon Sep 20 17:47:01 2004
New Revision: 224
Modified:
branches/rewrite/src/Dists.py
Log:
Clear in Dists.py
Modified: branches/rewrite/src/Dists.py
==============================================================================
--- branches/rewrite/src/Dists.py (original)
+++ branches/rewrite/src/Dists.py Mon Sep 20 17:47:01 2004
@@ -18,68 +18,14 @@
import os
+from Backends import *
+
class Dists:
"""
This class provides methods to create backendss dirs into the
partial-mirror
"""
- _errors = [13]
- _ready = True
-
def __init__(self, backend, mirror_dir = "/var/cache/debpartial-mirror/"):
self.dir = mirror_dir + backend
- self.dist = os.path.join(self.dir, "dists")
- self.pool = os.path.join(self.dir, "pool")
- self._dirs = [self.dir,
- self.dist,
- self.pool]
-
- if not os.path.exists(mirror_dir):
- print "Warning! %s does not exists!!" % mirror_dir
- self._ready = False
-
- 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 """
- for directory in self._1dirs:
- if not self._check(directory):
- print "Dir %s not found" % directory
-
-
- def _create(self, path):
- """ Create dir """
- print "Attempt to create %s" % path
- try:
- os.mkdir (path)
- return "ok"
- except OSError, (errno,strerror):
- if errno in self._errors:
- return strerror
-
- def create(self):
- """ Create backend dir struct """
- if not self._ready:
- return
-
- for directory in self._dirs:
- ret = self._create(directory)
- if not ret=="ok":
- print ret
-
- def remove(self):
- """ Remove backend """
- self._dirs.reverse()
- for directory in self._dirs:
- if not self._check(directory):
- try:
- print "Removing %s" % directory
- os.rmdir(directory)
- except OSError, (errno, strerror):
- print strerror
- self._dirs.reverse()