[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[dak/security] Cleanup



---
 ChangeLog                     |    3 ++
 dak/check_proposed_updates.py |   46 ++++++++++++++++++++--------------------
 2 files changed, 26 insertions(+), 23 deletions(-)
 mode change 100644 => 100755 dak/check_proposed_updates.py

diff --git a/ChangeLog b/ChangeLog
index 212146d..6178c27 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2008-05-04  Joerg Jaspert  <joerg@debian.org>
 
+	* dak/check_proposed_updates.py: Import stuff from daklib as
+	"import daklib.foo as foo"
+
 	* dak/check_archive.py (check_files_not_symlinks): Remove
 	long-time unused and commented code. Import stuff from daklib as
 	"import daklib.foo as foo"
diff --git a/dak/check_proposed_updates.py b/dak/check_proposed_updates.py
old mode 100644
new mode 100755
index 3a86ef7..a4e7c0c
--- a/dak/check_proposed_updates.py
+++ b/dak/check_proposed_updates.py
@@ -30,8 +30,8 @@
 
 import pg, sys, os
 import apt_pkg, apt_inst
-import daklib.database
-import daklib.utils
+import daklib.database as database
+import daklib.utils as utils
 
 ################################################################################
 
@@ -79,7 +79,7 @@ def check_dep (depends, dep_type, check_archs, filename, files):
                     if stable[dep].has_key(arch):
                         if apt_pkg.CheckDep(stable[dep][arch], constraint, version):
                             if Options["debug"]:
-                                print "Found %s as a real package." % (daklib.utils.pp_deps(parsed_dep))
+                                print "Found %s as a real package." % (utils.pp_deps(parsed_dep))
                             unsat = 0
                             break
                 # As a virtual?
@@ -87,20 +87,20 @@ def check_dep (depends, dep_type, check_archs, filename, files):
                     if stable_virtual[dep].has_key(arch):
                         if not constraint and not version:
                             if Options["debug"]:
-                                print "Found %s as a virtual package." % (daklib.utils.pp_deps(parsed_dep))
+                                print "Found %s as a virtual package." % (utils.pp_deps(parsed_dep))
                             unsat = 0
                             break
                 # As part of the same .changes?
-                epochless_version = daklib.utils.re_no_epoch.sub('', version)
+                epochless_version = utils.re_no_epoch.sub('', version)
                 dep_filename = "%s_%s_%s.deb" % (dep, epochless_version, arch)
                 if files.has_key(dep_filename):
                     if Options["debug"]:
-                        print "Found %s in the same upload." % (daklib.utils.pp_deps(parsed_dep))
+                        print "Found %s in the same upload." % (utils.pp_deps(parsed_dep))
                     unsat = 0
                     break
                 # Not found...
                 # [FIXME: must be a better way ... ]
-                error = "%s not found. [Real: " % (daklib.utils.pp_deps(parsed_dep))
+                error = "%s not found. [Real: " % (utils.pp_deps(parsed_dep))
                 if stable.has_key(dep):
                     if stable[dep].has_key(arch):
                         error += "%s:%s:%s" % (dep, arch, stable[dep][arch])
@@ -125,7 +125,7 @@ def check_dep (depends, dep_type, check_archs, filename, files):
                 unsat.append(error)
 
             if unsat:
-                sys.stderr.write("MWAAP! %s: '%s' %s can not be satisifed:\n" % (filename, daklib.utils.pp_deps(parsed_dep), dep_type))
+                sys.stderr.write("MWAAP! %s: '%s' %s can not be satisifed:\n" % (filename, utils.pp_deps(parsed_dep), dep_type))
                 for error in unsat:
                     sys.stderr.write("  %s\n" % (error))
                 pkg_unsat = 1
@@ -134,9 +134,9 @@ def check_dep (depends, dep_type, check_archs, filename, files):
 
 def check_package(filename, files):
     try:
-        control = apt_pkg.ParseSection(apt_inst.debExtractControl(daklib.utils.open_file(filename)))
+        control = apt_pkg.ParseSection(apt_inst.debExtractControl(utils.open_file(filename)))
     except:
-        daklib.utils.warn("%s: debExtractControl() raised %s." % (filename, sys.exc_type))
+        utils.warn("%s: debExtractControl() raised %s." % (filename, sys.exc_type))
         return 1
     Depends = control.Find("Depends")
     Pre_Depends = control.Find("Pre-Depends")
@@ -173,10 +173,10 @@ def pass_fail (filename, result):
 
 def check_changes (filename):
     try:
-        changes = daklib.utils.parse_changes(filename)
-        files = daklib.utils.build_file_list(changes)
+        changes = utils.parse_changes(filename)
+        files = utils.build_file_list(changes)
     except:
-        daklib.utils.warn("Error parsing changes file '%s'" % (filename))
+        utils.warn("Error parsing changes file '%s'" % (filename))
         return
 
     result = 0
@@ -184,7 +184,7 @@ def check_changes (filename):
     # Move to the pool directory
     cwd = os.getcwd()
     f = files.keys()[0]
-    pool_dir = Cnf["Dir::Pool"] + '/' + daklib.utils.poolify(changes["source"], files[f]["component"])
+    pool_dir = Cnf["Dir::Pool"] + '/' + utils.poolify(changes["source"], files[f]["component"])
     os.chdir(pool_dir)
 
     changes_result = 0
@@ -210,7 +210,7 @@ def check_deb (filename):
 ################################################################################
 
 def check_joey (filename):
-    f = daklib.utils.open_file(filename)
+    f = utils.open_file(filename)
 
     cwd = os.getcwd()
     os.chdir("%s/dists/proposed-updates" % (Cnf["Dir::Root"]))
@@ -220,10 +220,10 @@ def check_joey (filename):
         if line.find('install') != -1:
             split_line = line.split()
             if len(split_line) != 2:
-                daklib.utils.fubar("Parse error (not exactly 2 elements): %s" % (line))
+                utils.fubar("Parse error (not exactly 2 elements): %s" % (line))
             install_type = split_line[0]
             if install_type not in [ "install", "install-u", "sync-install" ]:
-                daklib.utils.fubar("Unknown install type ('%s') from: %s" % (install_type, line))
+                utils.fubar("Unknown install type ('%s') from: %s" % (install_type, line))
             changes_filename = split_line[1]
             if Options["debug"]:
                 print "Processing %s..." % (changes_filename)
@@ -241,11 +241,11 @@ def parse_packages():
     suite = "stable"
     stable = {}
     components = Cnf.ValueList("Suite::%s::Components" % (suite))
-    architectures = filter(daklib.utils.real_arch, Cnf.ValueList("Suite::%s::Architectures" % (suite)))
+    architectures = filter(utils.real_arch, Cnf.ValueList("Suite::%s::Architectures" % (suite)))
     for component in components:
         for architecture in architectures:
             filename = "%s/dists/%s/%s/binary-%s/Packages" % (Cnf["Dir::Root"], suite, component, architecture)
-            packages = daklib.utils.open_file(filename, 'r')
+            packages = utils.open_file(filename, 'r')
             Packages = apt_pkg.ParseTagFile(packages)
             while Packages.Step():
                 package = Packages.Section.Find('Package')
@@ -267,7 +267,7 @@ def parse_packages():
 def main ():
     global Cnf, projectB, Options
 
-    Cnf = daklib.utils.get_conf()
+    Cnf = utils.get_conf()
 
     Arguments = [('d', "debug", "Check-Proposed-Updates::Options::Debug"),
                  ('q',"quiet","Check-Proposed-Updates::Options::Quiet"),
@@ -283,10 +283,10 @@ def main ():
     if Options["Help"]:
         usage(0)
     if not arguments:
-        daklib.utils.fubar("need at least one package name as an argument.")
+        utils.fubar("need at least one package name as an argument.")
 
     projectB = pg.connect(Cnf["DB::Name"], Cnf["DB::Host"], int(Cnf["DB::Port"]))
-    daklib.database.init(Cnf, projectB)
+    database.init(Cnf, projectB)
 
     print "Parsing packages files...",
     parse_packages()
@@ -300,7 +300,7 @@ def main ():
         elif f.endswith(".joey"):
             check_joey(f)
         else:
-            daklib.utils.fubar("Unrecognised file type: '%s'." % (f))
+            utils.fubar("Unrecognised file type: '%s'." % (f))
 
 #######################################################################################
 
-- 
1.5.6.5



Reply to: