From: Joerg Jaspert Date: Sat, 3 May 2008 23:44:24 +0000 (+0200) Subject: Use "import daklib.foo as foo" style X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0c3897b048c795b9684e6fdcab4e20123b610285;p=dak Use "import daklib.foo as foo" style --- diff --git a/ChangeLog b/ChangeLog index ff8cecb0..cb42ab4c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -6,6 +6,7 @@ * dak/clean_queues.py: likewise * dak/clean_suites.py: likewise * dak/compare_suites.py: likewise + * dak/cruft_report.py: likewise * dak/check_archive.py (check_files_not_symlinks): Remove long-time unused and commented code. Import stuff from daklib as diff --git a/dak/cruft_report.py b/dak/cruft_report.py old mode 100644 new mode 100755 index 02a38e0d..238cdd49 --- a/dak/cruft_report.py +++ b/dak/cruft_report.py @@ -29,8 +29,8 @@ import commands, pg, os, sys, time import apt_pkg -import daklib.database -import daklib.utils +import daklib.database as database +import daklib.utils as utils ################################################################################ @@ -117,7 +117,7 @@ def do_anais(architecture, binaries_list, source): ################################################################################ def do_nviu(): - experimental_id = daklib.database.get_suite_id("experimental") + experimental_id = database.get_suite_id("experimental") if experimental_id == -1: return # Check for packages in experimental obsoleted by versions in unstable @@ -127,7 +127,7 @@ SELECT s.source, s.version AS experimental, s2.version AS unstable WHERE sa.suite = %s AND sa2.suite = %d AND sa.source = s.id AND sa2.source = s2.id AND s.source = s2.source AND versioncmp(s.version, s2.version) < 0""" % (experimental_id, - daklib.database.get_suite_id("unstable"))) + database.get_suite_id("unstable"))) ql = q.getresult() if ql: nviu_to_remove = [] @@ -247,7 +247,7 @@ def do_obsolete_source(duplicate_bins, bin2source): def main (): global Cnf, projectB, suite, suite_id, source_binaries, source_versions - Cnf = daklib.utils.get_conf() + Cnf = utils.get_conf() Arguments = [('h',"help","Cruft-Report::Options::Help"), ('m',"mode","Cruft-Report::Options::Mode", "HasArg"), @@ -272,11 +272,11 @@ def main (): elif Options["Mode"] == "full": checks = [ "nbs", "nviu", "obsolete source", "dubious nbs", "bnb", "bms", "anais" ] else: - daklib.utils.warn("%s is not a recognised mode - only 'full' or 'daily' are understood." % (Options["Mode"])) + utils.warn("%s is not a recognised mode - only 'full' or 'daily' are understood." % (Options["Mode"])) usage(1) projectB = pg.connect(Cnf["DB::Name"], Cnf["DB::Host"], int(Cnf["DB::Port"])) - daklib.database.init(Cnf, projectB) + database.init(Cnf, projectB) bin_pkgs = {} src_pkgs = {} @@ -289,7 +289,7 @@ def main (): duplicate_bins = {} suite = Options["Suite"] - suite_id = daklib.database.get_suite_id(suite) + suite_id = database.get_suite_id(suite) bin_not_built = {} @@ -308,12 +308,12 @@ def main (): for component in components: filename = "%s/dists/%s/%s/source/Sources.gz" % (Cnf["Dir::Root"], suite, component) # apt_pkg.ParseTagFile needs a real file handle and can't handle a GzipFile instance... - temp_filename = daklib.utils.temp_filename() + temp_filename = utils.temp_filename() (result, output) = commands.getstatusoutput("gunzip -c %s > %s" % (filename, temp_filename)) if (result != 0): sys.stderr.write("Gunzip invocation failed!\n%s\n" % (output)) sys.exit(result) - sources = daklib.utils.open_file(temp_filename) + sources = utils.open_file(temp_filename) Sources = apt_pkg.ParseTagFile(sources) while Sources.Step(): source = Sources.Section.Find('Package') @@ -356,16 +356,16 @@ def main (): if suite != "experimental": check_components.append('main/debian-installer'); for component in check_components: - architectures = filter(daklib.utils.real_arch, Cnf.ValueList("Suite::%s::Architectures" % (suite))) + architectures = filter(utils.real_arch, Cnf.ValueList("Suite::%s::Architectures" % (suite))) for architecture in architectures: filename = "%s/dists/%s/%s/binary-%s/Packages.gz" % (Cnf["Dir::Root"], suite, component, architecture) # apt_pkg.ParseTagFile needs a real file handle - temp_filename = daklib.utils.temp_filename() + temp_filename = utils.temp_filename() (result, output) = commands.getstatusoutput("gunzip -c %s > %s" % (filename, temp_filename)) if (result != 0): sys.stderr.write("Gunzip invocation failed!\n%s\n" % (output)) sys.exit(result) - packages = daklib.utils.open_file(temp_filename) + packages = utils.open_file(temp_filename) Packages = apt_pkg.ParseTagFile(packages) while Packages.Step(): package = Packages.Section.Find('Package') @@ -382,7 +382,7 @@ def main (): bin2source[package]["version"] = version bin2source[package]["source"] = source if source.find("(") != -1: - m = daklib.utils.re_extract_src_version.match(source) + m = utils.re_extract_src_version.match(source) source = m.group(1) version = m.group(2) if not bin_pkgs.has_key(package):