]> git.decadent.org.uk Git - dak.git/blobdiff - daklib/utils.py
Move common code to the new get_packages_from_ftp()
[dak.git] / daklib / utils.py
index 542ede51c8cab50c9b56fd0b09c7e15f3b5daabc..dffad274c508c9c06dccc9143c5be4c6c0490fc0 100755 (executable)
@@ -1548,7 +1548,14 @@ def parse_wnpp_bug_file(file = "/srv/ftp-master.debian.org/scripts/masterfiles/w
     returns a dict associating source package name with a list of open wnpp
     bugs (Yes, there might be more than one)
     """
-    lines = open(file).readlines()
+
+    line = []
+    try:
+        f = open(file)
+        lines = f.readlines()
+    except IOError, e:
+        print "Warning:  Couldn't open %s; don't know about WNPP bugs, so won't close any." % file
+       lines = []
     wnpp = {}
 
     for line in lines:
@@ -1565,3 +1572,23 @@ def parse_wnpp_bug_file(file = "/srv/ftp-master.debian.org/scripts/masterfiles/w
         wnpp[source] = bugs
     return wnpp
 
+################################################################################
+
+def get_packages_from_ftp(root, suite, component, architecture):
+    """
+    Returns a filename containing data collected by aggregating Packages.gz files
+    gathered for each architecture.
+
+    Returned file has to be manually deleted afterwards.
+    """
+    filename = "%s/dists/%s/%s/binary-%s/Packages.gz" % (root, suite, component, architecture)
+    (fd, temp_file) = temp_filename()
+    (result, output) = commands.getstatusoutput("gunzip -c %s > %s" % (filename, temp_file))
+    if (result != 0):
+        fubar("Gunzip invocation failed!\n%s\n" % (output), result)
+    filename = "%s/dists/%s/%s/debian-installer/binary-%s/Packages.gz" % (root, suite, component, architecture)
+    if os.path.exists(filename):
+        (result, output) = commands.getstatusoutput("gunzip -c %s >> %s" % (filename, temp_file))
+        if (result != 0):
+            fubar("Gunzip invocation failed!\n%s\n" % (output), result)
+    return temp_file