[dak/master] Move common code to the new get_packages_from_ftp()
Signed-off-by: Luca Falavigna <dktrkranz@debian.org>
---
dak/override.py | 12 +-----------
dak/override_disparity.py | 12 +-----------
daklib/utils.py | 21 +++++++++++++++++++++
3 files changed, 23 insertions(+), 22 deletions(-)
diff --git a/dak/override.py b/dak/override.py
index 6d5b82e..ddb829b 100755
--- a/dak/override.py
+++ b/dak/override.py
@@ -28,7 +28,6 @@
import os
import sys
import apt_pkg
-import commands
from daklib.config import Config
from daklib.dbconn import *
@@ -67,16 +66,7 @@ def check_override_compliance(package, priority, suite, cnf, session):
arches -= set(["source", "all"])
for arch in arches:
for component in components:
- filename = "%s/dists/%s/%s/binary-%s/Packages.gz" % (cnf["Dir::Root"], suite, component, arch)
- (fd, temp_filename) = utils.temp_filename()
- (result, output) = commands.getstatusoutput("gunzip -c %s > %s" % (filename, temp_filename))
- if (result != 0):
- utils.fubar("Gunzip invocation failed!\n%s\n" % (output), result)
- filename = "%s/dists/%s/%s/debian-installer/binary-%s/Packages.gz" % (cnf["Dir::Root"], suite, component, arch)
- if os.path.exists(filename):
- (result, output) = commands.getstatusoutput("gunzip -c %s >> %s" % (filename, temp_filename))
- if (result != 0):
- utils.fubar("Gunzip invocation failed!\n%s\n" % (output), result)
+ temp_filename = utils.get_packages_from_ftp(cnf['Dir::Root'], suite, component, arch)
packages = utils.open_file(temp_filename)
Packages = apt_pkg.ParseTagFile(packages)
while Packages.Step():
diff --git a/dak/override_disparity.py b/dak/override_disparity.py
index 7a3b290..94e1e9e 100755
--- a/dak/override_disparity.py
+++ b/dak/override_disparity.py
@@ -37,7 +37,6 @@ Generate a list of override disparities
import os
import sys
import apt_pkg
-import commands
from daklib.config import Config
from daklib.dbconn import *
@@ -85,16 +84,7 @@ def main():
arches -= set(['source', 'all'])
for arch in arches:
for component in components:
- filename = '%s/dists/%s/%s/binary-%s/Packages.gz' % (cnf['Dir::Root'], suite, component, arch)
- (fd, temp_filename) = utils.temp_filename()
- (result, output) = commands.getstatusoutput('gunzip -c %s > %s' % (filename, temp_filename))
- if (result != 0):
- utils.fubar('Gunzip invocation failed!\n%s\n' % (output), result)
- filename = '%s/dists/%s/%s/debian-installer/binary-%s/Packages.gz' % (cnf['Dir::Root'], suite, component, arch)
- if os.path.exists(filename):
- (result, output) = commands.getstatusoutput('gunzip -c %s >> %s' % (filename, temp_filename))
- if (result != 0):
- utils.fubar('Gunzip invocation failed!\n%s\n' % (output), result)
+ temp_filename = utils.get_packages_from_ftp(cnf['Dir::Root'], suite, component, arch)
packages_file = utils.open_file(temp_filename)
Packages = apt_pkg.ParseTagFile(packages_file)
while Packages.Step():
diff --git a/daklib/utils.py b/daklib/utils.py
index 1756f58..dffad27 100755
--- a/daklib/utils.py
+++ b/daklib/utils.py
@@ -1571,3 +1571,24 @@ def parse_wnpp_bug_file(file = "/srv/ftp-master.debian.org/scripts/masterfiles/w
bugs.append(bug_no)
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
--
1.5.6.5
Reply to: