]> git.decadent.org.uk Git - dak.git/commitdiff
Merge from Thomas
authorJoerg Jaspert <joerg@debian.org>
Sun, 4 May 2008 09:13:30 +0000 (11:13 +0200)
committerJoerg Jaspert <joerg@debian.org>
Sun, 4 May 2008 09:13:30 +0000 (11:13 +0200)
42 files changed:
ChangeLog
config/debian/cron.dinstall
dak/check_archive.py [changed mode: 0644->0755]
dak/check_overrides.py
dak/check_proposed_updates.py [changed mode: 0644->0755]
dak/clean_proposed_updates.py [changed mode: 0644->0755]
dak/clean_queues.py [changed mode: 0644->0755]
dak/clean_suites.py [changed mode: 0644->0755]
dak/compare_suites.py [changed mode: 0644->0755]
dak/control_overrides.py
dak/control_suite.py
dak/cruft_report.py [changed mode: 0644->0755]
dak/dak.py [changed mode: 0644->0755]
dak/decode_dot_dak.py
dak/examine_package.py [changed mode: 0644->0755]
dak/find_null_maintainers.py [changed mode: 0644->0755]
dak/generate_index_diffs.py [changed mode: 0644->0755]
dak/generate_releases.py [changed mode: 0644->0755]
dak/import_archive.py [changed mode: 0644->0755]
dak/import_keyring.py [changed mode: 0644->0755]
dak/import_ldap_fingerprints.py [changed mode: 0644->0755]
dak/import_users_from_passwd.py [changed mode: 0644->0755]
dak/init_db.py [changed mode: 0644->0755]
dak/init_dirs.py [changed mode: 0644->0755]
dak/ls.py [changed mode: 0644->0755]
dak/make_maintainers.py [changed mode: 0644->0755]
dak/make_overrides.py [changed mode: 0644->0755]
dak/make_suite_file_list.py [changed mode: 0644->0755]
dak/new_security_install.py [changed mode: 0644->0755]
dak/override.py [changed mode: 0644->0755]
dak/process_accepted.py [changed mode: 0644->0755]
dak/process_new.py [changed mode: 0644->0755]
dak/process_unchecked.py [changed mode: 0644->0755]
dak/queue_report.py
dak/reject_proposed_updates.py
dak/rm.py [changed mode: 0644->0755]
dak/security_install.py
dak/show_new.py [changed mode: 0644->0755]
dak/split_done.py [changed mode: 0644->0755]
dak/stats.py [changed mode: 0644->0755]
dak/symlink_dists.py
dak/transitions.py [changed mode: 0644->0755]

index 6f67b2e2fbdbfa4ae302bebb773e3047fcd42f8e..eead3da3bcfc0b541efd1535f06d6401b3c600c3 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,8 +1,76 @@
+2008-05-04  Joerg Jaspert  <joerg@debian.org>
+
+       * dak/import_keyring.py: Remove unused daklib.logging and Logger
+       and add the actually used daklib/utils
+
+       * dak/examine_package.py: remove daklib.queue import, never used
+
+       * dak/check_proposed_updates.py: Import stuff from daklib as
+       "import daklib.foo as foo"
+       * dak/clean_proposed_updates.py: likewise
+       * dak/clean_queues.py: likewise
+       * dak/clean_suites.py: likewise
+       * dak/compare_suites.py: likewise
+       * dak/cruft_report.py: likewise
+       * dak/examine_package.py: likewise
+       * dak/find_null_maintainers.py: likewise
+       * dak/generate_index_diffs.py: likewise
+       * dak/generate_releases.py: likewise
+       * dak/import_archive.py: likewise
+       * dak/import_ldap_fingerprints.py: likewise
+       * dak/import_users_from_passwd.py: likewise
+       * dak/init_db.py: likewise
+       * dak/init_dirs.py: likewise
+       * dak/ls.py: likewise
+       * dak/make_maintainers.py: likewise
+       * dak/make_overrides.py: likewise
+       * dak/make_suite_file_list.py: likewise
+       * dak/new_security_install.py: likewise
+       * dak/override.py: likewise
+       * dak/process_accepted.py: likewise
+       * dak/process_new.py: likewise
+       * dak/process_unchecked.py: likewise
+       * dak/rm.py: likewise
+       * dak/show_new.py: likewise
+       * dak/split_done.py: likewise
+       * dak/stats.py: likewise
+       * dak/transitions.py: likewise
+
+       * 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"
+
 2008-05-04  Thomas Viehmann  <tv@beamnet.de>
 
        * dak/process_unchecked.py (check_signed_by_key): cater for uid_email
        None in sponsor notification
 
+2008-05-03  Joerg Jaspert  <joerg@debian.org>
+
+       * dak/examine_package.py: clean up pychecker warnings (merged with
+       Thomas changes to the NEW display)
+
+2008-05-03  Mark Hymers <mhy@debian.org>
+
+       * dak/check_archive.py: clean up pychecker warnings
+       * dak/check_overrides.py: likewise
+       * dak/check_proposed_updates.py: likewise
+       * dak/clean_proposed_updates.py: likewise
+       * dak/clean_queues.py: likewise
+       * dak/control_overrides.py: likewise
+       * dak/control_suite.py: likewise
+       * dak/decode_dot_dak.py: likewise
+       * dak/examine_package.py: likewise
+       * dak/process_new.py: likewise
+       * dak/process_unchecked.py: likewise
+       * dak/queue_report.py: likewise
+       * dak/reject_proposed_updates.py: likewise
+       * dak/security_install.py: likewise
+       * dak/show_new.py: likewise
+       * dak/stats.py: likewise
+       * dak/symlink_dists.py: likewise
+       * dak/transitions.py: likewise
+
 2008-05-03  Joerg Jaspert  <joerg@debian.org>
 
        * config/debian/cron.daily: Rename to
@@ -10,6 +78,7 @@
        daily for some time now. And while dinstall is an OLD name, its
        recognized pretty well within Debian
        Also add some more timing information
+       Do not allow automated [o-]p-u-new processing to break dinstall
 
 2008-05-03  Thomas Viehmann  <tv@beamnet.de>
 
index d8a69d62de4478af48045c1ad2c4b0fa368993ec..8813d519fa1c42a98eff79db75c06deda3702929 100755 (executable)
@@ -65,14 +65,14 @@ TS=$(($TS+1)); echo Archive maintenance timestamp $TS: $(date +%X)
 echo "Doing automated p-u-new processing"
 cd $queuedir/p-u-new
 date -u -R >> REPORT
-dak process-new -a -C COMMENTS >> REPORT
+dak process-new -a -C COMMENTS >> REPORT || true
 echo >> REPORT
 
 TS=$(($TS+1)); echo Archive maintenance timestamp $TS: $(date +%X)
 echo "Doing automated o-p-u-new processing"
 cd $queuedir/o-p-u-new
 date -u -R >> REPORT
-dak process-new -a -C COMMENTS >> REPORT
+dak process-new -a -C COMMENTS >> REPORT || true
 echo >> REPORT
 
 ################################################################################
old mode 100644 (file)
new mode 100755 (executable)
index ba208dd..c00aa08
@@ -28,8 +28,8 @@
 
 import commands, os, pg, stat, sys, time
 import apt_pkg, apt_inst
-import daklib.database
-import daklib.utils
+import daklib.database as database
+import daklib.utils as utils
 
 ################################################################################
 
@@ -105,8 +105,8 @@ def check_files():
 
     filename = Cnf["Dir::Override"]+'override.unreferenced'
     if os.path.exists(filename):
-        file = daklib.utils.open_file(filename)
-        for filename in file.readlines():
+        f = utils.open_file(filename)
+        for filename in f.readlines():
             filename = filename[:-1]
             excluded[filename] = ""
 
@@ -115,7 +115,7 @@ def check_files():
     os.path.walk(Cnf["Dir::Root"]+'pool/', process_dir, None)
 
     print
-    print "%s wasted..." % (daklib.utils.size_type(waste))
+    print "%s wasted..." % (utils.size_type(waste))
 
 ################################################################################
 
@@ -127,17 +127,17 @@ def check_dscs():
             continue
         component = component.lower()
         list_filename = '%s%s_%s_source.list' % (Cnf["Dir::Lists"], suite, component)
-        list_file = daklib.utils.open_file(list_filename)
+        list_file = utils.open_file(list_filename)
         for line in list_file.readlines():
-            file = line[:-1]
+            f = line[:-1]
             try:
-                daklib.utils.parse_changes(file, signing_rules=1)
-            except daklib.utils.invalid_dsc_format_exc, line:
-                daklib.utils.warn("syntax error in .dsc file '%s', line %s." % (file, line))
+                utils.parse_changes(f, signing_rules=1)
+            except utils.invalid_dsc_format_exc, line:
+                utils.warn("syntax error in .dsc file '%s', line %s." % (f, line))
                 count += 1
 
     if count:
-        daklib.utils.warn("Found %s invalid .dsc files." % (count))
+        utils.warn("Found %s invalid .dsc files." % (count))
 
 ################################################################################
 
@@ -146,7 +146,7 @@ def check_override():
         print suite
         print "-"*len(suite)
         print
-        suite_id = daklib.database.get_suite_id(suite)
+        suite_id = database.get_suite_id(suite)
         q = projectB.query("""
 SELECT DISTINCT b.package FROM binaries b, bin_associations ba
  WHERE b.id = ba.bin AND ba.suite = %s AND NOT EXISTS
@@ -205,16 +205,16 @@ def check_md5sums():
         db_md5sum = i[2]
         db_size = int(i[3])
         try:
-            file = daklib.utils.open_file(filename)
+            f = utils.open_file(filename)
         except:
-            daklib.utils.warn("can't open '%s'." % (filename))
+            utils.warn("can't open '%s'." % (filename))
             continue
-        md5sum = apt_pkg.md5sum(file)
+        md5sum = apt_pkg.md5sum(f)
         size = os.stat(filename)[stat.ST_SIZE]
         if md5sum != db_md5sum:
-            daklib.utils.warn("**WARNING** md5sum mismatch for '%s' ('%s' [current] vs. '%s' [db])." % (filename, md5sum, db_md5sum))
+            utils.warn("**WARNING** md5sum mismatch for '%s' ('%s' [current] vs. '%s' [db])." % (filename, md5sum, db_md5sum))
         if size != db_size:
-            daklib.utils.warn("**WARNING** size mismatch for '%s' ('%s' [current] vs. '%s' [db])." % (filename, size, db_size))
+            utils.warn("**WARNING** size mismatch for '%s' ('%s' [current] vs. '%s' [db])." % (filename, size, db_size))
 
     print "Done."
 
@@ -240,12 +240,12 @@ def check_timestamps():
     for i in ql:
         filename = os.path.abspath(i[0] + i[1])
         if os.access(filename, os.R_OK):
-            file = daklib.utils.open_file(filename)
+            f = utils.open_file(filename)
             current_file = filename
             sys.stderr.write("Processing %s.\n" % (filename))
-            apt_inst.debExtract(file,Ent,"control.tar.gz")
-            file.seek(0)
-            apt_inst.debExtract(file,Ent,"data.tar.gz")
+            apt_inst.debExtract(f, Ent, "control.tar.gz")
+            f.seek(0)
+            apt_inst.debExtract(f, Ent, "data.tar.gz")
             count += 1
     print "Checked %d files (out of %d)." % (count, len(db_files.keys()))
 
@@ -265,24 +265,24 @@ def check_missing_tar_gz_in_dsc():
         filename = os.path.abspath(i[0] + i[1])
         try:
             # NB: don't enforce .dsc syntax
-            dsc = daklib.utils.parse_changes(filename)
+            dsc = utils.parse_changes(filename)
         except:
-            daklib.utils.fubar("error parsing .dsc file '%s'." % (filename))
-        dsc_files = daklib.utils.build_file_list(dsc, is_a_dsc=1)
+            utils.fubar("error parsing .dsc file '%s'." % (filename))
+        dsc_files = utils.build_file_list(dsc, is_a_dsc=1)
         has_tar = 0
-        for file in dsc_files.keys():
-            m = daklib.utils.re_issource.match(file)
+        for f in dsc_files.keys():
+            m = utils.re_issource.match(f)
             if not m:
-                daklib.utils.fubar("%s not recognised as source." % (file))
-            type = m.group(3)
-            if type == "orig.tar.gz" or type == "tar.gz":
+                utils.fubar("%s not recognised as source." % (f))
+            ftype = m.group(3)
+            if ftype == "orig.tar.gz" or ftype == "tar.gz":
                 has_tar = 1
         if not has_tar:
-            daklib.utils.warn("%s has no .tar.gz in the .dsc file." % (file))
+            utils.warn("%s has no .tar.gz in the .dsc file." % (f))
             count += 1
 
     if count:
-        daklib.utils.warn("Found %s invalid .dsc files." % (count))
+        utils.warn("Found %s invalid .dsc files." % (count))
 
 
 ################################################################################
@@ -291,12 +291,12 @@ def validate_sources(suite, component):
     filename = "%s/dists/%s/%s/source/Sources.gz" % (Cnf["Dir::Root"], suite, component)
     print "Processing %s..." % (filename)
     # 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')
@@ -309,7 +309,7 @@ def validate_sources(suite, component):
                 if directory.find("potato") == -1:
                     print "W: %s missing." % (filename)
                 else:
-                    pool_location = daklib.utils.poolify (source, component)
+                    pool_location = utils.poolify (source, component)
                     pool_filename = "%s/%s/%s" % (Cnf["Dir::Pool"], pool_location, name)
                     if not os.path.exists(pool_filename):
                         print "E: %s missing (%s)." % (filename, pool_filename)
@@ -317,7 +317,7 @@ def validate_sources(suite, component):
                         # Create symlink
                         pool_filename = os.path.normpath(pool_filename)
                         filename = os.path.normpath(filename)
-                        src = daklib.utils.clean_symlink(pool_filename, filename, Cnf["Dir::Root"])
+                        src = utils.clean_symlink(pool_filename, filename, Cnf["Dir::Root"])
                         print "Symlinking: %s -> %s" % (filename, src)
                         #os.symlink(src, filename)
     sources.close()
@@ -330,12 +330,12 @@ def validate_packages(suite, component, architecture):
                % (Cnf["Dir::Root"], suite, component, architecture)
     print "Processing %s..." % (filename)
     # 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)
-    packages = daklib.utils.open_file(temp_filename)
+    packages = utils.open_file(temp_filename)
     Packages = apt_pkg.ParseTagFile(packages)
     while Packages.Step():
         filename = "%s/%s" % (Cnf["Dir::Root"], Packages.Section.Find('Filename'))
@@ -367,39 +367,13 @@ def check_files_not_symlinks():
     print "done. (%d seconds)" % (int(time.time()-before))
     q_files = q.getresult()
 
-#      locations = {}
-#      q = projectB.query("SELECT l.path, c.name, l.id FROM location l, component c WHERE l.component = c.id")
-#      for i in q.getresult():
-#          path = os.path.normpath(i[0] + i[1])
-#          locations[path] = (i[0], i[2])
-
-#      q = projectB.query("BEGIN WORK")
     for i in q_files:
         filename = os.path.normpath(i[0] + i[1])
-#        file_id = i[2]
         if os.access(filename, os.R_OK) == 0:
-            daklib.utils.warn("%s: doesn't exist." % (filename))
+            utils.warn("%s: doesn't exist." % (filename))
         else:
             if os.path.islink(filename):
-                daklib.utils.warn("%s: is a symlink." % (filename))
-                # You probably don't want to use the rest of this...
-#                  print "%s: is a symlink." % (filename)
-#                  dest = os.readlink(filename)
-#                  if not os.path.isabs(dest):
-#                      dest = os.path.normpath(os.path.join(os.path.dirname(filename), dest))
-#                  print "--> %s" % (dest)
-#                  # Determine suitable location ID
-#                  # [in what must be the suckiest way possible?]
-#                  location_id = None
-#                  for path in locations.keys():
-#                      if dest.find(path) == 0:
-#                          (location, location_id) = locations[path]
-#                          break
-#                  if not location_id:
-#                      daklib.utils.fubar("Can't find location for %s (%s)." % (dest, filename))
-#                  new_filename = dest.replace(location, "")
-#                  q = projectB.query("UPDATE files SET filename = '%s', location = %s WHERE id = %s" % (new_filename, location_id, file_id))
-#      q = projectB.query("COMMIT WORK")
+                utils.warn("%s: is a symlink." % (filename))
 
 ################################################################################
 
@@ -408,7 +382,7 @@ def chk_bd_process_dir (unused, dirname, filenames):
         if not name.endswith(".dsc"):
             continue
         filename = os.path.abspath(dirname+'/'+name)
-        dsc = daklib.utils.parse_changes(filename)
+        dsc = utils.parse_changes(filename)
         for field_name in [ "build-depends", "build-depends-indep" ]:
             field = dsc.get(field_name)
             if field:
@@ -428,7 +402,7 @@ def check_build_depends():
 def main ():
     global Cnf, projectB, db_files, waste, excluded
 
-    Cnf = daklib.utils.get_conf()
+    Cnf = utils.get_conf()
     Arguments = [('h',"help","Check-Archive::Options::Help")]
     for i in [ "help" ]:
         if not Cnf.has_key("Check-Archive::Options::%s" % (i)):
@@ -441,15 +415,15 @@ def main ():
         usage()
 
     if len(args) < 1:
-        daklib.utils.warn("dak check-archive requires at least one argument")
+        utils.warn("dak check-archive requires at least one argument")
         usage(1)
     elif len(args) > 1:
-        daklib.utils.warn("dak check-archive accepts only one argument")
+        utils.warn("dak check-archive accepts only one argument")
         usage(1)
     mode = args[0].lower()
 
     projectB = pg.connect(Cnf["DB::Name"], Cnf["DB::Host"], int(Cnf["DB::Port"]))
-    daklib.database.init(Cnf, projectB)
+    database.init(Cnf, projectB)
 
     if mode == "md5sums":
         check_md5sums()
@@ -472,7 +446,7 @@ def main ():
     elif mode == "validate-builddeps":
         check_build_depends()
     else:
-        daklib.utils.warn("unknown mode '%s'" % (mode))
+        utils.warn("unknown mode '%s'" % (mode))
         usage(1)
 
 ################################################################################
index ecbaa75b60bfd9b9b3a880b0781523b4c8571115..cdab644935f67a866408da210f087360235dd87c 100644 (file)
@@ -50,9 +50,9 @@
 
 import pg, sys, os
 import apt_pkg
-import daklib.database
-import daklib.logging
-import daklib.utils
+import daklib.database as database
+import daklib.logging as logging
+import daklib.utils as utils
 
 ################################################################################
 
@@ -84,26 +84,25 @@ def gen_blacklist(dir):
 def process(osuite, affected_suites, originosuite, component, type):
     global Logger, Options, projectB, sections, priorities
 
-    osuite_id = daklib.database.get_suite_id(osuite)
+    osuite_id = database.get_suite_id(osuite)
     if osuite_id == -1:
-        daklib.utils.fubar("Suite '%s' not recognised." % (osuite))
+        utils.fubar("Suite '%s' not recognised." % (osuite))
     originosuite_id = None
     if originosuite:
-        originosuite_id = daklib.database.get_suite_id(originosuite)
+        originosuite_id = database.get_suite_id(originosuite)
         if originosuite_id == -1:
-            daklib.utils.fubar("Suite '%s' not recognised." % (originosuite))
+            utils.fubar("Suite '%s' not recognised." % (originosuite))
 
-    component_id = daklib.database.get_component_id(component)
+    component_id = database.get_component_id(component)
     if component_id == -1:
-        daklib.utils.fubar("Component '%s' not recognised." % (component))
+        utils.fubar("Component '%s' not recognised." % (component))
 
-    type_id = daklib.database.get_override_type_id(type)
+    type_id = database.get_override_type_id(type)
     if type_id == -1:
-        daklib.utils.fubar("Type '%s' not recognised. (Valid types are deb, udeb and dsc)" % (type))
-    dsc_type_id = daklib.database.get_override_type_id("dsc")
-    deb_type_id = daklib.database.get_override_type_id("deb")
+        utils.fubar("Type '%s' not recognised. (Valid types are deb, udeb and dsc)" % (type))
+    dsc_type_id = database.get_override_type_id("dsc")
 
-    source_priority_id = daklib.database.get_priority_id("source")
+    source_priority_id = database.get_priority_id("source")
 
     if type == "deb" or type == "udeb":
         packages = {}
@@ -138,7 +137,7 @@ SELECT s.source FROM source s, src_associations sa, files f, location l,
                 src_packages[package] = 1
             else:
                 if blacklist.has_key(package):
-                    daklib.utils.warn("%s in incoming, not touching" % package)
+                    utils.warn("%s in incoming, not touching" % package)
                     continue
                 Logger.log(["removing unused override", osuite, component,
                     type, package, priorities[i[1]], sections[i[2]], i[3]])
@@ -202,7 +201,7 @@ SELECT s.source FROM source s, src_associations sa, files f, location l,
 
         for package, hasoverride in src_packages.items():
             if not hasoverride:
-                daklib.utils.warn("%s has no override!" % package)
+                utils.warn("%s has no override!" % package)
 
     else: # binary override
         for i in q.getresult():
@@ -211,7 +210,7 @@ SELECT s.source FROM source s, src_associations sa, files f, location l,
                 packages[package] = 1
             else:
                 if blacklist.has_key(package):
-                    daklib.utils.warn("%s in incoming, not touching" % package)
+                    utils.warn("%s in incoming, not touching" % package)
                     continue
                 Logger.log(["removing unused override", osuite, component,
                     type, package, priorities[i[1]], sections[i[2]], i[3]])
@@ -256,7 +255,7 @@ SELECT s.source FROM source s, src_associations sa, files f, location l,
 
         for package, hasoverride in packages.items():
             if not hasoverride:
-                daklib.utils.warn("%s has no override!" % package)
+                utils.warn("%s has no override!" % package)
 
     projectB.query("COMMIT WORK")
     sys.stdout.flush()
@@ -267,7 +266,7 @@ SELECT s.source FROM source s, src_associations sa, files f, location l,
 def main ():
     global Logger, Options, projectB, sections, priorities
 
-    Cnf = daklib.utils.get_conf()
+    Cnf = utils.get_conf()
 
     Arguments = [('h',"help","Check-Overrides::Options::Help"),
                  ('n',"no-action", "Check-Overrides::Options::No-Action")]
@@ -281,7 +280,7 @@ def main ():
         usage()
 
     projectB = pg.connect(Cnf["DB::Name"], Cnf["DB::Host"], int(Cnf["DB::Port"]))
-    daklib.database.init(Cnf, projectB)
+    database.init(Cnf, projectB)
 
     # init sections, priorities:
     q = projectB.query("SELECT id, section FROM section")
@@ -292,9 +291,9 @@ def main ():
         priorities[i[0]] = i[1]
 
     if not Options["No-Action"]:
-        Logger = daklib.logging.Logger(Cnf, "check-overrides")
+        Logger = logging.Logger(Cnf, "check-overrides")
     else:
-        Logger = daklib.logging.Logger(Cnf, "check-overrides", 1)
+        Logger = logging.Logger(Cnf, "check-overrides", 1)
 
     gen_blacklist(Cnf["Dir::Queue::Accepted"])
 
@@ -329,7 +328,7 @@ def main ():
             suiteids.append(i[0])
 
         if len(suiteids) != len(suites) or len(suiteids) < 1:
-            daklib.utils.fubar("Couldn't find id's of all suites: %s" % suites)
+            utils.fubar("Couldn't find id's of all suites: %s" % suites)
 
         for component in Cnf.SubTree("Component").List():
             if component == "mixed":
old mode 100644 (file)
new mode 100755 (executable)
index 529f0a0..a4e7c0c
@@ -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,26 +173,26 @@ 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
 
     # Move to the pool directory
     cwd = os.getcwd()
-    file = files.keys()[0]
-    pool_dir = Cnf["Dir::Pool"] + '/' + daklib.utils.poolify(changes["source"], files[file]["component"])
+    f = files.keys()[0]
+    pool_dir = Cnf["Dir::Pool"] + '/' + utils.poolify(changes["source"], files[f]["component"])
     os.chdir(pool_dir)
 
     changes_result = 0
-    for file in files.keys():
-        if file.endswith(".deb"):
-            result = check_package(file, files)
+    for f in files.keys():
+        if f.endswith(".deb"):
+            result = check_package(f, files)
             if Options["verbose"]:
-                pass_fail(file, result)
+                pass_fail(f, result)
             changes_result += result
 
     pass_fail (filename, changes_result)
@@ -210,25 +210,25 @@ def check_deb (filename):
 ################################################################################
 
 def check_joey (filename):
-    file = daklib.utils.open_file(filename)
+    f = utils.open_file(filename)
 
     cwd = os.getcwd()
     os.chdir("%s/dists/proposed-updates" % (Cnf["Dir::Root"]))
 
-    for line in file.readlines():
+    for line in f.readlines():
         line = line.rstrip()
         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)
             check_changes(changes_filename)
-    file.close()
+    f.close()
 
     os.chdir(cwd)
 
@@ -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,24 +283,24 @@ 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()
     print "done."
 
-    for file in arguments:
-        if file.endswith(".changes"):
-            check_changes(file)
-        elif file.endswith(".deb"):
-            check_deb(file)
-        elif file.endswith(".joey"):
-            check_joey(file)
+    for f in arguments:
+        if f.endswith(".changes"):
+            check_changes(f)
+        elif f.endswith(".deb"):
+            check_deb(f)
+        elif f.endswith(".joey"):
+            check_joey(f)
         else:
-            daklib.utils.fubar("Unrecognised file type: '%s'." % (file))
+            utils.fubar("Unrecognised file type: '%s'." % (f))
 
 #######################################################################################
 
old mode 100644 (file)
new mode 100755 (executable)
index 02032b1..fc063dd
@@ -21,8 +21,8 @@
 
 import os, pg, re, sys
 import apt_pkg
-import daklib.database
-import daklib.utils
+import daklib.database as database
+import daklib.utils as utils
 
 ################################################################################
 
@@ -49,58 +49,58 @@ Need either changes files or an admin.txt file with a '.joey' suffix."""
 
 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("Couldn't read changes file '%s'." % (filename))
+        utils.warn("Couldn't read changes file '%s'." % (filename))
         return
     num_files = len(files.keys())
-    for file in files.keys():
-        if daklib.utils.re_isadeb.match(file):
-            m = re_isdeb.match(file)
+    for f in files.keys():
+        if utils.re_isadeb.match(f):
+            m = re_isdeb.match(f)
             pkg = m.group(1)
             version = m.group(2)
             arch = m.group(3)
             if Options["debug"]:
-                print "BINARY: %s ==> %s_%s_%s" % (file, pkg, version, arch)
+                print "BINARY: %s ==> %s_%s_%s" % (f, pkg, version, arch)
         else:
-            m = daklib.utils.re_issource.match(file)
+            m = utils.re_issource.match(f)
             if m:
                 pkg = m.group(1)
                 version = m.group(2)
-                type = m.group(3)
-                if type != "dsc":
-                    del files[file]
+                ftype = m.group(3)
+                if ftype != "dsc":
+                    del files[f]
                     num_files -= 1
                     continue
                 arch = "source"
                 if Options["debug"]:
-                    print "SOURCE: %s ==> %s_%s_%s" % (file, pkg, version, arch)
+                    print "SOURCE: %s ==> %s_%s_%s" % (f, pkg, version, arch)
             else:
-                daklib.utils.fubar("unknown type, fix me")
+                utils.fubar("unknown type, fix me")
         if not pu.has_key(pkg):
             # FIXME
-            daklib.utils.warn("%s doesn't seem to exist in %s?? (from %s [%s])" % (pkg, Options["suite"], file, filename))
+            utils.warn("%s doesn't seem to exist in %s?? (from %s [%s])" % (pkg, Options["suite"], f, filename))
             continue
         if not pu[pkg].has_key(arch):
             # FIXME
-            daklib.utils.warn("%s doesn't seem to exist for %s in %s?? (from %s [%s])" % (pkg, arch, Options["suite"], file, filename))
+            utils.warn("%s doesn't seem to exist for %s in %s?? (from %s [%s])" % (pkg, arch, Options["suite"], f, filename))
             continue
-        pu_version = daklib.utils.re_no_epoch.sub('', pu[pkg][arch])
+        pu_version = utils.re_no_epoch.sub('', pu[pkg][arch])
         if pu_version == version:
             if Options["verbose"]:
-                print "%s: ok" % (file)
+                print "%s: ok" % (f)
         else:
             if Options["verbose"]:
-                print "%s: superseded, removing. [%s]" % (file, pu_version)
-            del files[file]
+                print "%s: superseded, removing. [%s]" % (f, pu_version)
+            del files[f]
 
     new_num_files = len(files.keys())
     if new_num_files == 0:
         print "%s: no files left, superseded by %s" % (filename, pu_version)
         dest = Cnf["Dir::Morgue"] + "/misc/"
         if not Options["no-action"]:
-            daklib.utils.move(filename, dest)
+            utils.move(filename, dest)
     elif new_num_files < num_files:
         print "%s: lost files, MWAAP." % (filename)
     else:
@@ -110,20 +110,20 @@ def check_changes (filename):
 ################################################################################
 
 def check_joey (filename):
-    file = daklib.utils.open_file(filename)
+    f = utils.open_file(filename)
 
     cwd = os.getcwd()
     os.chdir("%s/dists/%s" % (Cnf["Dir::Root"]), Options["suite"])
 
-    for line in file.readlines():
+    for line in f.readlines():
         line = line.rstrip()
         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)
@@ -159,7 +159,7 @@ ORDER BY package, version, arch_string
 def main ():
     global Cnf, projectB, Options
 
-    Cnf = daklib.utils.get_conf()
+    Cnf = utils.get_conf()
 
     Arguments = [('d', "debug", "Clean-Proposed-Updates::Options::Debug"),
                  ('v', "verbose", "Clean-Proposed-Updates::Options::Verbose"),
@@ -180,20 +180,20 @@ 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)
 
     init_pu()
 
-    for file in arguments:
-        if file.endswith(".changes"):
-            check_changes(file)
-        elif file.endswith(".joey"):
-            check_joey(file)
+    for f in arguments:
+        if f.endswith(".changes"):
+            check_changes(f)
+        elif f.endswith(".joey"):
+            check_joey(f)
         else:
-            daklib.utils.fubar("Unrecognised file type: '%s'." % (file))
+            utils.fubar("Unrecognised file type: '%s'." % (f))
 
 #######################################################################################
 
old mode 100644 (file)
new mode 100755 (executable)
index 43f8ffb..30e0baf
@@ -35,7 +35,7 @@
 
 import os, stat, sys, time
 import apt_pkg
-import daklib.utils
+import daklib.utils as utils
 
 ################################################################################
 
@@ -72,7 +72,7 @@ def init ():
         if not os.path.exists(del_dir):
             os.makedirs(del_dir, 02775)
         if not os.path.isdir(del_dir):
-            daklib.utils.fubar("%s must be a directory." % (del_dir))
+            utils.fubar("%s must be a directory." % (del_dir))
 
     # Move to the directory to clean
     incoming = Options["Incoming"]
@@ -81,32 +81,32 @@ def init ():
     os.chdir(incoming)
 
 # Remove a file to the morgue
-def remove (file):
-    if os.access(file, os.R_OK):
-        dest_filename = del_dir + '/' + os.path.basename(file)
+def remove (f):
+    if os.access(f, os.R_OK):
+        dest_filename = del_dir + '/' + os.path.basename(f)
         # If the destination file exists; try to find another filename to use
         if os.path.exists(dest_filename):
-            dest_filename = daklib.utils.find_next_free(dest_filename, 10)
-        daklib.utils.move(file, dest_filename, 0660)
+            dest_filename = utils.find_next_free(dest_filename, 10)
+        utils.move(f, dest_filename, 0660)
     else:
-        daklib.utils.warn("skipping '%s', permission denied." % (os.path.basename(file)))
+        utils.warn("skipping '%s', permission denied." % (os.path.basename(f)))
 
 # Removes any old files.
 # [Used for Incoming/REJECT]
 #
 def flush_old ():
-    for file in os.listdir('.'):
-        if os.path.isfile(file):
-            if os.stat(file)[stat.ST_MTIME] < delete_date:
+    for f in os.listdir('.'):
+        if os.path.isfile(f):
+            if os.stat(f)[stat.ST_MTIME] < delete_date:
                 if Options["No-Action"]:
-                    print "I: Would delete '%s'." % (os.path.basename(file))
+                    print "I: Would delete '%s'." % (os.path.basename(f))
                 else:
                     if Options["Verbose"]:
-                        print "Removing '%s' (to '%s')."  % (os.path.basename(file), del_dir)
-                    remove(file)
+                        print "Removing '%s' (to '%s')."  % (os.path.basename(f), del_dir)
+                    remove(f)
             else:
                 if Options["Verbose"]:
-                    print "Skipping, too new, '%s'." % (os.path.basename(file))
+                    print "Skipping, too new, '%s'." % (os.path.basename(f))
 
 # Removes any files which are old orphans (not associated with a valid .changes file).
 # [Used for Incoming]
@@ -125,20 +125,20 @@ def flush_orphans ():
     # Proces all .changes and .dsc files.
     for changes_filename in changes_files:
         try:
-            changes = daklib.utils.parse_changes(changes_filename)
-            files = daklib.utils.build_file_list(changes)
+            changes = utils.parse_changes(changes_filename)
+            files = utils.build_file_list(changes)
         except:
-            daklib.utils.warn("error processing '%s'; skipping it. [Got %s]" % (changes_filename, sys.exc_type))
+            utils.warn("error processing '%s'; skipping it. [Got %s]" % (changes_filename, sys.exc_type))
             continue
 
         dsc_files = {}
-        for file in files.keys():
-            if file.endswith(".dsc"):
+        for f in files.keys():
+            if f.endswith(".dsc"):
                 try:
-                    dsc = daklib.utils.parse_changes(file)
-                    dsc_files = daklib.utils.build_file_list(dsc, is_a_dsc=1)
+                    dsc = utils.parse_changes(f)
+                    dsc_files = utils.build_file_list(dsc, is_a_dsc=1)
                 except:
-                    daklib.utils.warn("error processing '%s'; skipping it. [Got %s]" % (file, sys.exc_type))
+                    utils.warn("error processing '%s'; skipping it. [Got %s]" % (f, sys.exc_type))
                     continue
 
         # Ensure all the files we've seen aren't deleted
@@ -153,24 +153,24 @@ def flush_orphans ():
 
     # Anthing left at this stage is not referenced by a .changes (or
     # a .dsc) and should be deleted if old enough.
-    for file in all_files.keys():
-        if os.stat(file)[stat.ST_MTIME] < delete_date:
+    for f in all_files.keys():
+        if os.stat(f)[stat.ST_MTIME] < delete_date:
             if Options["No-Action"]:
-                print "I: Would delete '%s'." % (os.path.basename(file))
+                print "I: Would delete '%s'." % (os.path.basename(f))
             else:
                 if Options["Verbose"]:
-                    print "Removing '%s' (to '%s')."  % (os.path.basename(file), del_dir)
-                remove(file)
+                    print "Removing '%s' (to '%s')."  % (os.path.basename(f), del_dir)
+                remove(f)
         else:
             if Options["Verbose"]:
-                print "Skipping, too new, '%s'." % (os.path.basename(file))
+                print "Skipping, too new, '%s'." % (os.path.basename(f))
 
 ################################################################################
 
 def main ():
     global Cnf, Options
 
-    Cnf = daklib.utils.get_conf()
+    Cnf = utils.get_conf()
 
     for i in ["Help", "Incoming", "No-Action", "Verbose" ]:
         if not Cnf.has_key("Clean-Queues::Options::%s" % (i)):
old mode 100644 (file)
new mode 100755 (executable)
index cb7225b..f459cdd
@@ -30,7 +30,7 @@
 
 import os, pg, stat, sys, time
 import apt_pkg
-import daklib.utils
+import daklib.utils as utils
 
 ################################################################################
 
@@ -208,7 +208,7 @@ def clean():
     for i in q.getresult():
         filename = i[0] + i[1]
         if not os.path.exists(filename):
-            daklib.utils.warn("can not find '%s'." % (filename))
+            utils.warn("can not find '%s'." % (filename))
             continue
         if os.path.isfile(filename):
             if os.path.islink(filename):
@@ -224,14 +224,14 @@ def clean():
                 dest_filename = dest + '/' + os.path.basename(filename)
                 # If the destination file exists; try to find another filename to use
                 if os.path.exists(dest_filename):
-                    dest_filename = daklib.utils.find_next_free(dest_filename)
+                    dest_filename = utils.find_next_free(dest_filename)
 
                 if Options["No-Action"]:
                     print "Cleaning %s -> %s ..." % (filename, dest_filename)
                 else:
-                    daklib.utils.move(filename, dest_filename)
+                    utils.move(filename, dest_filename)
         else:
-            daklib.utils.fubar("%s is neither symlink nor file?!" % (filename))
+            utils.fubar("%s is neither symlink nor file?!" % (filename))
 
     # Delete from the 'files' table
     if not Options["No-Action"]:
@@ -240,7 +240,7 @@ def clean():
         projectB.query("DELETE FROM files WHERE last_used <= '%s'" % (delete_date))
         sys.stdout.write("done. (%d seconds)]\n" % (int(time.time()-before)))
     if count > 0:
-        sys.stderr.write("Cleaned %d files, %s.\n" % (count, daklib.utils.size_type(size)))
+        sys.stderr.write("Cleaned %d files, %s.\n" % (count, utils.size_type(size)))
 
 ################################################################################
 
@@ -307,10 +307,10 @@ def clean_queue_build():
     for i in q.getresult():
         filename = i[0]
         if not os.path.exists(filename):
-            daklib.utils.warn("%s (from queue_build) doesn't exist." % (filename))
+            utils.warn("%s (from queue_build) doesn't exist." % (filename))
             continue
         if not Cnf.FindB("Dinstall::SecurityQueueBuild") and not os.path.islink(filename):
-            daklib.utils.fubar("%s (from queue_build) should be a symlink but isn't." % (filename))
+            utils.fubar("%s (from queue_build) should be a symlink but isn't." % (filename))
         os.unlink(filename)
         count += 1
     projectB.query("DELETE FROM queue_build WHERE last_used <= '%s'" % (our_delete_date))
@@ -323,7 +323,7 @@ def clean_queue_build():
 def main():
     global Cnf, Options, projectB, delete_date, now_date
 
-    Cnf = daklib.utils.get_conf()
+    Cnf = utils.get_conf()
     for i in ["Help", "No-Action" ]:
         if not Cnf.has_key("Clean-Suites::Options::%s" % (i)):
             Cnf["Clean-Suites::Options::%s" % (i)] = ""
old mode 100644 (file)
new mode 100755 (executable)
index e94d9f5..a3df829
@@ -22,8 +22,8 @@
 
 import pg, sys
 import apt_pkg
-import daklib.database
-import daklib.utils
+import daklib.database as database
+import daklib.utils as utils
 
 ################################################################################
 
@@ -44,7 +44,7 @@ Looks for fixable descrepancies between stable and unstable.
 def main ():
     global Cnf, projectB
 
-    Cnf = daklib.utils.get_conf()
+    Cnf = utils.get_conf()
     Arguments = [('h',"help","Compare-Suites::Options::Help")]
     for i in [ "help" ]:
         if not Cnf.has_key("Compare-Suites::Options::%s" % (i)):
@@ -57,15 +57,15 @@ def main ():
         usage()
 
     projectB = pg.connect(Cnf["DB::Name"], Cnf["DB::Host"], int(Cnf["DB::Port"]))
-    daklib.database.init(Cnf, projectB)
+    database.init(Cnf, projectB)
 
     src_suite = "stable"
     dst_suite = "unstable"
 
-    src_suite_id = daklib.database.get_suite_id(src_suite)
-    dst_suite_id = daklib.database.get_suite_id(dst_suite)
-    arch_all_id = daklib.database.get_architecture_id("all")
-    dsc_type_id = daklib.database.get_override_type_id("dsc")
+    src_suite_id = database.get_suite_id(src_suite)
+    dst_suite_id = database.get_suite_id(dst_suite)
+    arch_all_id = database.get_architecture_id("all")
+    dsc_type_id = database.get_override_type_id("dsc")
 
     for arch in Cnf.ValueList("Suite::%s::Architectures" % (src_suite)):
         if arch == "source":
@@ -77,7 +77,7 @@ def main ():
 
         if arch == "all":
             continue
-        arch_id = daklib.database.get_architecture_id(arch)
+        arch_id = database.get_architecture_id(arch)
         q = projectB.query("""
 SELECT b_src.package, b_src.version, a.arch_string
   FROM binaries b_src, bin_associations ba, override o, architecture a
index 2b1c0e09b541f07c52a8bd13d99c5dca806524ea..9ea1cd60c2bd813bafdb42e7d4df95facfa51203 100644 (file)
@@ -51,7 +51,9 @@
 
 import pg, sys, time
 import apt_pkg
-import daklib.utils, daklib.database, daklib.logging
+import daklib.utils as utils
+import daklib.database as database
+import daklib.logging as logging
 
 ################################################################################
 
@@ -84,17 +86,17 @@ def usage (exit_code=0):
 ################################################################################
 
 def process_file (file, suite, component, type, action):
-    suite_id = daklib.database.get_suite_id(suite)
+    suite_id = database.get_suite_id(suite)
     if suite_id == -1:
-        daklib.utils.fubar("Suite '%s' not recognised." % (suite))
+        utils.fubar("Suite '%s' not recognised." % (suite))
 
-    component_id = daklib.database.get_component_id(component)
+    component_id = database.get_component_id(component)
     if component_id == -1:
-        daklib.utils.fubar("Component '%s' not recognised." % (component))
+        utils.fubar("Component '%s' not recognised." % (component))
 
-    type_id = daklib.database.get_override_type_id(type)
+    type_id = database.get_override_type_id(type)
     if type_id == -1:
-        daklib.utils.fubar("Type '%s' not recognised. (Valid types are deb, udeb and dsc.)" % (type))
+        utils.fubar("Type '%s' not recognised. (Valid types are deb, udeb and dsc.)" % (type))
 
     # --set is done mostly internal for performance reasons; most
     # invocations of --set will be updates and making people wait 2-3
@@ -116,7 +118,7 @@ def process_file (file, suite, component, type, action):
     start_time = time.time()
     projectB.query("BEGIN WORK")
     for line in file.readlines():
-        line = daklib.utils.re_comments.sub('', line).strip()
+        line = utils.re_comments.sub('', line).strip()
         if line == "":
             continue
 
@@ -128,7 +130,7 @@ def process_file (file, suite, component, type, action):
             elif len(split_line) == 3:
                 (package, section, maintainer_override) = split_line
             else:
-                daklib.utils.warn("'%s' does not break into 'package section [maintainer-override]'." % (line))
+                utils.warn("'%s' does not break into 'package section [maintainer-override]'." % (line))
                 c_error += 1
                 continue
             priority = "source"
@@ -139,23 +141,23 @@ def process_file (file, suite, component, type, action):
             elif len(split_line) == 4:
                 (package, priority, section, maintainer_override) = split_line
             else:
-                daklib.utils.warn("'%s' does not break into 'package priority section [maintainer-override]'." % (line))
+                utils.warn("'%s' does not break into 'package priority section [maintainer-override]'." % (line))
                 c_error += 1
                 continue
 
-        section_id = daklib.database.get_section_id(section)
+        section_id = database.get_section_id(section)
         if section_id == -1:
-            daklib.utils.warn("'%s' is not a valid section. ['%s' in suite %s, component %s]." % (section, package, suite, component))
+            utils.warn("'%s' is not a valid section. ['%s' in suite %s, component %s]." % (section, package, suite, component))
             c_error += 1
             continue
-        priority_id = daklib.database.get_priority_id(priority)
+        priority_id = database.get_priority_id(priority)
         if priority_id == -1:
-            daklib.utils.warn("'%s' is not a valid priority. ['%s' in suite %s, component %s]." % (priority, package, suite, component))
+            utils.warn("'%s' is not a valid priority. ['%s' in suite %s, component %s]." % (priority, package, suite, component))
             c_error += 1
             continue
 
         if new.has_key(package):
-            daklib.utils.warn("Can't insert duplicate entry for '%s'; ignoring all but the first. [suite %s, component %s]" % (package, suite, component))
+            utils.warn("Can't insert duplicate entry for '%s'; ignoring all but the first. [suite %s, component %s]" % (package, suite, component))
             c_error += 1
             continue
         new[package] = ""
@@ -212,34 +214,34 @@ def process_file (file, suite, component, type, action):
 
 ################################################################################
 
-def list(suite, component, type):
-    suite_id = daklib.database.get_suite_id(suite)
+def list_overrides(suite, component, type):
+    suite_id = database.get_suite_id(suite)
     if suite_id == -1:
-        daklib.utils.fubar("Suite '%s' not recognised." % (suite))
+        utils.fubar("Suite '%s' not recognised." % (suite))
 
-    component_id = daklib.database.get_component_id(component)
+    component_id = database.get_component_id(component)
     if component_id == -1:
-        daklib.utils.fubar("Component '%s' not recognised." % (component))
+        utils.fubar("Component '%s' not recognised." % (component))
 
-    type_id = daklib.database.get_override_type_id(type)
+    type_id = database.get_override_type_id(type)
     if type_id == -1:
-        daklib.utils.fubar("Type '%s' not recognised. (Valid types are deb, udeb and dsc)" % (type))
+        utils.fubar("Type '%s' not recognised. (Valid types are deb, udeb and dsc)" % (type))
 
     if type == "dsc":
         q = projectB.query("SELECT o.package, s.section, o.maintainer FROM override o, section s WHERE o.suite = %s AND o.component = %s AND o.type = %s AND o.section = s.id ORDER BY s.section, o.package" % (suite_id, component_id, type_id))
         for i in q.getresult():
-            print daklib.utils.result_join(i)
+            print utils.result_join(i)
     else:
         q = projectB.query("SELECT o.package, p.priority, s.section, o.maintainer, p.level FROM override o, priority p, section s WHERE o.suite = %s AND o.component = %s AND o.type = %s AND o.priority = p.id AND o.section = s.id ORDER BY s.section, p.level, o.package" % (suite_id, component_id, type_id))
         for i in q.getresult():
-            print daklib.utils.result_join(i[:-1])
+            print utils.result_join(i[:-1])
 
 ################################################################################
 
 def main ():
     global Cnf, projectB, Logger
 
-    Cnf = daklib.utils.get_conf()
+    Cnf = utils.get_conf()
     Arguments = [('a', "add", "Control-Overrides::Options::Add"),
                  ('c', "component", "Control-Overrides::Options::Component", "HasArg"),
                  ('h', "help", "Control-Overrides::Options::Help"),
@@ -266,31 +268,31 @@ def main ():
         usage()
 
     projectB = pg.connect(Cnf["DB::Name"], Cnf["DB::Host"], int(Cnf["DB::Port"]))
-    daklib.database.init(Cnf, projectB)
+    database.init(Cnf, projectB)
 
     action = None
     for i in [ "add", "list", "set" ]:
         if Cnf["Control-Overrides::Options::%s" % (i)]:
             if action:
-                daklib.utils.fubar("Can not perform more than one action at once.")
+                utils.fubar("Can not perform more than one action at once.")
             action = i
 
-    (suite, component, type) = (Cnf["Control-Overrides::Options::Suite"],
-                                Cnf["Control-Overrides::Options::Component"],
-                                Cnf["Control-Overrides::Options::Type"])
+    (suite, component, otype) = (Cnf["Control-Overrides::Options::Suite"],
+                                 Cnf["Control-Overrides::Options::Component"],
+                                 Cnf["Control-Overrides::Options::Type"])
 
     if action == "list":
-        list(suite, component, type)
+        list_overrides(suite, component, otype)
     else:
         if Cnf.has_key("Suite::%s::Untouchable" % suite) and Cnf["Suite::%s::Untouchable" % suite] != 0:
-            daklib.utils.fubar("%s: suite is untouchable" % suite)
+            utils.fubar("%s: suite is untouchable" % suite)
 
-        Logger = daklib.logging.Logger(Cnf, "control-overrides")
+        Logger = logging.Logger(Cnf, "control-overrides")
         if file_list:
-            for file in file_list:
-                process_file(daklib.utils.open_file(file), suite, component, type, action)
+            for f in file_list:
+                process_file(utils.open_file(f), suite, component, otype, action)
         else:
-            process_file(sys.stdin, suite, component, type, action)
+            process_file(sys.stdin, suite, component, otype, action)
         Logger.close()
 
 #######################################################################################
index 5291b59564796e3e8f3f3579fc51db634854e216..63a0386b1ed0f26f14cc5033c2055defdee09e57 100644 (file)
@@ -43,9 +43,9 @@
 
 import pg, sys
 import apt_pkg
-import daklib.database
-import daklib.logging
-import daklib.utils
+import daklib.database as database
+import daklib.logging as logging
+import daklib.utils as utils
 
 #######################################################################################
 
@@ -77,13 +77,12 @@ def get_id (package, version, architecture):
 
     ql = q.getresult()
     if not ql:
-        daklib.utils.warn("Couldn't find '%s_%s_%s'." % (package, version, architecture))
+        utils.warn("Couldn't find '%s_%s_%s'." % (package, version, architecture))
         return None
     if len(ql) > 1:
-        daklib.utils.warn("Found more than one match for '%s_%s_%s'." % (package, version, architecture))
+        utils.warn("Found more than one match for '%s_%s_%s'." % (package, version, architecture))
         return None
-    id = ql[0][0]
-    return id
+    return ql[0][0]
 
 #######################################################################################
 
@@ -110,7 +109,7 @@ def set_suite (file, suite_id):
     for line in lines:
         split_line = line.strip().split()
         if len(split_line) != 3:
-            daklib.utils.warn("'%s' does not break into 'package version architecture'." % (line[:-1]))
+            utils.warn("'%s' does not break into 'package version architecture'." % (line[:-1]))
             continue
         key = " ".join(split_line)
         desired[key] = ""
@@ -119,25 +118,25 @@ def set_suite (file, suite_id):
     for key in current.keys():
         if not desired.has_key(key):
             (package, version, architecture) = key.split()
-            id = current[key]
+            pkid = current[key]
             if architecture == "source":
-                q = projectB.query("DELETE FROM src_associations WHERE id = %s" % (id))
+                q = projectB.query("DELETE FROM src_associations WHERE id = %s" % (pkid))
             else:
-                q = projectB.query("DELETE FROM bin_associations WHERE id = %s" % (id))
-            Logger.log(["removed",key,id])
+                q = projectB.query("DELETE FROM bin_associations WHERE id = %s" % (pkid))
+            Logger.log(["removed", key, pkid])
 
     # Check to see which packages need added and add them
     for key in desired.keys():
         if not current.has_key(key):
             (package, version, architecture) = key.split()
-            id = get_id (package, version, architecture)
-            if not id:
+            pkid = get_id (package, version, architecture)
+            if not pkid:
                 continue
             if architecture == "source":
-                q = projectB.query("INSERT INTO src_associations (suite, source) VALUES (%s, %s)" % (suite_id, id))
+                q = projectB.query("INSERT INTO src_associations (suite, source) VALUES (%s, %s)" % (suite_id, pkid))
             else:
-                q = projectB.query("INSERT INTO bin_associations (suite, bin) VALUES (%s, %s)" % (suite_id, id))
-            Logger.log(["added",key,id])
+                q = projectB.query("INSERT INTO bin_associations (suite, bin) VALUES (%s, %s)" % (suite_id, pkid))
+            Logger.log(["added", key, pkid])
 
     projectB.query("COMMIT WORK")
 
@@ -145,7 +144,7 @@ def set_suite (file, suite_id):
 
 def process_file (file, suite, action):
 
-    suite_id = daklib.database.get_suite_id(suite)
+    suite_id = database.get_suite_id(suite)
 
     if action == "set":
         set_suite (file, suite_id)
@@ -158,18 +157,18 @@ def process_file (file, suite, action):
     for line in lines:
         split_line = line.strip().split()
         if len(split_line) != 3:
-            daklib.utils.warn("'%s' does not break into 'package version architecture'." % (line[:-1]))
+            utils.warn("'%s' does not break into 'package version architecture'." % (line[:-1]))
             continue
 
         (package, version, architecture) = split_line
 
-        id = get_id(package, version, architecture)
-        if not id:
+        pkid = get_id(package, version, architecture)
+        if not pkid:
             continue
 
         if architecture == "source":
             # Find the existing assoications ID, if any
-            q = projectB.query("SELECT id FROM src_associations WHERE suite = %s and source = %s" % (suite_id, id))
+            q = projectB.query("SELECT id FROM src_associations WHERE suite = %s and source = %s" % (suite_id, pkid))
             ql = q.getresult()
             if not ql:
                 assoication_id = None
@@ -178,19 +177,19 @@ def process_file (file, suite, action):
             # Take action
             if action == "add":
                 if assoication_id:
-                    daklib.utils.warn("'%s_%s_%s' already exists in suite %s." % (package, version, architecture, suite))
+                    utils.warn("'%s_%s_%s' already exists in suite %s." % (package, version, architecture, suite))
                     continue
                 else:
-                    q = projectB.query("INSERT INTO src_associations (suite, source) VALUES (%s, %s)" % (suite_id, id))
+                    q = projectB.query("INSERT INTO src_associations (suite, source) VALUES (%s, %s)" % (suite_id, pkid))
             elif action == "remove":
                 if assoication_id == None:
-                    daklib.utils.warn("'%s_%s_%s' doesn't exist in suite %s." % (package, version, architecture, suite))
+                    utils.warn("'%s_%s_%s' doesn't exist in suite %s." % (package, version, architecture, suite))
                     continue
                 else:
                     q = projectB.query("DELETE FROM src_associations WHERE id = %s" % (assoication_id))
         else:
             # Find the existing assoications ID, if any
-            q = projectB.query("SELECT id FROM bin_associations WHERE suite = %s and bin = %s" % (suite_id, id))
+            q = projectB.query("SELECT id FROM bin_associations WHERE suite = %s and bin = %s" % (suite_id, pkid))
             ql = q.getresult()
             if not ql:
                 assoication_id = None
@@ -199,13 +198,13 @@ def process_file (file, suite, action):
             # Take action
             if action == "add":
                 if assoication_id:
-                    daklib.utils.warn("'%s_%s_%s' already exists in suite %s." % (package, version, architecture, suite))
+                    utils.warn("'%s_%s_%s' already exists in suite %s." % (package, version, architecture, suite))
                     continue
                 else:
-                    q = projectB.query("INSERT INTO bin_associations (suite, bin) VALUES (%s, %s)" % (suite_id, id))
+                    q = projectB.query("INSERT INTO bin_associations (suite, bin) VALUES (%s, %s)" % (suite_id, pkid))
             elif action == "remove":
                 if assoication_id == None:
-                    daklib.utils.warn("'%s_%s_%s' doesn't exist in suite %s." % (package, version, architecture, suite))
+                    utils.warn("'%s_%s_%s' doesn't exist in suite %s." % (package, version, architecture, suite))
                     continue
                 else:
                     q = projectB.query("DELETE FROM bin_associations WHERE id = %s" % (assoication_id))
@@ -215,7 +214,7 @@ def process_file (file, suite, action):
 #######################################################################################
 
 def get_list (suite):
-    suite_id = daklib.database.get_suite_id(suite)
+    suite_id = database.get_suite_id(suite)
     # List binaries
     q = projectB.query("SELECT b.package, b.version, a.arch_string FROM binaries b, bin_associations ba, architecture a WHERE ba.suite = %s AND ba.bin = b.id AND b.architecture = a.id" % (suite_id))
     ql = q.getresult()
@@ -233,7 +232,7 @@ def get_list (suite):
 def main ():
     global Cnf, projectB, Logger
 
-    Cnf = daklib.utils.get_conf()
+    Cnf = utils.get_conf()
 
     Arguments = [('a',"add","Control-Suite::Options::Add", "HasArg"),
                  ('h',"help","Control-Suite::Options::Help"),
@@ -253,35 +252,35 @@ def main ():
 
     projectB = pg.connect(Cnf["DB::Name"], Cnf["DB::Host"],int(Cnf["DB::Port"]))
 
-    daklib.database.init(Cnf, projectB)
+    database.init(Cnf, projectB)
 
     action = None
 
     for i in ("add", "list", "remove", "set"):
         if Cnf["Control-Suite::Options::%s" % (i)] != "":
             suite = Cnf["Control-Suite::Options::%s" % (i)]
-            if daklib.database.get_suite_id(suite) == -1:
-                daklib.utils.fubar("Unknown suite '%s'." %(suite))
+            if database.get_suite_id(suite) == -1:
+                utils.fubar("Unknown suite '%s'." %(suite))
             else:
                 if action:
-                    daklib.utils.fubar("Can only perform one action at a time.")
+                    utils.fubar("Can only perform one action at a time.")
                 action = i
 
     # Need an action...
     if action == None:
-        daklib.utils.fubar("No action specified.")
+        utils.fubar("No action specified.")
 
     # Safety/Sanity check
     if action == "set" and suite not in ["testing", "etch-m68k"]:
-        daklib.utils.fubar("Will not reset a suite other than testing.")
+        utils.fubar("Will not reset a suite other than testing.")
 
     if action == "list":
         get_list(suite)
     else:
-        Logger = daklib.logging.Logger(Cnf, "control-suite")
+        Logger = logging.Logger(Cnf, "control-suite")
         if file_list:
-            for file in file_list:
-                process_file(daklib.utils.open_file(file), suite, action)
+            for f in file_list:
+                process_file(utils.open_file(f), suite, action)
         else:
             process_file(sys.stdin, suite, action)
         Logger.close()
old mode 100644 (file)
new mode 100755 (executable)
index 02a38e0..238cdd4
@@ -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):
old mode 100644 (file)
new mode 100755 (executable)
index b6cee445c449d4d9bb48889edb7fed50dfaef165..d4373641a0d11e853f1c64bde4a62b8b0df04827 100644 (file)
@@ -28,8 +28,8 @@
 
 import sys
 import apt_pkg
-import daklib.queue
-import daklib.utils
+import daklib.queue as queue
+import daklib.utils as utils
 
 ################################################################################
 
@@ -43,7 +43,7 @@ Dumps the info in .dak FILE(s).
 ################################################################################
 
 def main():
-    Cnf = daklib.utils.get_conf()
+    Cnf = utils.get_conf()
     Arguments = [('h',"help","Decode-Dot-Dak::Options::Help")]
     for i in [ "help" ]:
         if not Cnf.has_key("Decode-Dot-Dak::Options::%s" % (i)):
@@ -55,9 +55,9 @@ def main():
     if Options["Help"]:
         usage()
 
-    k = daklib.queue.Upload(Cnf)
+    k = queue.Upload(Cnf)
     for arg in sys.argv[1:]:
-        arg = daklib.utils.validate_changes_file_arg(arg,require_changes=-1)
+        arg = utils.validate_changes_file_arg(arg,require_changes=-1)
         k.pkg.changes_file = arg
         print "%s:" % (arg)
         k.init_vars()
@@ -83,7 +83,7 @@ def main():
                 del changes[i]
         print
         if changes:
-            daklib.utils.warn("changes still has following unrecognised keys: %s" % (changes.keys()))
+            utils.warn("changes still has following unrecognised keys: %s" % (changes.keys()))
 
         dsc = k.pkg.dsc
         print " Dsc:"
@@ -94,38 +94,38 @@ def main():
                 del dsc[i]
         print
         if dsc:
-            daklib.utils.warn("dsc still has following unrecognised keys: %s" % (dsc.keys()))
+            utils.warn("dsc still has following unrecognised keys: %s" % (dsc.keys()))
 
         files = k.pkg.files
         print " Files:"
-        for file in files.keys():
-            print "  %s:" % (file)
+        for f in files.keys():
+            print "  %s:" % (f)
             for i in [ "package", "version", "architecture", "type", "size",
                        "md5sum", "component", "location id", "source package",
                        "source version", "maintainer", "dbtype", "files id",
                        "new", "section", "priority", "pool name" ]:
-                if files[file].has_key(i):
-                    print "   %s: %s" % (i.capitalize(), files[file][i])
-                    del files[file][i]
-            if files[file]:
-                daklib.utils.warn("files[%s] still has following unrecognised keys: %s" % (file, files[file].keys()))
+                if files[f].has_key(i):
+                    print "   %s: %s" % (i.capitalize(), files[f][i])
+                    del files[f][i]
+            if files[f]:
+                utils.warn("files[%s] still has following unrecognised keys: %s" % (f, files[f].keys()))
         print
 
         dsc_files = k.pkg.dsc_files
         print " Dsc Files:"
-        for file in dsc_files.keys():
-            print "  %s:" % (file)
+        for f in dsc_files.keys():
+            print "  %s:" % (f)
             # Mandatory fields
             for i in [ "size", "md5sum" ]:
-                print "   %s: %s" % (i.capitalize(), dsc_files[file][i])
-                del dsc_files[file][i]
+                print "   %s: %s" % (i.capitalize(), dsc_files[f][i])
+                del dsc_files[f][i]
             # Optional fields
             for i in [ "files id" ]:
-                if dsc_files[file].has_key(i):
-                    print "   %s: %s" % (i.capitalize(), dsc_files[file][i])
-                    del dsc_files[file][i]
-            if dsc_files[file]:
-                daklib.utils.warn("dsc_files[%s] still has following unrecognised keys: %s" % (file, dsc_files[file].keys()))
+                if dsc_files[f].has_key(i):
+                    print "   %s: %s" % (i.capitalize(), dsc_files[f][i])
+                    del dsc_files[f][i]
+            if dsc_files[f]:
+                utils.warn("dsc_files[%s] still has following unrecognised keys: %s" % (f, dsc_files[f].keys()))
 
 ################################################################################
 
old mode 100644 (file)
new mode 100755 (executable)
index b9ac9af..81191d2
@@ -34,7 +34,8 @@
 
 import errno, os, pg, re, sys, md5
 import apt_pkg, apt_inst
-import daklib.database, daklib.utils, daklib.queue
+import daklib.database as database
+import daklib.utils as utils
 
 ################################################################################
 
@@ -62,9 +63,9 @@ re_html_escaping = re.compile('|'.join(map(re.escape, html_escaping.keys())))
 Cnf = None
 projectB = None
 
-Cnf = daklib.utils.get_conf()
+Cnf = utils.get_conf()
 projectB = pg.connect(Cnf["DB::Name"], Cnf["DB::Host"], int(Cnf["DB::Port"]))
-daklib.database.init(Cnf, projectB)
+database.init(Cnf, projectB)
 
 printed_copyrights = {}
 
@@ -225,7 +226,7 @@ def read_control (filename):
     maintainer = ''
     arch = ''
 
-    deb_file = daklib.utils.open_file(filename)
+    deb_file = utils.open_file(filename)
     try:
         extracts = apt_inst.debExtractControl(deb_file)
         control = apt_pkg.ParseSection(extracts)
@@ -279,9 +280,9 @@ def read_control (filename):
 def read_changes_or_dsc (filename):
     dsc = {}
 
-    dsc_file = daklib.utils.open_file(filename)
+    dsc_file = utils.open_file(filename)
     try:
-        dsc = daklib.utils.parse_changes(filename)
+        dsc = utils.parse_changes(filename)
     except:
         return formatted_text("can't parse .dsc control info")
     dsc_file.close()
@@ -395,18 +396,18 @@ def do_lintian (filename):
 def get_copyright (deb_filename):
     package = re_package.sub(r'\1', deb_filename)
     o = os.popen("dpkg-deb -c %s | egrep 'usr(/share)?/doc/[^/]*/copyright' | awk '{print $6}' | head -n 1" % (deb_filename))
-    copyright = o.read()[:-1]
+    cright = o.read()[:-1]
 
-    if copyright == "":
+    if cright == "":
         return formatted_text("WARNING: No copyright found, please check package manually.")
 
-    doc_directory = re_doc_directory.sub(r'\1', copyright)
+    doc_directory = re_doc_directory.sub(r'\1', cright)
     if package != doc_directory:
         return formatted_text("WARNING: wrong doc directory (expected %s, got %s)." % (package, doc_directory))
 
-    o = os.popen("dpkg-deb --fsys-tarfile %s | tar xvOf - %s 2>/dev/null" % (deb_filename, copyright))
-    copyright = o.read()
-    copyrightmd5 = md5.md5(copyright).hexdigest()
+    o = os.popen("dpkg-deb --fsys-tarfile %s | tar xvOf - %s 2>/dev/null" % (deb_filename, cright))
+    cright = o.read()
+    copyrightmd5 = md5.md5(cright).hexdigest()
 
     res = ""
     if printed_copyrights.has_key(copyrightmd5) and printed_copyrights[copyrightmd5] != "%s (%s)" % (package, deb_filename):
@@ -414,7 +415,7 @@ def get_copyright (deb_filename):
                                (printed_copyrights[copyrightmd5]))
     else:
         printed_copyrights[copyrightmd5] = "%s (%s)" % (package, deb_filename)
-    return res+formatted_text(copyright)
+    return res+formatted_text(cright)
 
 def check_dsc (dsc_filename):
     (dsc) = read_changes_or_dsc(dsc_filename)
@@ -457,7 +458,7 @@ def check_deb (deb_filename):
 # Read a file, strip the signature and return the modified contents as
 # a string.
 def strip_pgp_signature (filename):
-    file = daklib.utils.open_file (filename)
+    file = utils.open_file (filename)
     contents = ""
     inside_signature = 0
     skip_next = 0
@@ -489,19 +490,19 @@ def display_changes(changes_filename):
 def check_changes (changes_filename):
     display_changes(changes_filename)
 
-    changes = daklib.utils.parse_changes (changes_filename)
-    files = daklib.utils.build_file_list(changes)
-    for file in files.keys():
-        if file.endswith(".deb") or file.endswith(".udeb"):
-            check_deb(file)
-        if file.endswith(".dsc"):
-            check_dsc(file)
+    changes = utils.parse_changes (changes_filename)
+    files = utils.build_file_list(changes)
+    for f in files.keys():
+        if f.endswith(".deb") or f.endswith(".udeb"):
+            check_deb(f)
+        if f.endswith(".dsc"):
+            check_dsc(f)
         # else: => byhand
 
 def main ():
     global Cnf, projectB, db_files, waste, excluded
 
-#    Cnf = daklib.utils.get_conf()
+#    Cnf = utils.get_conf()
 
     Arguments = [('h',"help","Examine-Package::Options::Help"),
                  ('H',"html-output","Examine-Package::Options::Html-Output"),
@@ -518,7 +519,7 @@ def main ():
 
     stdout_fd = sys.stdout
 
-    for file in args:
+    for f in args:
         try:
             if not Options["Html-Output"]:
                 # Pipe output for each argument through less
@@ -526,14 +527,14 @@ def main ():
                 # -R added to display raw control chars for colour
                 sys.stdout = less_fd
             try:
-                if file.endswith(".changes"):
-                    check_changes(file)
-                elif file.endswith(".deb") or file.endswith(".udeb"):
+                if f.endswith(".changes"):
+                    check_changes(f)
+                elif f.endswith(".deb") or f.endswith(".udeb"):
                     check_deb(file)
-                elif file.endswith(".dsc"):
-                    check_dsc(file)
+                elif f.endswith(".dsc"):
+                    check_dsc(f)
                 else:
-                    daklib.utils.fubar("Unrecognised file type: '%s'." % (file))
+                    utils.fubar("Unrecognised file type: '%s'." % (f))
             finally:
                 if not Options["Html-Output"]:
                     # Reset stdout here so future less invocations aren't FUBAR
@@ -541,12 +542,12 @@ def main ():
                     sys.stdout = stdout_fd
         except IOError, e:
             if errno.errorcode[e.errno] == 'EPIPE':
-                daklib.utils.warn("[examine-package] Caught EPIPE; skipping.")
+                utils.warn("[examine-package] Caught EPIPE; skipping.")
                 pass
             else:
                 raise
         except KeyboardInterrupt:
-            daklib.utils.warn("[examine-package] Caught C-c; skipping.")
+            utils.warn("[examine-package] Caught C-c; skipping.")
             pass
 
 #######################################################################################
old mode 100644 (file)
new mode 100755 (executable)
index 727ed31..c4e457f
@@ -21,7 +21,7 @@
 
 import ldap, pg, sys, time
 import apt_pkg
-import daklib.utils
+import daklib.utils as utils
 
 ################################################################################
 
@@ -50,7 +50,7 @@ def get_ldap_value(entry, value):
 def main():
     global Cnf, projectB
 
-    Cnf = daklib.utils.get_conf()
+    Cnf = utils.get_conf()
     Arguments = [('h',"help","Find-Null-Maintainers::Options::Help")]
     for i in [ "help" ]:
         if not Cnf.has_key("Find-Null-Maintainers::Options::%s" % (i)):
old mode 100644 (file)
new mode 100755 (executable)
index 03d5165..7cbedb9
@@ -32,7 +32,7 @@
 
 import sys, os, tempfile
 import apt_pkg
-import daklib.utils
+import daklib.utils as utils
 
 ################################################################################
 
@@ -286,7 +286,7 @@ def main():
 
     os.umask(0002)
 
-    Cnf = daklib.utils.get_conf()
+    Cnf = utils.get_conf()
     Arguments = [ ('h', "help", "Generate-Index-Diffs::Options::Help"),
                   ('c', None, "Generate-Index-Diffs::Options::CanonicalPath", "hasArg"),
                   ('p', "patchname", "Generate-Index-Diffs::Options::PatchName", "hasArg"),
@@ -312,7 +312,7 @@ def main():
         o.close()
 
     AptCnf = apt_pkg.newConfiguration()
-    apt_pkg.ReadConfigFileISC(AptCnf,daklib.utils.which_apt_conf_file())
+    apt_pkg.ReadConfigFileISC(AptCnf,utils.which_apt_conf_file())
 
     if Options.has_key("RootDir"): Cnf["Dir::Root"] = Options["RootDir"]
 
@@ -349,7 +349,7 @@ def main():
         elif AptCnf.has_key("bindirectory::%s" % (tree)):
             sections = AptCnf["bindirectory::%s::Sections" % (tree)].split()
         else:
-            aptcnf_filename = os.path.basename(daklib.utils.which_apt_conf_file())
+            aptcnf_filename = os.path.basename(utils.which_apt_conf_file())
             print "ALERT: suite %s not in %s, nor untouchable!" % (suite, aptcnf_filename)
             continue
 
old mode 100644 (file)
new mode 100755 (executable)
index 867fbc8..cb82a94
@@ -24,7 +24,7 @@
 
 import sys, os, popen2, tempfile, stat, time, pg
 import apt_pkg
-import daklib.utils
+import daklib.utils as utils
 
 ################################################################################
 
@@ -106,8 +106,8 @@ def print_md5sha_files (tree, files, hashop):
                     (cat, path, name, ext))
             else:
                 size = os.stat(path + name)[stat.ST_SIZE]
-                file_handle = daklib.utils.open_file(path + name)
-        except daklib.utils.cant_open_exc:
+                file_handle = utils.open_file(path + name)
+        except utils.cant_open_exc:
             print "ALERT: Couldn't open " + path + name
         else:
             hash = hashop(file_handle)
@@ -129,7 +129,7 @@ def main ():
     global Cnf, AptCnf, projectB, out
     out = sys.stdout
 
-    Cnf = daklib.utils.get_conf()
+    Cnf = utils.get_conf()
 
     Arguments = [('h',"help","Generate-Releases::Options::Help"),
                  ('a',"apt-conf","Generate-Releases::Options::Apt-Conf", "HasArg"),
@@ -146,7 +146,7 @@ def main ():
         usage()
 
     if not Options["Apt-Conf"]:
-        Options["Apt-Conf"] = daklib.utils.which_apt_conf_file()
+        Options["Apt-Conf"] = utils.which_apt_conf_file()
 
     AptCnf = apt_pkg.newConfiguration()
     apt_pkg.ReadConfigFileISC(AptCnf, Options["Apt-Conf"])
@@ -202,7 +202,7 @@ def main ():
         elif AptCnf.has_key("bindirectory::%s" % (tree)):
             pass
         else:
-            aptcnf_filename = os.path.basename(daklib.utils.which_apt_conf_file())
+            aptcnf_filename = os.path.basename(utils.which_apt_conf_file())
             print "ALERT: suite %s not in %s, nor untouchable!" % (suite, aptcnf_filename)
             continue
 
@@ -219,7 +219,7 @@ def main ():
         out.write("Date: %s\n" % (time.strftime("%a, %d %b %Y %H:%M:%S UTC", time.gmtime(time.time()))))
         if notautomatic != "":
             out.write("NotAutomatic: %s\n" % (notautomatic))
-        out.write("Architectures: %s\n" % (" ".join(filter(daklib.utils.real_arch, SuiteBlock.ValueList("Architectures")))))
+        out.write("Architectures: %s\n" % (" ".join(filter(utils.real_arch, SuiteBlock.ValueList("Architectures")))))
         if components:
             out.write("Components: %s\n" % (" ".join(components)))
 
@@ -262,7 +262,7 @@ def main ():
                         release = open(relpath, "w")
                         #release = open(longsuite.replace("/","_") + "_" + arch + "_" + sec + "_Release", "w")
                     except IOError:
-                        daklib.utils.fubar("Couldn't write to " + relpath)
+                        utils.fubar("Couldn't write to " + relpath)
 
                     release.write("Archive: %s\n" % (suite))
                     if version != "":
old mode 100644 (file)
new mode 100755 (executable)
index 82def1e..b8884ab
@@ -38,8 +38,8 @@
 
 import commands, os, pg, re, sys, time
 import apt_pkg
-import daklib.database
-import daklib.utils
+import daklib.database as database
+import daklib.utils as utils
 
 ###############################################################################
 
@@ -93,14 +93,14 @@ def reject (str, prefix="Rejected: "):
 ###############################################################################
 
 def check_signature (filename):
-    if not daklib.utils.re_taint_free.match(os.path.basename(filename)):
+    if not utils.re_taint_free.match(os.path.basename(filename)):
         reject("!!WARNING!! tainted filename: '%s'." % (filename))
         return None
 
     status_read, status_write = os.pipe()
     cmd = "gpgv --status-fd %s %s %s" \
-          % (status_write, daklib.utils.gpg_keyring_args(), filename)
-    (output, status, exit_status) = daklib.utils.gpgv_get_status_output(cmd, status_read, status_write)
+          % (status_write, utils.gpg_keyring_args(), filename)
+    (output, status, exit_status) = utils.gpgv_get_status_output(cmd, status_read, status_write)
 
     # Process the status-fd output
     keywords = {}
@@ -133,7 +133,7 @@ def check_signature (filename):
 
     # Now check for obviously bad things in the processed output
     if keywords.has_key("SIGEXPIRED"):
-        daklib.utils.warn("%s: signing key has expired." % (filename))
+        utils.warn("%s: signing key has expired." % (filename))
     if keywords.has_key("KEYREVOKED"):
         reject("key used to sign %s has been revoked." % (filename))
         bad = 1
@@ -154,7 +154,7 @@ def check_signature (filename):
         reject("ascii armour of signature was corrupt in %s." % (filename))
         bad = 1
     if keywords.has_key("NODATA"):
-        daklib.utils.warn("no signature found for %s." % (filename))
+        utils.warn("no signature found for %s." % (filename))
         return "NOSIG"
         #reject("no signature found in %s." % (filename))
         #bad = 1
@@ -166,9 +166,9 @@ def check_signature (filename):
     if exit_status and not keywords.has_key("NO_PUBKEY"):
         reject("gpgv failed while checking %s." % (filename))
         if status.strip():
-            reject(daklib.utils.prefix_multi_line_string(status, " [GPG status-fd output:] "), "")
+            reject(utils.prefix_multi_line_string(status, " [GPG status-fd output:] "), "")
         else:
-            reject(daklib.utils.prefix_multi_line_string(output, " [GPG output:] "), "")
+            reject(utils.prefix_multi_line_string(output, " [GPG output:] "), "")
         return None
 
     # Sanity check the good stuff we expect
@@ -191,7 +191,7 @@ def check_signature (filename):
         bad = 1
 
     # Finally ensure there's not something we don't recognise
-    known_keywords = daklib.utils.Dict(VALIDSIG="",SIG_ID="",GOODSIG="",BADSIG="",ERRSIG="",
+    known_keywords = utils.Dict(VALIDSIG="",SIG_ID="",GOODSIG="",BADSIG="",ERRSIG="",
                                 SIGEXPIRED="",KEYREVOKED="",NO_PUBKEY="",BADARMOR="",
                                 NODATA="")
 
@@ -232,13 +232,13 @@ def update_locations ():
     projectB.query("DELETE FROM location")
     for location in Cnf.SubTree("Location").List():
         SubSec = Cnf.SubTree("Location::%s" % (location))
-        archive_id = daklib.database.get_archive_id(SubSec["archive"])
+        archive_id = database.get_archive_id(SubSec["archive"])
         type = SubSec.Find("type")
         if type == "legacy-mixed":
             projectB.query("INSERT INTO location (path, archive, type) VALUES ('%s', %d, '%s')" % (location, archive_id, SubSec["type"]))
         else:
             for component in Cnf.SubTree("Component").List():
-                component_id = daklib.database.get_component_id(component)
+                component_id = database.get_component_id(component)
                 projectB.query("INSERT INTO location (path, component, archive, type) VALUES ('%s', %d, %d, '%s')" %
                                (location, component_id, archive_id, SubSec["type"]))
 
@@ -256,7 +256,7 @@ def update_suites ():
             if SubSec.has_key(i):
                 projectB.query("UPDATE suite SET %s = '%s' WHERE suite_name = '%s'" % (i.lower(), SubSec[i], suite.lower()))
         for architecture in Cnf.ValueList("Suite::%s::Architectures" % (suite)):
-            architecture_id = daklib.database.get_architecture_id (architecture)
+            architecture_id = database.get_architecture_id (architecture)
             projectB.query("INSERT INTO suite_architectures (suite, architecture) VALUES (currval('suite_id_seq'), %d)" % (architecture_id))
 
 def update_override_type():
@@ -297,7 +297,7 @@ def get_location_path(directory):
     try:
         path = q.getresult()[0][0]
     except:
-        daklib.utils.fubar("[import-archive] get_location_path(): Couldn't get path for %s" % (directory))
+        utils.fubar("[import-archive] get_location_path(): Couldn't get path for %s" % (directory))
     location_path_cache[directory] = path
     return path
 
@@ -320,41 +320,41 @@ def process_sources (filename, suite, component, archive):
     global source_cache, source_query_cache, src_associations_query_cache, dsc_files_query_cache, source_id_serial, src_associations_id_serial, dsc_files_id_serial, source_cache_for_binaries, orig_tar_gz_cache, reject_message
 
     suite = suite.lower()
-    suite_id = daklib.database.get_suite_id(suite)
+    suite_id = database.get_suite_id(suite)
     try:
-        file = daklib.utils.open_file (filename)
-    except daklib.utils.cant_open_exc:
-        daklib.utils.warn("can't open '%s'" % (filename))
+        file = utils.open_file (filename)
+    except utils.cant_open_exc:
+        utils.warn("can't open '%s'" % (filename))
         return
     Scanner = apt_pkg.ParseTagFile(file)
     while Scanner.Step() != 0:
         package = Scanner.Section["package"]
         version = Scanner.Section["version"]
         directory = Scanner.Section["directory"]
-        dsc_file = os.path.join(Cnf["Dir::Root"], directory, "%s_%s.dsc" % (package, daklib.utils.re_no_epoch.sub('', version)))
+        dsc_file = os.path.join(Cnf["Dir::Root"], directory, "%s_%s.dsc" % (package, utils.re_no_epoch.sub('', version)))
         # Sometimes the Directory path is a lie; check in the pool
         if not os.path.exists(dsc_file):
             if directory.split('/')[0] == "dists":
-                directory = Cnf["Dir::PoolRoot"] + daklib.utils.poolify(package, component)
-                dsc_file = os.path.join(Cnf["Dir::Root"], directory, "%s_%s.dsc" % (package, daklib.utils.re_no_epoch.sub('', version)))
+                directory = Cnf["Dir::PoolRoot"] + utils.poolify(package, component)
+                dsc_file = os.path.join(Cnf["Dir::Root"], directory, "%s_%s.dsc" % (package, utils.re_no_epoch.sub('', version)))
         if not os.path.exists(dsc_file):
-            daklib.utils.fubar("%s not found." % (dsc_file))
+            utils.fubar("%s not found." % (dsc_file))
         install_date = time.strftime("%Y-%m-%d", time.localtime(os.path.getmtime(dsc_file)))
         fingerprint = check_signature(dsc_file)
-        fingerprint_id = daklib.database.get_or_set_fingerprint_id(fingerprint)
+        fingerprint_id = database.get_or_set_fingerprint_id(fingerprint)
         if reject_message:
-            daklib.utils.fubar("%s: %s" % (dsc_file, reject_message))
+            utils.fubar("%s: %s" % (dsc_file, reject_message))
         maintainer = Scanner.Section["maintainer"]
         maintainer = maintainer.replace("'", "\\'")
-        maintainer_id = daklib.database.get_or_set_maintainer_id(maintainer)
+        maintainer_id = database.get_or_set_maintainer_id(maintainer)
         location = get_location_path(directory.split('/')[0])
-        location_id = daklib.database.get_location_id (location, component, archive)
+        location_id = database.get_location_id (location, component, archive)
         if not directory.endswith("/"):
             directory += '/'
         directory = poolify (directory, location)
         if directory != "" and not directory.endswith("/"):
             directory += '/'
-        no_epoch_version = daklib.utils.re_no_epoch.sub('', version)
+        no_epoch_version = utils.re_no_epoch.sub('', version)
         # Add all files referenced by the .dsc to the files table
         ids = []
         for line in Scanner.Section["files"].split('\n'):
@@ -403,11 +403,11 @@ def process_packages (filename, suite, component, archive):
     count_total = 0
     count_bad = 0
     suite = suite.lower()
-    suite_id = daklib.database.get_suite_id(suite)
+    suite_id = database.get_suite_id(suite)
     try:
-        file = daklib.utils.open_file (filename)
-    except daklib.utils.cant_open_exc:
-        daklib.utils.warn("can't open '%s'" % (filename))
+        file = utils.open_file (filename)
+    except utils.cant_open_exc:
+        utils.warn("can't open '%s'" % (filename))
         return
     Scanner = apt_pkg.ParseTagFile(file)
     while Scanner.Step() != 0:
@@ -415,25 +415,25 @@ def process_packages (filename, suite, component, archive):
         version = Scanner.Section["version"]
         maintainer = Scanner.Section["maintainer"]
         maintainer = maintainer.replace("'", "\\'")
-        maintainer_id = daklib.database.get_or_set_maintainer_id(maintainer)
+        maintainer_id = database.get_or_set_maintainer_id(maintainer)
         architecture = Scanner.Section["architecture"]
-        architecture_id = daklib.database.get_architecture_id (architecture)
+        architecture_id = database.get_architecture_id (architecture)
         fingerprint = "NOSIG"
-        fingerprint_id = daklib.database.get_or_set_fingerprint_id(fingerprint)
+        fingerprint_id = database.get_or_set_fingerprint_id(fingerprint)
         if not Scanner.Section.has_key("source"):
             source = package
         else:
             source = Scanner.Section["source"]
         source_version = ""
         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)
             source_version = m.group(2)
         if not source_version:
             source_version = version
         filename = Scanner.Section["filename"]
         location = get_location_path(filename.split('/')[0])
-        location_id = daklib.database.get_location_id (location, component, archive)
+        location_id = database.get_location_id (location, component, archive)
         filename = poolify (filename, location)
         if architecture == "all":
             filename = re_arch_from_filename.sub("binary-all", filename)
@@ -473,10 +473,10 @@ def process_packages (filename, suite, component, archive):
 ###############################################################################
 
 def do_sources(sources, suite, component, server):
-    temp_filename = daklib.utils.temp_filename()
+    temp_filename = utils.temp_filename()
     (result, output) = commands.getstatusoutput("gunzip -c %s > %s" % (sources, temp_filename))
     if (result != 0):
-        daklib.utils.fubar("Gunzip invocation failed!\n%s" % (output), result)
+        utils.fubar("Gunzip invocation failed!\n%s" % (output), result)
     print 'Processing '+sources+'...'
     process_sources (temp_filename, suite, component, server)
     os.unlink(temp_filename)
@@ -486,7 +486,7 @@ def do_sources(sources, suite, component, server):
 def do_da_do_da ():
     global Cnf, projectB, query_cache, files_query_cache, source_query_cache, src_associations_query_cache, dsc_files_query_cache, bin_associations_query_cache, binaries_query_cache
 
-    Cnf = daklib.utils.get_conf()
+    Cnf = utils.get_conf()
     Arguments = [('a', "action", "Import-Archive::Options::Action"),
                  ('h', "help", "Import-Archive::Options::Help")]
     for i in [ "action", "help" ]:
@@ -500,7 +500,7 @@ def do_da_do_da ():
         usage()
 
     if not Options["Action"]:
-        daklib.utils.warn("""no -a/--action given; not doing anything.
+        utils.warn("""no -a/--action given; not doing anything.
 Please read the documentation before running this script.
 """)
         usage(1)
@@ -508,12 +508,12 @@ Please read the documentation before running this script.
     print "Re-Creating DB..."
     (result, output) = commands.getstatusoutput("psql -f init_pool.sql template1")
     if (result != 0):
-        daklib.utils.fubar("psql invocation failed!\n", result)
+        utils.fubar("psql invocation failed!\n", result)
     print output
 
     projectB = pg.connect(Cnf["DB::Name"], Cnf["DB::Host"], int(Cnf["DB::Port"]))
 
-    daklib.database.init (Cnf, projectB)
+    database.init (Cnf, projectB)
 
     print "Adding static tables from conf file..."
     projectB.query("BEGIN WORK")
@@ -527,12 +527,12 @@ Please read the documentation before running this script.
     update_section()
     projectB.query("COMMIT WORK")
 
-    files_query_cache = daklib.utils.open_file(Cnf["Import-Archive::ExportDir"]+"files","w")
-    source_query_cache = daklib.utils.open_file(Cnf["Import-Archive::ExportDir"]+"source","w")
-    src_associations_query_cache = daklib.utils.open_file(Cnf["Import-Archive::ExportDir"]+"src_associations","w")
-    dsc_files_query_cache = daklib.utils.open_file(Cnf["Import-Archive::ExportDir"]+"dsc_files","w")
-    binaries_query_cache = daklib.utils.open_file(Cnf["Import-Archive::ExportDir"]+"binaries","w")
-    bin_associations_query_cache = daklib.utils.open_file(Cnf["Import-Archive::ExportDir"]+"bin_associations","w")
+    files_query_cache = utils.open_file(Cnf["Import-Archive::ExportDir"]+"files","w")
+    source_query_cache = utils.open_file(Cnf["Import-Archive::ExportDir"]+"source","w")
+    src_associations_query_cache = utils.open_file(Cnf["Import-Archive::ExportDir"]+"src_associations","w")
+    dsc_files_query_cache = utils.open_file(Cnf["Import-Archive::ExportDir"]+"dsc_files","w")
+    binaries_query_cache = utils.open_file(Cnf["Import-Archive::ExportDir"]+"binaries","w")
+    bin_associations_query_cache = utils.open_file(Cnf["Import-Archive::ExportDir"]+"bin_associations","w")
 
     projectB.query("BEGIN WORK")
     # Process Sources files to popoulate `source' and friends
@@ -550,7 +550,7 @@ Please read the documentation before running this script.
                     sources = Cnf["Dir::Root"] + "dists/" + Cnf["Suite::%s::CodeName" % (suite)] + '/' + component + '/source/' + 'Sources.gz'
                     do_sources(sources, suite, component, server)
         else:
-            daklib.utils.fubar("Unknown location type ('%s')." % (type))
+            utils.fubar("Unknown location type ('%s')." % (type))
 
     # Process Packages files to populate `binaries' and friends
 
@@ -566,7 +566,7 @@ Please read the documentation before running this script.
         elif type == "legacy" or type == "pool":
             for suite in Cnf.ValueList("Location::%s::Suites" % (location)):
                 for component in Cnf.SubTree("Component").List():
-                    architectures = filter(daklib.utils.real_arch,
+                    architectures = filter(utils.real_arch,
                                            Cnf.ValueList("Suite::%s::Architectures" % (suite)))
                     for architecture in architectures:
                         packages = Cnf["Dir::Root"] + "dists/" + Cnf["Suite::%s::CodeName" % (suite)] + '/' + component + '/binary-' + architecture + '/Packages'
@@ -601,14 +601,14 @@ Please read the documentation before running this script.
     (result, output) = commands.getstatusoutput("psql %s < add_constraints.sql" % (Cnf["DB::Name"]))
     print output
     if (result != 0):
-        daklib.utils.fubar("psql invocation failed!\n%s" % (output), result)
+        utils.fubar("psql invocation failed!\n%s" % (output), result)
 
     return
 
 ################################################################################
 
 def main():
-    daklib.utils.try_with_debug(do_da_do_da)
+    utils.try_with_debug(do_da_do_da)
 
 ################################################################################
 
old mode 100644 (file)
new mode 100755 (executable)
index 63c0724..6d91b46
@@ -19,7 +19,8 @@
 
 ################################################################################
 
-import daklib.database, daklib.logging
+import daklib.database as database
+import daklib.utils as utils
 import sys, os, re
 import apt_pkg, pg, ldap, email.Utils
 
@@ -27,7 +28,6 @@ import apt_pkg, pg, ldap, email.Utils
 Cnf = None
 Options = None
 projectB = None
-Logger = None
 
 ################################################################################
 
@@ -138,7 +138,7 @@ class Keyring:
                 keys[key]["uid"] = uid
 
                 if id != None: continue
-                id = daklib.database.get_or_set_uid_id(uid)
+                id = database.get_or_set_uid_id(uid)
                 byuid[id] = (uid, name)
                 byname[uid] = (id, name)
 
@@ -155,13 +155,13 @@ class Keyring:
                 keys[x]["uid"] = format % "invalid-uid"
             else:
                 uid = format % keys[x]["email"]
-                id = daklib.database.get_or_set_uid_id(uid)
+                id = database.get_or_set_uid_id(uid)
                 byuid[id] = (uid, keys[x]["name"])
                 byname[uid] = (id, keys[x]["name"])
                 keys[x]["uid"] = uid
         if any_invalid:
             uid = format % "invalid-uid"
-            id = daklib.database.get_or_set_uid_id(uid)
+            id = database.get_or_set_uid_id(uid)
             byuid[id] = (uid, "ungeneratable user id")
             byname[uid] = (id, "ungeneratable user id")
         return (byname, byuid)
@@ -181,7 +181,7 @@ def usage (exit_code=0):
 def main():
     global Cnf, projectB, Options
 
-    Cnf = daklib.utils.get_conf()
+    Cnf = utils.get_conf()
     Arguments = [('h',"help","Import-Keyring::Options::Help"),
                  ('L',"import-ldap-users","Import-Keyring::Options::Import-Ldap-Users"),
                  ('U',"generate-users","Import-Keyring::Options::Generate-Users", "HasArg"),
@@ -209,7 +209,7 @@ def main():
     ### Initialise
 
     projectB = pg.connect(Cnf["DB::Name"], Cnf["DB::Host"], int(Cnf["DB::Port"]))
-    daklib.database.init(Cnf, projectB)
+    database.init(Cnf, projectB)
 
     projectB.query("BEGIN WORK")
 
@@ -222,7 +222,7 @@ def main():
     keyringname = keyring_names[0]
     keyring = Keyring(keyringname)
 
-    keyring_id = daklib.database.get_or_set_keyring_id(
+    keyring_id = database.get_or_set_keyring_id(
                         keyringname.split("/")[-1])
 
     ### Generate new uid entries if they're needed (from LDAP or the keyring)
old mode 100644 (file)
new mode 100755 (executable)
index f204a9f..85cd7a2
@@ -46,8 +46,8 @@
 
 import commands, ldap, pg, re, sys
 import apt_pkg
-import daklib.database
-import daklib.utils
+import daklib.database as database
+import daklib.utils as utils
 
 ################################################################################
 
@@ -88,7 +88,7 @@ def escape_string(str):
 def main():
     global Cnf, projectB
 
-    Cnf = daklib.utils.get_conf()
+    Cnf = utils.get_conf()
     Arguments = [('h',"help","Import-LDAP-Fingerprints::Options::Help")]
     for i in [ "help" ]:
         if not Cnf.has_key("Import-LDAP-Fingerprints::Options::%s" % (i)):
@@ -101,7 +101,7 @@ def main():
         usage()
 
     projectB = pg.connect(Cnf["DB::Name"], Cnf["DB::Host"], int(Cnf["DB::Port"]))
-    daklib.database.init(Cnf, projectB)
+    database.init(Cnf, projectB)
 
     LDAPDn = Cnf["Import-LDAP-Fingerprints::LDAPDn"]
     LDAPServer = Cnf["Import-LDAP-Fingerprints::LDAPServer"]
@@ -136,7 +136,7 @@ SELECT f.fingerprint, f.id, u.uid FROM fingerprint f, uid u WHERE f.uid = u.id
         fingerprints = entry["keyFingerPrint"]
         uid = entry["uid"][0]
         name = get_ldap_name(entry)
-        uid_id = daklib.database.get_or_set_uid_id(uid)
+        uid_id = database.get_or_set_uid_id(uid)
 
         if not db_uid_name.has_key(uid_id) or db_uid_name[uid_id] != name:
             q = projectB.query("UPDATE uid SET name = '%s' WHERE id = %d" % (escape_string(name), uid_id))
@@ -155,24 +155,24 @@ SELECT f.fingerprint, f.id, u.uid FROM fingerprint f, uid u WHERE f.uid = u.id
                     q = projectB.query("UPDATE fingerprint SET uid = %s WHERE id = %s" % (uid_id, fingerprint_id))
                     print "Promoting DM %s to DD %s with keyid 0x%s." % (existing_uid, uid, fingerprint)
                 else:
-                    daklib.utils.warn("%s has %s in LDAP, but projectB says it should be %s." % (uid, fingerprint, existing_uid))
+                    utils.warn("%s has %s in LDAP, but projectB says it should be %s." % (uid, fingerprint, existing_uid))
 
     # Try to update people who sign with non-primary key
     q = projectB.query("SELECT fingerprint, id FROM fingerprint WHERE uid is null")
     for i in q.getresult():
         (fingerprint, fingerprint_id) = i
         cmd = "gpg --no-default-keyring %s --fingerprint %s" \
-              % (daklib.utils.gpg_keyring_args(), fingerprint)
+              % (utils.gpg_keyring_args(), fingerprint)
         (result, output) = commands.getstatusoutput(cmd)
         if result == 0:
             m = re_gpg_fingerprint.search(output)
             if not m:
                 print output
-                daklib.utils.fubar("0x%s: No fingerprint found in gpg output but it returned 0?\n%s" % (fingerprint, daklib.utils.prefix_multi_line_string(output, " [GPG output:] ")))
+                utils.fubar("0x%s: No fingerprint found in gpg output but it returned 0?\n%s" % (fingerprint, utils.prefix_multi_line_string(output, " [GPG output:] ")))
             primary_key = m.group(1)
             primary_key = primary_key.replace(" ","")
             if not ldap_fin_uid_id.has_key(primary_key):
-                daklib.utils.warn("0x%s (from 0x%s): no UID found in LDAP" % (primary_key, fingerprint))
+                utils.warn("0x%s (from 0x%s): no UID found in LDAP" % (primary_key, fingerprint))
             else:
                 (uid, uid_id) = ldap_fin_uid_id[primary_key]
                 q = projectB.query("UPDATE fingerprint SET uid = %s WHERE id = %s" % (uid_id, fingerprint_id))
@@ -182,7 +182,7 @@ SELECT f.fingerprint, f.id, u.uid FROM fingerprint f, uid u WHERE f.uid = u.id
             for keyring in Cnf.ValueList("Import-LDAP-Fingerprints::ExtraKeyrings"):
                 extra_keyrings += " --keyring=%s" % (keyring)
             cmd = "gpg %s %s --list-key %s" \
-                  % (daklib.utils.gpg_keyring_args(), extra_keyrings, fingerprint)
+                  % (utils.gpg_keyring_args(), extra_keyrings, fingerprint)
             (result, output) = commands.getstatusoutput(cmd)
             if result != 0:
                 cmd = "gpg --keyserver=%s --allow-non-selfsigned-uid --recv-key %s" % (Cnf["Import-LDAP-Fingerprints::KeyServer"], fingerprint)
@@ -214,7 +214,7 @@ SELECT f.fingerprint, f.id, u.uid FROM fingerprint f, uid u WHERE f.uid = u.id
             # FIXME: default to the guessed ID
             uid = None
             while not uid:
-                uid = daklib.utils.our_raw_input("Map to which UID ? ")
+                uid = utils.our_raw_input("Map to which UID ? ")
                 Attrs = l.search_s(LDAPDn,ldap.SCOPE_ONELEVEL,"(uid=%s)" % (uid), ["cn","mn","sn"])
                 if not Attrs:
                     print "That UID doesn't exist in LDAP!"
@@ -223,9 +223,9 @@ SELECT f.fingerprint, f.id, u.uid FROM fingerprint f, uid u WHERE f.uid = u.id
                     entry = Attrs[0][1]
                     name = get_ldap_name(entry)
                     prompt = "Map to %s - %s (y/N) ? " % (uid, name.replace("  "," "))
-                    yn = daklib.utils.our_raw_input(prompt).lower()
+                    yn = utils.our_raw_input(prompt).lower()
                     if yn == "y":
-                        uid_id = daklib.database.get_or_set_uid_id(uid)
+                        uid_id = database.get_or_set_uid_id(uid)
                         projectB.query("UPDATE fingerprint SET uid = %s WHERE id = %s" % (uid_id, fingerprint_id))
                         print "Assigning %s to 0x%s." % (uid, fingerprint)
                     else:
old mode 100644 (file)
new mode 100755 (executable)
index fa34772..af9d123
@@ -31,7 +31,7 @@
 
 import pg, pwd, sys
 import apt_pkg
-import daklib.utils
+import daklib.utils as utils
 
 ################################################################################
 
@@ -54,7 +54,7 @@ Sync PostgreSQL's users with system users.
 def main ():
     global Cnf, projectB
 
-    Cnf = daklib.utils.get_conf()
+    Cnf = utils.get_conf()
 
     Arguments = [('n', "no-action", "Import-Users-From-Passwd::Options::No-Action"),
                  ('q', "quiet", "Import-Users-From-Passwd::Options::Quiet"),
@@ -70,7 +70,7 @@ def main ():
     if Options["Help"]:
         usage()
     elif arguments:
-        daklib.utils.warn("dak import-users-from-passwd takes no non-option arguments.")
+        utils.warn("dak import-users-from-passwd takes no non-option arguments.")
         usage(1)
 
     projectB = pg.connect(Cnf["DB::Name"], Cnf["DB::Host"], int(Cnf["DB::Port"]))
old mode 100644 (file)
new mode 100755 (executable)
index 3185b6e..16a8d8b
@@ -21,8 +21,8 @@
 
 import pg, sys
 import apt_pkg
-import daklib.database
-import daklib.utils
+import daklib.database as database
+import daklib.utils as utils
 
 ################################################################################
 
@@ -101,9 +101,9 @@ def do_location():
     projectB.query("DELETE FROM location")
     for location in Cnf.SubTree("Location").List():
         location_config = Cnf.SubTree("Location::%s" % (location))
-        archive_id = daklib.database.get_archive_id(location_config["Archive"])
+        archive_id = database.get_archive_id(location_config["Archive"])
         if archive_id == -1:
-            daklib.utils.fubar("Archive '%s' for location '%s' not found."
+            utils.fubar("Archive '%s' for location '%s' not found."
                                % (location_config["Archive"], location))
         location_type = location_config.get("type")
         if location_type == "legacy-mixed":
@@ -112,13 +112,13 @@ def do_location():
                            % (location, archive_id, location_config["type"]))
         elif location_type == "legacy" or location_type == "pool":
             for component in Cnf.SubTree("Component").List():
-                component_id = daklib.database.get_component_id(component)
+                component_id = database.get_component_id(component)
                 projectB.query("INSERT INTO location (path, component, "
                                "archive, type) VALUES ('%s', %d, %d, '%s')"
                                % (location, component_id, archive_id,
                                   location_type))
         else:
-            daklib.utils.fubar("E: type '%s' not recognised in location %s."
+            utils.fubar("E: type '%s' not recognised in location %s."
                                % (location_type, location))
     projectB.query("COMMIT WORK")
 
@@ -136,9 +136,9 @@ def do_suite():
                        "description) VALUES ('%s', %s, %s, %s)"
                        % (suite.lower(), version, origin, description))
         for architecture in Cnf.ValueList("Suite::%s::Architectures" % (suite)):
-            architecture_id = daklib.database.get_architecture_id (architecture)
+            architecture_id = database.get_architecture_id (architecture)
             if architecture_id < 0:
-                daklib.utils.fubar("architecture '%s' not found in architecture"
+                utils.fubar("architecture '%s' not found in architecture"
                                    " table for suite %s."
                                    % (architecture, suite))
             projectB.query("INSERT INTO suite_architectures (suite, "
@@ -196,7 +196,7 @@ def main ():
 
     global Cnf, projectB
 
-    Cnf = daklib.utils.get_conf()
+    Cnf = utils.get_conf()
     arguments = [('h', "help", "Init-DB::Options::Help")]
     for i in [ "help" ]:
         if not Cnf.has_key("Init-DB::Options::%s" % (i)):
@@ -208,12 +208,12 @@ def main ():
     if options["Help"]:
         usage()
     elif arguments:
-        daklib.utils.warn("dak init-db takes no arguments.")
+        utils.warn("dak init-db takes no arguments.")
         usage(exit_code=1)
 
     projectB = pg.connect(Cnf["DB::Name"], Cnf["DB::Host"],
                           int(Cnf["DB::Port"]))
-    daklib.database.init(Cnf, projectB)
+    database.init(Cnf, projectB)
 
     do_archive()
     do_architecture()
old mode 100644 (file)
new mode 100755 (executable)
index f9d3e80..f92515e
@@ -21,7 +21,7 @@
 
 import os, sys
 import apt_pkg
-import daklib.utils
+import daklib.utils as utils
 
 ################################################################################
 
@@ -47,7 +47,7 @@ it."""
 
     if os.path.exists(target):
         if not os.path.isdir(target):
-            daklib.utils.fubar("%s (%s) is not a directory."
+            utils.fubar("%s (%s) is not a directory."
                                % (target, config_name))
     else:
         print "Creating %s ..." % (target)
@@ -118,7 +118,7 @@ def main ():
 
     global AptCnf, Cnf
 
-    Cnf = daklib.utils.get_conf()
+    Cnf = utils.get_conf()
     arguments = [('h', "help", "Init-Dirs::Options::Help")]
     for i in [ "help" ]:
         if not Cnf.has_key("Init-Dirs::Options::%s" % (i)):
@@ -130,11 +130,11 @@ def main ():
     if options["Help"]:
         usage()
     elif arguments:
-        daklib.utils.warn("dak init-dirs takes no arguments.")
+        utils.warn("dak init-dirs takes no arguments.")
         usage(exit_code=1)
 
     AptCnf = apt_pkg.newConfiguration()
-    apt_pkg.ReadConfigFileISC(AptCnf, daklib.utils.which_apt_conf_file())
+    apt_pkg.ReadConfigFileISC(AptCnf, utils.which_apt_conf_file())
 
     create_directories()
 
old mode 100644 (file)
new mode 100755 (executable)
index 6ed845f..2b445d8
--- a/dak/ls.py
+++ b/dak/ls.py
@@ -28,8 +28,8 @@
 
 import os, pg, sys
 import apt_pkg
-import daklib.database
-import daklib.utils
+import daklib.database as database
+import daklib.utils as utils
 
 ################################################################################
 
@@ -61,7 +61,7 @@ ARCH, COMPONENT and SUITE can be comma (or space) separated lists, e.g.
 def main ():
     global Cnf, projectB
 
-    Cnf = daklib.utils.get_conf()
+    Cnf = utils.get_conf()
 
     Arguments = [('a', "architecture", "Ls::Options::Architecture", "HasArg"),
                  ('b', "binarytype", "Ls::Options::BinaryType", "HasArg"),
@@ -85,29 +85,29 @@ def main ():
     if Options["Help"]:
         usage()
     if not packages:
-        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)
 
     # If cron.daily is running; warn the user that our output might seem strange
     if os.path.exists(os.path.join(Cnf["Dir::Root"], "Archive_Maintenance_In_Progress")):
-        daklib.utils.warn("Archive maintenance is in progress; database inconsistencies are possible.")
+        utils.warn("Archive maintenance is in progress; database inconsistencies are possible.")
 
     # Handle buildd maintenance helper options
     if Options["GreaterOrEqual"] or Options["GreaterThan"]:
         if Options["GreaterOrEqual"] and Options["GreaterThan"]:
-            daklib.utils.fubar("-g/--greaterorequal and -G/--greaterthan are mutually exclusive.")
+            utils.fubar("-g/--greaterorequal and -G/--greaterthan are mutually exclusive.")
         if not Options["Suite"]:
             Options["Suite"] = "unstable"
 
     # Parse -a/--architecture, -c/--component and -s/--suite
     (con_suites, con_architectures, con_components, check_source) = \
-                 daklib.utils.parse_args(Options)
+                 utils.parse_args(Options)
 
     if Options["BinaryType"]:
         if Options["BinaryType"] != "udeb" and Options["BinaryType"] != "deb":
-            daklib.utils.fubar("Invalid binary type.  'udeb' and 'deb' recognised.")
+            utils.fubar("Invalid binary type.  'udeb' and 'deb' recognised.")
         con_bintype = "AND b.type = '%s'" % (Options["BinaryType"])
         # REMOVE ME TRAMP
         if Options["BinaryType"] == "udeb":
@@ -178,7 +178,7 @@ SELECT s.source, s.version, 'source', su.suite_name, c.name, m.name
                 suites.sort()
                 for suite in suites:
                     arches = d[pkg][version][suite]
-                    arches.sort(daklib.utils.arch_compare_sw)
+                    arches.sort(utils.arch_compare_sw)
                     if Options["Format"] == "": #normal
                         sys.stdout.write("%10s | %10s | %13s | " % (pkg, version, suite))
                         sys.stdout.write(", ".join(arches))
old mode 100644 (file)
new mode 100755 (executable)
index 077386a..c3905af
@@ -27,8 +27,8 @@
 
 import pg, sys
 import apt_pkg
-import daklib.database
-import daklib.utils
+import daklib.database as database
+import daklib.utils as utils
 
 ################################################################################
 
@@ -54,12 +54,12 @@ def fix_maintainer (maintainer):
     global fixed_maintainer_cache
 
     if not fixed_maintainer_cache.has_key(maintainer):
-        fixed_maintainer_cache[maintainer] = daklib.utils.fix_maintainer(maintainer)[0]
+        fixed_maintainer_cache[maintainer] = utils.fix_maintainer(maintainer)[0]
 
     return fixed_maintainer_cache[maintainer]
 
 def get_maintainer (maintainer):
-    return fix_maintainer(daklib.database.get_maintainer(maintainer))
+    return fix_maintainer(database.get_maintainer(maintainer))
 
 def get_maintainer_from_source (source_id):
     global maintainer_from_source_cache
@@ -76,7 +76,7 @@ def get_maintainer_from_source (source_id):
 def main():
     global Cnf, projectB
 
-    Cnf = daklib.utils.get_conf()
+    Cnf = utils.get_conf()
 
     Arguments = [('h',"help","Make-Maintainers::Options::Help")]
     if not Cnf.has_key("Make-Maintainers::Options::Help"):
@@ -89,7 +89,7 @@ def main():
         usage()
 
     projectB = pg.connect(Cnf["DB::Name"], Cnf["DB::Host"], int(Cnf["DB::Port"]))
-    daklib.database.init(Cnf, projectB)
+    database.init(Cnf, projectB)
 
     for suite in Cnf.SubTree("Suite").List():
         suite = suite.lower()
@@ -130,9 +130,9 @@ def main():
 
     # Process any additional Maintainer files (e.g. from pseudo packages)
     for filename in extra_files:
-        file = daklib.utils.open_file(filename)
+        file = utils.open_file(filename)
         for line in file.readlines():
-            line = daklib.utils.re_comments.sub('', line).strip()
+            line = utils.re_comments.sub('', line).strip()
             if line == "":
                 continue
             split = line.split()
old mode 100644 (file)
new mode 100755 (executable)
index 77074ed..77e7bb8
@@ -27,8 +27,8 @@
 
 import pg, sys
 import apt_pkg
-import daklib.database
-import daklib.utils
+import daklib.database as database
+import daklib.utils as utils
 
 ################################################################################
 
@@ -50,17 +50,17 @@ Outputs the override tables to text files.
 def do_list(output_file, suite, component, otype):
     global override
 
-    suite_id = daklib.database.get_suite_id(suite)
+    suite_id = database.get_suite_id(suite)
     if suite_id == -1:
-        daklib.utils.fubar("Suite '%s' not recognised." % (suite))
+        utils.fubar("Suite '%s' not recognised." % (suite))
 
-    component_id = daklib.database.get_component_id(component)
+    component_id = database.get_component_id(component)
     if component_id == -1:
-        daklib.utils.fubar("Component '%s' not recognised." % (component))
+        utils.fubar("Component '%s' not recognised." % (component))
 
-    otype_id = daklib.database.get_override_type_id(otype)
+    otype_id = database.get_override_type_id(otype)
     if otype_id == -1:
-        daklib.utils.fubar("Type '%s' not recognised. (Valid types are deb, udeb and dsc)" % (otype))
+        utils.fubar("Type '%s' not recognised. (Valid types are deb, udeb and dsc)" % (otype))
 
     override.setdefault(suite, {})
     override[suite].setdefault(component, {})
@@ -70,20 +70,20 @@ def do_list(output_file, suite, component, otype):
         q = projectB.query("SELECT o.package, s.section, o.maintainer FROM override o, section s WHERE o.suite = %s AND o.component = %s AND o.type = %s AND o.section = s.id ORDER BY s.section, o.package" % (suite_id, component_id, otype_id))
         for i in q.getresult():
             override[suite][component][otype][i[0]] = i
-            output_file.write(daklib.utils.result_join(i)+'\n')
+            output_file.write(utils.result_join(i)+'\n')
     else:
         q = projectB.query("SELECT o.package, p.priority, s.section, o.maintainer, p.level FROM override o, priority p, section s WHERE o.suite = %s AND o.component = %s AND o.type = %s AND o.priority = p.id AND o.section = s.id ORDER BY s.section, p.level, o.package" % (suite_id, component_id, otype_id))
         for i in q.getresult():
             i = i[:-1]; # Strip the priority level
             override[suite][component][otype][i[0]] = i
-            output_file.write(daklib.utils.result_join(i)+'\n')
+            output_file.write(utils.result_join(i)+'\n')
 
 ################################################################################
 
 def main ():
     global Cnf, projectB, override
 
-    Cnf = daklib.utils.get_conf()
+    Cnf = utils.get_conf()
     Arguments = [('h',"help","Make-Overrides::Options::Help")]
     for i in [ "help" ]:
         if not Cnf.has_key("Make-Overrides::Options::%s" % (i)):
@@ -94,7 +94,7 @@ def main ():
         usage()
 
     projectB = pg.connect(Cnf["DB::Name"], Cnf["DB::Host"], int(Cnf["DB::Port"]))
-    daklib.database.init(Cnf, projectB)
+    database.init(Cnf, projectB)
 
     for suite in Cnf.SubTree("Check-Overrides::OverrideSuites").List():
         if Cnf.has_key("Suite::%s::Untouchable" % suite) and Cnf["Suite::%s::Untouchable" % suite] != 0:
@@ -116,7 +116,7 @@ def main ():
                 elif otype == "dsc":
                     suffix = ".src"
                 filename = "%s/override.%s.%s%s" % (Cnf["Dir::Override"], override_suite, component, suffix)
-                output_file = daklib.utils.open_file(filename, 'w')
+                output_file = utils.open_file(filename, 'w')
                 do_list(output_file, suite, component, otype)
                 output_file.close()
 
old mode 100644 (file)
new mode 100755 (executable)
index a63a617..ca4e036
@@ -36,9 +36,9 @@
 import copy, os, pg, sys
 import apt_pkg
 import symlink_dists
-import daklib.database
-import daklib.logging
-import daklib.utils
+import daklib.database as database
+import daklib.logging as logging
+import daklib.utils as utils
 
 ################################################################################
 
@@ -77,7 +77,7 @@ def version_cmp(a, b):
 
 def delete_packages(delete_versions, pkg, dominant_arch, suite,
                     dominant_version, delete_table, delete_col, packages):
-    suite_id = daklib.database.get_suite_id(suite)
+    suite_id = database.get_suite_id(suite)
     for version in delete_versions:
         delete_unique_id = version[1]
         if not packages.has_key(delete_unique_id):
@@ -199,7 +199,7 @@ def cleanup(packages):
 def write_legacy_mixed_filelist(suite, list, packages, dislocated_files):
     # Work out the filename
     filename = os.path.join(Cnf["Dir::Lists"], "%s_-_all.list" % (suite))
-    output = daklib.utils.open_file(filename, "w")
+    output = utils.open_file(filename, "w")
     # Generate the final list of files
     files = {}
     for id in list:
@@ -211,7 +211,7 @@ def write_legacy_mixed_filelist(suite, list, packages, dislocated_files):
         else:
             filename = path + filename
         if files.has_key(filename):
-            daklib.utils.warn("%s (in %s) is duplicated." % (filename, suite))
+            utils.warn("%s (in %s) is duplicated." % (filename, suite))
         else:
             files[filename] = ""
     # Sort the files since apt-ftparchive doesn't
@@ -232,7 +232,7 @@ def write_filelist(suite, component, arch, type, list, packages, dislocated_file
         elif type == "deb":
             arch = "binary-%s" % (arch)
     filename = os.path.join(Cnf["Dir::Lists"], "%s_%s_%s.list" % (suite, component, arch))
-    output = daklib.utils.open_file(filename, "w")
+    output = utils.open_file(filename, "w")
     # Generate the final list of files
     files = {}
     for id in list:
@@ -245,7 +245,7 @@ def write_filelist(suite, component, arch, type, list, packages, dislocated_file
         else:
             filename = path + filename
         if files.has_key(pkg):
-            daklib.utils.warn("%s (in %s/%s, %s) is duplicated." % (pkg, suite, component, filename))
+            utils.warn("%s (in %s/%s, %s) is duplicated." % (pkg, suite, component, filename))
         else:
             files[pkg] = filename
     # Sort the files since apt-ftparchive doesn't
@@ -275,13 +275,13 @@ def write_filelists(packages, dislocated_files):
     if not Options["Suite"]:
         suites = Cnf.SubTree("Suite").List()
     else:
-        suites = daklib.utils.split_args(Options["Suite"])
+        suites = utils.split_args(Options["Suite"])
     for suite in [ i.lower() for i in suites ]:
         d.setdefault(suite, {})
         if not Options["Component"]:
             components = Cnf.ValueList("Suite::%s::Components" % (suite))
         else:
-            components = daklib.utils.split_args(Options["Component"])
+            components = utils.split_args(Options["Component"])
         udeb_components = Cnf.ValueList("Suite::%s::UdebComponents" % (suite))
         udeb_components = udeb_components
         for component in components:
@@ -293,7 +293,7 @@ def write_filelists(packages, dislocated_files):
             if not Options["Architecture"]:
                 architectures = Cnf.ValueList("Suite::%s::Architectures" % (suite))
             else:
-                architectures = daklib.utils.split_args(Options["Architectures"])
+                architectures = utils.split_args(Options["Architectures"])
             for arch in [ i.lower() for i in architectures ]:
                 d[suite][component].setdefault(arch, {})
                 if arch == "source":
@@ -343,7 +343,7 @@ def stable_dislocation_p():
     if not Options["Suite"]:
         return 1
     # Otherwise, look in what suites the user specified
-    suites = daklib.utils.split_args(Options["Suite"])
+    suites = utils.split_args(Options["Suite"])
 
     if "stable" in suites:
         return 1
@@ -356,16 +356,16 @@ def do_da_do_da():
     # If we're only doing a subset of suites, ensure we do enough to
     # be able to do arch: all mapping.
     if Options["Suite"]:
-        suites = daklib.utils.split_args(Options["Suite"])
+        suites = utils.split_args(Options["Suite"])
         for suite in suites:
             archall_suite = Cnf.get("Make-Suite-File-List::ArchAllMap::%s" % (suite))
             if archall_suite and archall_suite not in suites:
-                daklib.utils.warn("Adding %s as %s maps Arch: all from it." % (archall_suite, suite))
+                utils.warn("Adding %s as %s maps Arch: all from it." % (archall_suite, suite))
                 suites.append(archall_suite)
         Options["Suite"] = ",".join(suites)
 
     (con_suites, con_architectures, con_components, check_source) = \
-                 daklib.utils.parse_args(Options)
+                 utils.parse_args(Options)
 
     if stable_dislocation_p():
         dislocated_files = symlink_dists.find_dislocated_stable(Cnf, projectB)
@@ -409,7 +409,7 @@ SELECT s.id, s.source, 'source', s.version, l.path, f.filename, c.name, f.id,
 def main():
     global Cnf, projectB, Options, Logger
 
-    Cnf = daklib.utils.get_conf()
+    Cnf = utils.get_conf()
     Arguments = [('a', "architecture", "Make-Suite-File-List::Options::Architecture", "HasArg"),
                  ('c', "component", "Make-Suite-File-List::Options::Component", "HasArg"),
                  ('h', "help", "Make-Suite-File-List::Options::Help"),
@@ -425,8 +425,8 @@ def main():
         usage()
 
     projectB = pg.connect(Cnf["DB::Name"], Cnf["DB::Host"], int(Cnf["DB::Port"]))
-    daklib.database.init(Cnf, projectB)
-    Logger = daklib.logging.Logger(Cnf, "make-suite-file-list")
+    database.init(Cnf, projectB)
+    Logger = logging.Logger(Cnf, "make-suite-file-list")
     do_da_do_da()
     Logger.close()
 
old mode 100644 (file)
new mode 100755 (executable)
index f2aea52..ca119c8
 
 ################################################################################
 
-import daklib.queue, daklib.logging, daklib.utils, daklib.database
+import daklib.queue as queue
+import daklib.logging as logging
+import daklib.utils as utils
+import daklib.database as database
 import apt_pkg, os, sys, pwd, time, re, commands
 
 re_taint_free = re.compile(r"^['/;\-\+\.~\s\w]+$");
@@ -37,7 +40,7 @@ srcverarches = {}
 def init():
     global Cnf, Upload, Options, Logger
 
-    Cnf = daklib.utils.get_conf()
+    Cnf = utils.get_conf()
     Cnf["Dinstall::Options::No-Mail"] = "y"
     Arguments = [('h', "help", "Security-Install::Options::Help"),
                  ('a', "automatic", "Security-Install::Options::Automatic"),
@@ -69,13 +72,13 @@ def init():
         sys.exit(0)
 
     if len(arguments) == 0:
-        daklib.utils.fubar("Process what?")
+        utils.fubar("Process what?")
 
-    Upload = daklib.queue.Upload(Cnf)
+    Upload = queue.Upload(Cnf)
     if Options["No-Action"]:
         Options["Sudo"] = ""
     if not Options["Sudo"] and not Options["No-Action"]:
-        Logger = Upload.Logger = daklib.logging.Logger(Cnf, "new-security-install")
+        Logger = Upload.Logger = logging.Logger(Cnf, "new-security-install")
 
     return arguments
 
@@ -97,9 +100,9 @@ def load_args(arguments):
     changesfiles = {}
     for a in arguments:
         if "/" in a:
-            daklib.utils.fubar("can only deal with files in the current directory")
+            utils.fubar("can only deal with files in the current directory")
         if not a.endswith(".changes"):
-            daklib.utils.fubar("not a .changes file: %s" % (a))
+            utils.fubar("not a .changes file: %s" % (a))
         Upload.init_vars()
         Upload.pkg.changes_file = a
         Upload.update_vars()
@@ -111,7 +114,7 @@ def load_args(arguments):
 
     adv_ids = adv_ids.keys()
     if len(adv_ids) > 1:
-        daklib.utils.fubar("multiple advisories selected: %s" % (", ".join(adv_ids)))
+        utils.fubar("multiple advisories selected: %s" % (", ".join(adv_ids)))
     if adv_ids == []:
         advisory = None
     else:
@@ -171,7 +174,7 @@ def prompt(opts, default):
         a = default
 
     while a not in v:
-        a = daklib.utils.our_raw_input(p) + default
+        a = utils.our_raw_input(p) + default
         a = a[:1].upper()
 
     return v[a]
@@ -192,7 +195,7 @@ def add_changes(extras):
 def yes_no(prompt):
     if Options["Automatic"]: return True
     while 1:
-        answer = daklib.utils.our_raw_input(prompt + " ").lower()
+        answer = utils.our_raw_input(prompt + " ").lower()
         if answer in "yn":
             return answer == "y"
         print "Invalid answer; please try again."
@@ -218,9 +221,9 @@ def actually_upload(changes_files):
     uploads = {}; # uploads[uri] = file_list
     changesfiles = {}; # changesfiles[uri] = file_list
     package_list = {} # package_list[source_name][version]
-    changes_files.sort(daklib.utils.changes_compare)
+    changes_files.sort(utils.changes_compare)
     for changes_file in changes_files:
-        changes_file = daklib.utils.validate_changes_file_arg(changes_file)
+        changes_file = utils.validate_changes_file_arg(changes_file)
         # Reset variables
         components = {}
         upload_uris = {}
@@ -239,7 +242,7 @@ def actually_upload(changes_files):
         # Build the file list for this .changes file
         for file in files.keys():
             poolname = os.path.join(Cnf["Dir::Root"], Cnf["Dir::PoolRoot"],
-                                    daklib.utils.poolify(changes["source"], files[file]["component"]),
+                                    utils.poolify(changes["source"], files[file]["component"]),
                                     file)
             file_list.append(poolname)
             orig_component = files[file].get("original component", files[file]["component"])
@@ -251,10 +254,10 @@ def actually_upload(changes_files):
                 upload_uris[upload_uri] = ""
         num_upload_uris = len(upload_uris.keys())
         if num_upload_uris == 0:
-            daklib.utils.fubar("%s: No valid upload URI found from components (%s)."
+            utils.fubar("%s: No valid upload URI found from components (%s)."
                         % (changes_file, ", ".join(components.keys())))
         elif num_upload_uris > 1:
-            daklib.utils.fubar("%s: more than one upload URI (%s) from components (%s)."
+            utils.fubar("%s: more than one upload URI (%s) from components (%s)."
                         % (changes_file, ", ".join(upload_uris.keys()),
                            ", ".join(components.keys())))
         upload_uri = upload_uris.keys()[0]
@@ -285,7 +288,7 @@ def actually_upload(changes_files):
 
     if not Options["No-Action"]:
         filename = "%s/testing-processed" % (Cnf["Dir::Log"])
-        file = daklib.utils.open_file(filename, 'a')
+        file = utils.open_file(filename, 'a')
         for source in package_list.keys():
             for version in package_list[source].keys():
                 file.write(" ".join([source, version])+'\n')
@@ -298,7 +301,7 @@ def generate_advisory(template):
     updated_pkgs = {};  # updated_pkgs[distro][arch][file] = {path,md5,size}
 
     for arg in changes:
-        arg = daklib.utils.validate_changes_file_arg(arg)
+        arg = utils.validate_changes_file_arg(arg)
         Upload.pkg.changes_file = arg
         Upload.init_vars()
         Upload.update_vars()
@@ -319,7 +322,7 @@ def generate_advisory(template):
             md5 = files[file]["md5sum"]
             size = files[file]["size"]
             poolname = Cnf["Dir::PoolRoot"] + \
-                daklib.utils.poolify(src, files[file]["component"])
+                utils.poolify(src, files[file]["component"])
             if arch == "source" and file.endswith(".dsc"):
                 dscpoolname = poolname
             for suite in suites:
@@ -363,7 +366,7 @@ def generate_advisory(template):
         Subst["__BCC__"] = "Bcc: %s" % (Cnf["Dinstall::Bcc"])
 
     adv = ""
-    archive = Cnf["Archive::%s::PrimaryMirror" % (daklib.utils.where_am_i())]
+    archive = Cnf["Archive::%s::PrimaryMirror" % (utils.where_am_i())]
     for suite in updated_pkgs.keys():
         ver = Cnf["Suite::%s::Version" % suite]
         if ver != "": ver += " "
@@ -379,7 +382,7 @@ def generate_advisory(template):
         arches.sort()
 
         adv += "%s updates are available for %s.\n\n" % (
-                suite.capitalize(), daklib.utils.join_with_commas_and(arches))
+                suite.capitalize(), utils.join_with_commas_and(arches))
 
         for a in ["source", "all"] + arches:
             if not updated_pkgs[suite].has_key(a):
@@ -404,19 +407,19 @@ def generate_advisory(template):
 
     Subst["__ADVISORY_TEXT__"] = adv
 
-    adv = daklib.utils.TemplateSubst(Subst, template)
+    adv = utils.TemplateSubst(Subst, template)
     return adv
 
 def spawn(command):
     if not re_taint_free.match(command):
-        daklib.utils.fubar("Invalid character in \"%s\"." % (command))
+        utils.fubar("Invalid character in \"%s\"." % (command))
 
     if Options["No-Action"]:
         print "[%s]" % (command)
     else:
         (result, output) = commands.getstatusoutput(command)
         if (result != 0):
-            daklib.utils.fubar("Invocation of '%s' failed:\n%s\n" % (command, output), result)
+            utils.fubar("Invocation of '%s' failed:\n%s\n" % (command, output), result)
 
 
 ##################### ! ! ! N O T E ! ! !  #####################
@@ -429,7 +432,7 @@ def spawn(command):
 def sudo(arg, fn, exit):
     if Options["Sudo"]:
         if advisory == None:
-            daklib.utils.fubar("Must set advisory name")
+            utils.fubar("Must set advisory name")
         os.spawnl(os.P_WAIT, "/usr/bin/sudo", "/usr/bin/sudo", "-u", "dak", "-H",
                   "/usr/local/bin/dak", "new-security-install", "-"+arg, "--", advisory)
     else:
@@ -459,7 +462,7 @@ def _do_Approve():
     print "Updating file lists for apt-ftparchive..."
     spawn("dak make-suite-file-list")
     print "Updating Packages and Sources files..."
-    spawn("apt-ftparchive generate %s" % (daklib.utils.which_apt_conf_file()))
+    spawn("apt-ftparchive generate %s" % (utils.which_apt_conf_file()))
     print "Updating Release files..."
     spawn("dak generate-releases")
     print "Triggering security mirrors..."
@@ -473,11 +476,11 @@ def _do_Approve():
 def do_Disembargo(): sudo("D", _do_Disembargo, True)
 def _do_Disembargo():
     if os.getcwd() != Cnf["Dir::Queue::Embargoed"].rstrip("/"):
-        daklib.utils.fubar("Can only disembargo from %s" % Cnf["Dir::Queue::Embargoed"])
+        utils.fubar("Can only disembargo from %s" % Cnf["Dir::Queue::Embargoed"])
 
     dest = Cnf["Dir::Queue::Unembargoed"]
-    emb_q = daklib.database.get_or_set_queue_id("embargoed")
-    une_q = daklib.database.get_or_set_queue_id("unembargoed")
+    emb_q = database.get_or_set_queue_id("embargoed")
+    une_q = database.get_or_set_queue_id("unembargoed")
 
     for c in changes:
         print "Disembargoing %s" % (c)
@@ -507,14 +510,14 @@ def _do_Disembargo():
         Upload.projectB.query("COMMIT WORK")
 
         for file in Upload.pkg.files.keys():
-            daklib.utils.copy(file, os.path.join(dest, file))
+            utils.copy(file, os.path.join(dest, file))
             os.unlink(file)
 
     for c in changes:
-        daklib.utils.copy(c, os.path.join(dest, c))
+        utils.copy(c, os.path.join(dest, c))
         os.unlink(c)
         k = c[:-8] + ".dak"
-        daklib.utils.copy(k, os.path.join(dest, k))
+        utils.copy(k, os.path.join(dest, k))
         os.unlink(k)
 
 def do_Reject(): sudo("R", _do_Reject, True)
@@ -564,11 +567,11 @@ def do_DropAdvisory():
 def do_Edit():
     adv_file = "./advisory.%s" % (advisory)
     if not os.path.exists(adv_file):
-        daklib.utils.copy(Cnf["Dir::Templates"]+"/security-install.advisory", adv_file)
+        utils.copy(Cnf["Dir::Templates"]+"/security-install.advisory", adv_file)
     editor = os.environ.get("EDITOR", "vi")
     result = os.system("%s %s" % (editor, adv_file))
     if result != 0:
-        daklib.utils.fubar("%s invocation failed for %s." % (editor, adv_file))
+        utils.fubar("%s invocation failed for %s." % (editor, adv_file))
 
 def do_Show():
     adv_file = "./advisory.%s" % (advisory)
@@ -604,10 +607,10 @@ def main():
             add_changes(extras)
 
     if not advisory:
-        daklib.utils.fubar("Must specify an advisory id")
+        utils.fubar("Must specify an advisory id")
 
     if not changes:
-        daklib.utils.fubar("No changes specified")
+        utils.fubar("No changes specified")
 
     if Options["Approve"]:
         advisory_info()
@@ -649,7 +652,7 @@ def main():
             elif what == "Reject":
                 do_Reject()
             else:
-                daklib.utils.fubar("Impossible answer '%s', wtf?" % (what))
+                utils.fubar("Impossible answer '%s', wtf?" % (what))
 
 ################################################################################
 
old mode 100644 (file)
new mode 100755 (executable)
index 2e10bca..ffa6ae9
@@ -27,9 +27,9 @@
 
 import pg, sys
 import apt_pkg
-import daklib.logging
-import daklib.database
-import daklib.utils
+import daklib.logging as logging
+import daklib.database as database
+import daklib.utils as utils
 
 ################################################################################
 
@@ -38,9 +38,9 @@ projectB = None
 
 ################################################################################
 
-# Shamelessly stolen from 'dak rm'. Should probably end up in daklib.utils.py
+# Shamelessly stolen from 'dak rm'. Should probably end up in utils.py
 def game_over():
-    answer = daklib.utils.our_raw_input("Continue (y/N)? ").lower()
+    answer = utils.our_raw_input("Continue (y/N)? ").lower()
     if answer != "y":
         print "Aborted."
         sys.exit(1)
@@ -60,7 +60,7 @@ Make microchanges or microqueries of the binary overrides
 def main ():
     global Cnf, projectB
 
-    Cnf = daklib.utils.get_conf()
+    Cnf = utils.get_conf()
 
     Arguments = [('h',"help","Override::Options::Help"),
                  ('d',"done","Override::Options::Done", "HasArg"),
@@ -80,15 +80,15 @@ def main ():
         usage()
 
     projectB = pg.connect(Cnf["DB::Name"], Cnf["DB::Host"], int(Cnf["DB::Port"]))
-    daklib.database.init(Cnf, projectB)
+    database.init(Cnf, projectB)
 
     if not arguments:
-        daklib.utils.fubar("package name is a required argument.")
+        utils.fubar("package name is a required argument.")
 
     package = arguments.pop(0)
     suite = Options["Suite"]
     if arguments and len(arguments) > 2:
-        daklib.utils.fubar("Too many arguments")
+        utils.fubar("Too many arguments")
 
     if arguments and len(arguments) == 1:
         # Determine if the argument is a priority or a section...
@@ -103,7 +103,7 @@ def main ():
         elif r[0][1] == 1:
             arguments = (".",arg)
         else:
-            daklib.utils.fubar("%s is not a valid section or priority" % (arg))
+            utils.fubar("%s is not a valid section or priority" % (arg))
 
     # Retrieve current section/priority...
     oldsection, oldsourcesection, oldpriority = None, None, None
@@ -126,7 +126,7 @@ def main ():
         if q.ntuples() == 0:
             continue
         if q.ntuples() > 1:
-            daklib.utils.fubar("%s is ambiguous. Matches %d packages" % (package,q.ntuples()))
+            utils.fubar("%s is ambiguous. Matches %d packages" % (package,q.ntuples()))
 
         r = q.getresult()
         if type == 'binary':
@@ -136,10 +136,10 @@ def main ():
             oldsourcesection = r[0][1]
 
     if not oldpriority and not oldsourcesection:
-        daklib.utils.fubar("Unable to find package %s" % (package))
+        utils.fubar("Unable to find package %s" % (package))
     if oldsection and oldsourcesection and oldsection != oldsourcesection:
         # When setting overrides, both source & binary will become the same section
-        daklib.utils.warn("Source is in section '%s' instead of '%s'" % (oldsourcesection, oldsection))
+        utils.warn("Source is in section '%s' instead of '%s'" % (oldsourcesection, oldsection))
     if not oldsection:
         oldsection = oldsourcesection
 
@@ -165,14 +165,14 @@ def main ():
         pg._quote(newsection,"str")))
 
     if q.ntuples() == 0:
-        daklib.utils.fubar("Supplied section %s is invalid" % (newsection))
+        utils.fubar("Supplied section %s is invalid" % (newsection))
     newsecid = q.getresult()[0][0]
 
     q = projectB.query("SELECT id FROM priority WHERE priority=%s" % (
         pg._quote(newpriority,"str")))
 
     if q.ntuples() == 0:
-        daklib.utils.fubar("Supplied priority %s is invalid" % (newpriority))
+        utils.fubar("Supplied priority %s is invalid" % (newpriority))
     newprioid = q.getresult()[0][0]
 
     if newpriority == oldpriority and newsection == oldsection:
@@ -180,7 +180,7 @@ def main ():
         sys.exit(0)
 
     if newpriority and not oldpriority:
-        daklib.utils.fubar("Trying to set priority of a source-only package")
+        utils.fubar("Trying to set priority of a source-only package")
 
     # If we're in no-action mode
     if Options["No-Action"]:
@@ -200,13 +200,13 @@ def main ():
 
     if not Options.has_key("Done"):
         pass
-        #daklib.utils.warn("No bugs to close have been specified. Noone will know you have done this.")
+        #utils.warn("No bugs to close have been specified. Noone will know you have done this.")
     else:
         print "I: Will close bug(s): %s" % (Options["Done"])
 
     game_over()
 
-    Logger = daklib.logging.Logger(Cnf, "override")
+    Logger = logging.Logger(Cnf, "override")
 
     projectB.query("BEGIN WORK")
     # We're in "do it" mode, we have something to do... do it
@@ -218,7 +218,7 @@ def main ():
            AND override.type != %d
            AND suite = (SELECT id FROM suite WHERE suite_name=%s)""" % (
             newprioid,
-            pg._quote(package,"str"), daklib.database.get_override_type_id("dsc"),
+            pg._quote(package,"str"), database.get_override_type_id("dsc"),
             pg._quote(suite,"str") ))
         Logger.log(["changed priority",package,oldpriority,newpriority])
 
@@ -250,7 +250,7 @@ def main ():
         Subst["__CC__"] = "X-DAK: dak override\nX-Katie: alicia $Revision: 1.6$"
         Subst["__ADMIN_ADDRESS__"] = Cnf["Dinstall::MyAdminAddress"]
         Subst["__DISTRO__"] = Cnf["Dinstall::MyDistribution"]
-        Subst["__WHOAMI__"] = daklib.utils.whoami()
+        Subst["__WHOAMI__"] = utils.whoami()
 
         summary = "Concerning package %s...\n" % (package)
         summary += "Operating on the %s suite\n" % (suite)
@@ -260,11 +260,11 @@ def main ():
             summary += "Changed section from %s to %s\n" % (oldsection,newsection)
         Subst["__SUMMARY__"] = summary
 
-        for bug in daklib.utils.split_args(Options["Done"]):
+        for bug in utils.split_args(Options["Done"]):
             Subst["__BUG_NUMBER__"] = bug
-            mail_message = daklib.utils.TemplateSubst(
+            mail_message = utils.TemplateSubst(
                 Subst,Cnf["Dir::Templates"]+"/override.bug-close")
-            daklib.utils.send_mail(mail_message)
+            utils.send_mail(mail_message)
             Logger.log(["closed bug",bug])
 
     Logger.close()
old mode 100644 (file)
new mode 100755 (executable)
index bb75d5e..605b5c2
 
 import errno, fcntl, os, sys, time, re
 import apt_pkg
-import daklib.database
-import daklib.logging
-import daklib.queue
-import daklib.utils
+import daklib.database as database
+import daklib.logging as logging
+import daklib.queue as queue
+import daklib.utils as utils
 
 ###############################################################################
 
@@ -72,11 +72,11 @@ class Urgency_Log:
         # Create the log directory if it doesn't exist
         self.log_dir = Cnf["Dir::UrgencyLog"]
         if not os.path.exists(self.log_dir) or not os.access(self.log_dir, os.W_OK):
-            daklib.utils.warn("UrgencyLog directory %s does not exist or is not writeable, using /srv/ftp.debian.org/tmp/ instead" % (self.log_dir))
+            utils.warn("UrgencyLog directory %s does not exist or is not writeable, using /srv/ftp.debian.org/tmp/ instead" % (self.log_dir))
             self.log_dir = '/srv/ftp.debian.org/tmp/'
         # Open the logfile
         self.log_filename = "%s/.install-urgencies-%s.new" % (self.log_dir, self.timestamp)
-        self.log_file = daklib.utils.open_file(self.log_filename, 'w')
+        self.log_file = utils.open_file(self.log_filename, 'w')
         self.writes = 0
 
     def log (self, source, version, urgency):
@@ -91,7 +91,7 @@ class Urgency_Log:
         self.log_file.close()
         if self.writes:
             new_filename = "%s/install-urgencies-%s" % (self.log_dir, self.timestamp)
-            daklib.utils.move(self.log_filename, new_filename)
+            utils.move(self.log_filename, new_filename)
         else:
             os.unlink(self.log_filename)
 
@@ -154,7 +154,7 @@ def check():
 def init():
     global Cnf, Options, Upload, projectB, changes, dsc, dsc_files, files, pkg, Subst
 
-    Cnf = daklib.utils.get_conf()
+    Cnf = utils.get_conf()
 
     Arguments = [('a',"automatic","Dinstall::Options::Automatic"),
                  ('h',"help","Dinstall::Options::Help"),
@@ -172,7 +172,7 @@ def init():
     if Options["Help"]:
         usage()
 
-    Upload = daklib.queue.Upload(Cnf)
+    Upload = queue.Upload(Cnf)
     projectB = Upload.projectB
 
     changes = Upload.pkg.changes
@@ -218,8 +218,8 @@ def action ():
             answer = 'I'
 
     while prompt.find(answer) == -1:
-        answer = daklib.utils.our_raw_input(prompt)
-        m = daklib.queue.re_default_answer.match(prompt)
+        answer = utils.our_raw_input(prompt)
+        m = queue.re_default_answer.match(prompt)
         if answer == "":
             answer = m.group(1)
         answer = answer[:1].upper()
@@ -245,7 +245,7 @@ def do_reject ():
     Subst["__REJECTOR_ADDRESS__"] = Cnf["Dinstall::MyEmailAddress"]
     Subst["__REJECT_MESSAGE__"] = reject_message
     Subst["__CC__"] = "Cc: " + Cnf["Dinstall::MyEmailAddress"]
-    reject_mail_message = daklib.utils.TemplateSubst(Subst,Cnf["Dir::Templates"]+"/process-accepted.unaccept")
+    reject_mail_message = utils.TemplateSubst(Subst,Cnf["Dir::Templates"]+"/process-accepted.unaccept")
 
     # Write the rejection email out as the <foo>.reason file
     reason_filename = os.path.basename(pkg.changes_file[:-8]) + ".reason"
@@ -258,7 +258,7 @@ def do_reject ():
     os.write(fd, reject_mail_message)
     os.close(fd)
 
-    daklib.utils.send_mail(reject_mail_message)
+    utils.send_mail(reject_mail_message)
     Logger.log(["unaccepted", pkg.changes_file])
 
 ###############################################################################
@@ -280,22 +280,22 @@ def install ():
             version = dsc["version"]  # NB: not files[file]["version"], that has no epoch
             maintainer = dsc["maintainer"]
             maintainer = maintainer.replace("'", "\\'")
-            maintainer_id = daklib.database.get_or_set_maintainer_id(maintainer)
+            maintainer_id = database.get_or_set_maintainer_id(maintainer)
             changedby = changes["changed-by"]
             changedby = changedby.replace("'", "\\'")
-            changedby_id = daklib.database.get_or_set_maintainer_id(changedby)
-            fingerprint_id = daklib.database.get_or_set_fingerprint_id(dsc["fingerprint"])
+            changedby_id = database.get_or_set_maintainer_id(changedby)
+            fingerprint_id = database.get_or_set_fingerprint_id(dsc["fingerprint"])
             install_date = time.strftime("%Y-%m-%d")
             filename = files[file]["pool name"] + file
             dsc_component = files[file]["component"]
             dsc_location_id = files[file]["location id"]
             if not files[file].has_key("files id") or not files[file]["files id"]:
-                files[file]["files id"] = daklib.database.set_files_id (filename, files[file]["size"], files[file]["md5sum"], dsc_location_id)
+                files[file]["files id"] = database.set_files_id (filename, files[file]["size"], files[file]["md5sum"], dsc_location_id)
             projectB.query("INSERT INTO source (source, version, maintainer, changedby, file, install_date, sig_fpr) VALUES ('%s', '%s', %d, %d, %d, '%s', %s)"
                            % (package, version, maintainer_id, changedby_id, files[file]["files id"], install_date, fingerprint_id))
 
             for suite in changes["distribution"].keys():
-                suite_id = daklib.database.get_suite_id(suite)
+                suite_id = database.get_suite_id(suite)
                 projectB.query("INSERT INTO src_associations (suite, source) VALUES (%d, currval('source_id_seq'))" % (suite_id))
 
             # Add the source files to the DB (files and dsc_files)
@@ -306,10 +306,10 @@ def install ():
                 # files id is stored in dsc_files by check_dsc().
                 files_id = dsc_files[dsc_file].get("files id", None)
                 if files_id == None:
-                    files_id = daklib.database.get_files_id(filename, dsc_files[dsc_file]["size"], dsc_files[dsc_file]["md5sum"], dsc_location_id)
+                    files_id = database.get_files_id(filename, dsc_files[dsc_file]["size"], dsc_files[dsc_file]["md5sum"], dsc_location_id)
                 # FIXME: needs to check for -1/-2 and or handle exception
                 if files_id == None:
-                    files_id = daklib.database.set_files_id (filename, dsc_files[dsc_file]["size"], dsc_files[dsc_file]["md5sum"], dsc_location_id)
+                    files_id = database.set_files_id (filename, dsc_files[dsc_file]["size"], dsc_files[dsc_file]["md5sum"], dsc_location_id)
                 projectB.query("INSERT INTO dsc_files (source, file) VALUES (currval('source_id_seq'), %d)" % (files_id))
 
             # Add the src_uploaders to the DB
@@ -320,11 +320,11 @@ def install ():
                         u = u.replace("'", "\\'")
                         u = u.strip()
                         uploader_ids.append(
-                            daklib.database.get_or_set_maintainer_id(u))
+                            database.get_or_set_maintainer_id(u))
                 added_ids = {}
                 for u in uploader_ids:
                     if added_ids.has_key(u):
-                        daklib.utils.warn("Already saw uploader %s for source %s" % (u, package))
+                        utils.warn("Already saw uploader %s for source %s" % (u, package))
                         continue
                     added_ids[u]=1
                     projectB.query("INSERT INTO src_uploaders (source, maintainer) VALUES (currval('source_id_seq'), %d)" % (u))
@@ -337,19 +337,19 @@ def install ():
             version = files[file]["version"]
             maintainer = files[file]["maintainer"]
             maintainer = maintainer.replace("'", "\\'")
-            maintainer_id = daklib.database.get_or_set_maintainer_id(maintainer)
-            fingerprint_id = daklib.database.get_or_set_fingerprint_id(changes["fingerprint"])
+            maintainer_id = database.get_or_set_maintainer_id(maintainer)
+            fingerprint_id = database.get_or_set_fingerprint_id(changes["fingerprint"])
             architecture = files[file]["architecture"]
-            architecture_id = daklib.database.get_architecture_id (architecture)
+            architecture_id = database.get_architecture_id (architecture)
             type = files[file]["dbtype"]
             source = files[file]["source package"]
             source_version = files[file]["source version"]
             filename = files[file]["pool name"] + file
             if not files[file].has_key("location id") or not files[file]["location id"]:
-                files[file]["location id"] = daklib.database.get_location_id(Cnf["Dir::Pool"],files[file]["component"],daklib.utils.where_am_i())
+                files[file]["location id"] = database.get_location_id(Cnf["Dir::Pool"],files[file]["component"],utils.where_am_i())
             if not files[file].has_key("files id") or not files[file]["files id"]:
-                files[file]["files id"] = daklib.database.set_files_id (filename, files[file]["size"], files[file]["md5sum"], files[file]["location id"])
-            source_id = daklib.database.get_source_id (source, source_version)
+                files[file]["files id"] = database.set_files_id (filename, files[file]["size"], files[file]["md5sum"], files[file]["location id"])
+            source_id = database.get_source_id (source, source_version)
             if source_id:
                 projectB.query("INSERT INTO binaries (package, version, maintainer, source, architecture, file, type, sig_fpr) VALUES ('%s', '%s', %d, %d, %d, %d, '%s', %d)"
                                % (package, version, maintainer_id, source_id, architecture_id, files[file]["files id"], type, fingerprint_id))
@@ -357,7 +357,7 @@ def install ():
                 projectB.query("INSERT INTO binaries (package, version, maintainer, architecture, file, type, sig_fpr) VALUES ('%s', '%s', %d, %d, %d, '%s', %d)"
                                % (package, version, maintainer_id, architecture_id, files[file]["files id"], type, fingerprint_id))
             for suite in changes["distribution"].keys():
-                suite_id = daklib.database.get_suite_id(suite)
+                suite_id = database.get_suite_id(suite)
                 projectB.query("INSERT INTO bin_associations (suite, bin) VALUES (%d, currval('binaries_id_seq'))" % (suite_id))
 
     # If the .orig.tar.gz is in a legacy directory we need to poolify
@@ -375,10 +375,10 @@ def install ():
                 continue
             # First move the files to the new location
             legacy_filename = qid["path"] + qid["filename"]
-            pool_location = daklib.utils.poolify (changes["source"], files[file]["component"])
+            pool_location = utils.poolify (changes["source"], files[file]["component"])
             pool_filename = pool_location + os.path.basename(qid["filename"])
             destination = Cnf["Dir::Pool"] + pool_location
-            daklib.utils.move(legacy_filename, destination)
+            utils.move(legacy_filename, destination)
             # Then Update the DB's files table
             q = projectB.query("UPDATE files SET filename = '%s', location = '%s' WHERE id = '%s'" % (pool_filename, dsc_location_id, qid["files_id"]))
 
@@ -393,17 +393,17 @@ def install ():
         old_filename = ql[0] + ql[1]
         file_size = ql[2]
         file_md5sum = ql[3]
-        new_filename = daklib.utils.poolify(changes["source"], dsc_component) + os.path.basename(old_filename)
-        new_files_id = daklib.database.get_files_id(new_filename, file_size, file_md5sum, dsc_location_id)
+        new_filename = utils.poolify(changes["source"], dsc_component) + os.path.basename(old_filename)
+        new_files_id = database.get_files_id(new_filename, file_size, file_md5sum, dsc_location_id)
         if new_files_id == None:
-            daklib.utils.copy(old_filename, Cnf["Dir::Pool"] + new_filename)
-            new_files_id = daklib.database.set_files_id(new_filename, file_size, file_md5sum, dsc_location_id)
+            utils.copy(old_filename, Cnf["Dir::Pool"] + new_filename)
+            new_files_id = database.set_files_id(new_filename, file_size, file_md5sum, dsc_location_id)
             projectB.query("UPDATE dsc_files SET file = %s WHERE source = %s AND file = %s" % (new_files_id, source_id, orig_tar_id))
 
     # Install the files into the pool
     for file in files.keys():
         destination = Cnf["Dir::Pool"] + files[file]["pool name"] + file
-        daklib.utils.move(file, destination)
+        utils.move(file, destination)
         Logger.log(["installed", file, files[file]["type"], files[file]["size"], files[file]["architecture"]])
         install_bytes += float(files[file]["size"])
 
@@ -417,14 +417,14 @@ def install ():
         if Cnf.has_key("Suite::%s::CopyDotDak" % (suite)):
             copy_dot_dak[Cnf["Suite::%s::CopyDotDak" % (suite)]] = ""
     for dest in copy_changes.keys():
-        daklib.utils.copy(pkg.changes_file, Cnf["Dir::Root"] + dest)
+        utils.copy(pkg.changes_file, Cnf["Dir::Root"] + dest)
     for dest in copy_dot_dak.keys():
-        daklib.utils.copy(Upload.pkg.changes_file[:-8]+".dak", dest)
+        utils.copy(Upload.pkg.changes_file[:-8]+".dak", dest)
 
     projectB.query("COMMIT WORK")
 
     # Move the .changes into the 'done' directory
-    daklib.utils.move (pkg.changes_file,
+    utils.move (pkg.changes_file,
                 os.path.join(Cnf["Dir::Queue::Done"], os.path.basename(pkg.changes_file)))
 
     # Remove the .dak file
@@ -440,7 +440,7 @@ def install ():
         if suite not in Cnf.ValueList("Dinstall::QueueBuildSuites"):
             continue
         now_date = time.strftime("%Y-%m-%d %H:%M")
-        suite_id = daklib.database.get_suite_id(suite)
+        suite_id = database.get_suite_id(suite)
         dest_dir = Cnf["Dir::QueueBuild"]
         if Cnf.FindB("Dinstall::SecurityQueueBuild"):
             dest_dir = os.path.join(dest_dir, suite)
@@ -450,7 +450,7 @@ def install ():
             projectB.query("UPDATE queue_build SET in_queue = 'f', last_used = '%s' WHERE filename = '%s' AND suite = %s" % (now_date, dest, suite_id))
             if not Cnf.FindB("Dinstall::SecurityQueueBuild"):
                 # Update the symlink to point to the new location in the pool
-                pool_location = daklib.utils.poolify (changes["source"], files[file]["component"])
+                pool_location = utils.poolify (changes["source"], files[file]["component"])
                 src = os.path.join(Cnf["Dir::Pool"], pool_location, os.path.basename(file))
                 if os.path.islink(dest):
                     os.unlink(dest)
@@ -487,11 +487,11 @@ def stable_install (summary, short_summary):
             q = projectB.query("SELECT id FROM source WHERE source = '%s' AND version = '%s'" % (package, version))
             ql = q.getresult()
             if not ql:
-                daklib.utils.fubar("[INTERNAL ERROR] couldn't find '%s' (%s) in source table." % (package, version))
+                utils.fubar("[INTERNAL ERROR] couldn't find '%s' (%s) in source table." % (package, version))
             source_id = ql[0][0]
-            suite_id = daklib.database.get_suite_id('proposed-updates')
+            suite_id = database.get_suite_id('proposed-updates')
             projectB.query("DELETE FROM src_associations WHERE suite = '%s' AND source = '%s'" % (suite_id, source_id))
-            suite_id = daklib.database.get_suite_id('stable')
+            suite_id = database.get_suite_id('stable')
             projectB.query("INSERT INTO src_associations (suite, source) VALUES ('%s', '%s')" % (suite_id, source_id))
 
     # Add the binaries to stable (and remove it/them from proposed-updates)
@@ -503,17 +503,17 @@ def stable_install (summary, short_summary):
             q = projectB.query("SELECT b.id FROM binaries b, architecture a WHERE b.package = '%s' AND b.version = '%s' AND (a.arch_string = '%s' OR a.arch_string = 'all') AND b.architecture = a.id" % (package, version, architecture))
             ql = q.getresult()
             if not ql:
-                daklib.utils.fubar("[INTERNAL ERROR] couldn't find '%s' (%s for %s architecture) in binaries table." % (package, version, architecture))
+                utils.fubar("[INTERNAL ERROR] couldn't find '%s' (%s for %s architecture) in binaries table." % (package, version, architecture))
 
             binary_id = ql[0][0]
-            suite_id = daklib.database.get_suite_id('proposed-updates')
+            suite_id = database.get_suite_id('proposed-updates')
             projectB.query("DELETE FROM bin_associations WHERE suite = '%s' AND bin = '%s'" % (suite_id, binary_id))
-            suite_id = daklib.database.get_suite_id('stable')
+            suite_id = database.get_suite_id('stable')
             projectB.query("INSERT INTO bin_associations (suite, bin) VALUES ('%s', '%s')" % (suite_id, binary_id))
 
     projectB.query("COMMIT WORK")
 
-    daklib.utils.move (pkg.changes_file, Cnf["Dir::Morgue"] + '/process-accepted/' + os.path.basename(pkg.changes_file))
+    utils.move (pkg.changes_file, Cnf["Dir::Morgue"] + '/process-accepted/' + os.path.basename(pkg.changes_file))
 
     ## Update the Stable ChangeLog file
     new_changelog_filename = Cnf["Dir::Root"] + Cnf["Suite::Stable::ChangeLogBase"] + ".ChangeLog"
@@ -521,31 +521,31 @@ def stable_install (summary, short_summary):
     if os.path.exists(new_changelog_filename):
         os.unlink (new_changelog_filename)
 
-    new_changelog = daklib.utils.open_file(new_changelog_filename, 'w')
+    new_changelog = utils.open_file(new_changelog_filename, 'w')
     for file in files.keys():
         if files[file]["type"] == "deb":
             new_changelog.write("stable/%s/binary-%s/%s\n" % (files[file]["component"], files[file]["architecture"], file))
-        elif daklib.utils.re_issource.match(file):
+        elif utils.re_issource.match(file):
             new_changelog.write("stable/%s/source/%s\n" % (files[file]["component"], file))
         else:
             new_changelog.write("%s\n" % (file))
-    chop_changes = daklib.queue.re_fdnic.sub("\n", changes["changes"])
+    chop_changes = queue.re_fdnic.sub("\n", changes["changes"])
     new_changelog.write(chop_changes + '\n\n')
     if os.access(changelog_filename, os.R_OK) != 0:
-        changelog = daklib.utils.open_file(changelog_filename)
+        changelog = utils.open_file(changelog_filename)
         new_changelog.write(changelog.read())
     new_changelog.close()
     if os.access(changelog_filename, os.R_OK) != 0:
         os.unlink(changelog_filename)
-    daklib.utils.move(new_changelog_filename, changelog_filename)
+    utils.move(new_changelog_filename, changelog_filename)
 
     install_count += 1
 
     if not Options["No-Mail"] and changes["architecture"].has_key("source"):
         Subst["__SUITE__"] = " into stable"
         Subst["__SUMMARY__"] = summary
-        mail_message = daklib.utils.TemplateSubst(Subst,Cnf["Dir::Templates"]+"/process-accepted.install")
-        daklib.utils.send_mail(mail_message)
+        mail_message = utils.TemplateSubst(Subst,Cnf["Dir::Templates"]+"/process-accepted.install")
+        utils.send_mail(mail_message)
         Upload.announce(short_summary, 1)
 
     # Finally remove the .dak file
@@ -599,7 +599,7 @@ def main():
     # Check that we aren't going to clash with the daily cron job
 
     if not Options["No-Action"] and os.path.exists("%s/Archive_Maintenance_In_Progress" % (Cnf["Dir::Root"])) and not Options["No-Lock"]:
-        daklib.utils.fubar("Archive maintenance in progress.  Try again later.")
+        utils.fubar("Archive maintenance in progress.  Try again later.")
 
     # If running from within proposed-updates; assume an install to stable
     if os.getcwd().find('proposed-updates') != -1:
@@ -612,10 +612,10 @@ def main():
             fcntl.lockf(lock_fd, fcntl.LOCK_EX | fcntl.LOCK_NB)
         except IOError, e:
             if errno.errorcode[e.errno] == 'EACCES' or errno.errorcode[e.errno] == 'EAGAIN':
-                daklib.utils.fubar("Couldn't obtain lock; assuming another 'dak process-accepted' is already running.")
+                utils.fubar("Couldn't obtain lock; assuming another 'dak process-accepted' is already running.")
             else:
                 raise
-        Logger = Upload.Logger = daklib.logging.Logger(Cnf, "process-accepted")
+        Logger = Upload.Logger = logging.Logger(Cnf, "process-accepted")
         if not installing_to_stable and Cnf.get("Dir::UrgencyLog"):
             Urgency_Logger = Urgency_Log(Cnf)
 
@@ -627,7 +627,7 @@ def main():
         Subst["__BCC__"] = bcc
 
     # Sort the .changes files so that we process sourceful ones first
-    changes_files.sort(daklib.utils.changes_compare)
+    changes_files.sort(utils.changes_compare)
 
     # Process the changes files
     for changes_file in changes_files:
@@ -638,7 +638,7 @@ def main():
         sets = "set"
         if install_count > 1:
             sets = "sets"
-        sys.stderr.write("Installed %d package %s, %s.\n" % (install_count, sets, daklib.utils.size_type(int(install_bytes))))
+        sys.stderr.write("Installed %d package %s, %s.\n" % (install_count, sets, utils.size_type(int(install_bytes))))
         Logger.log(["total",install_count,install_bytes])
 
     if not Options["No-Action"]:
old mode 100644 (file)
new mode 100755 (executable)
index 37a902a..c13ff78
 import copy, errno, os, readline, stat, sys, time
 import apt_pkg, apt_inst
 import examine_package
-import daklib.database
-import daklib.logging
-import daklib.queue
-import daklib.utils
+import daklib.database as database
+import daklib.logging as logging
+import daklib.queue as queue
+import daklib.utils as utils
 
 # Globals
 Cnf = None
@@ -70,18 +70,18 @@ def recheck():
     files = Upload.pkg.files
     reject_message = ""
 
-    for file in files.keys():
+    for f in files.keys():
         # The .orig.tar.gz can disappear out from under us is it's a
         # duplicate of one in the archive.
-        if not files.has_key(file):
+        if not files.has_key(f):
             continue
         # Check that the source still exists
-        if files[file]["type"] == "deb":
-            source_version = files[file]["source version"]
-            source_package = files[file]["source package"]
+        if files[f]["type"] == "deb":
+            source_version = files[f]["source version"]
+            source_package = files[f]["source package"]
             if not Upload.pkg.changes["architecture"].has_key("source") \
                and not Upload.source_exists(source_package, source_version, Upload.pkg.changes["distribution"].keys()):
-                source_epochless_version = daklib.utils.re_no_epoch.sub('', source_version)
+                source_epochless_version = utils.re_no_epoch.sub('', source_version)
                 dsc_filename = "%s_%s.dsc" % (source_package, source_epochless_version)
                 found = 0
                 for q in ["Accepted", "Embargoed", "Unembargoed"]:
@@ -89,14 +89,14 @@ def recheck():
                         if os.path.exists(Cnf["Dir::Queue::%s" % (q)] + '/' + dsc_filename):
                             found = 1
                 if not found:
-                    reject("no source found for %s %s (%s)." % (source_package, source_version, file))
+                    reject("no source found for %s %s (%s)." % (source_package, source_version, f))
 
         # Version and file overwrite checks
-        if files[file]["type"] == "deb":
-            reject(Upload.check_binary_against_db(file))
-        elif files[file]["type"] == "dsc":
-            reject(Upload.check_source_against_db(file))
-            (reject_msg, is_in_incoming) = Upload.check_dsc_against_db(file)
+        if files[f]["type"] == "deb":
+            reject(Upload.check_binary_against_db(f))
+        elif files[f]["type"] == "dsc":
+            reject(Upload.check_source_against_db(f))
+            (reject_msg, is_in_incoming) = Upload.check_dsc_against_db(f)
             reject(reject_msg, "")
 
     if reject_message.find("Rejected") != -1:
@@ -108,8 +108,8 @@ def recheck():
         prompt = "[R]eject, Skip, Quit ?"
 
         while prompt.find(answer) == -1:
-            answer = daklib.utils.our_raw_input(prompt)
-            m = daklib.queue.re_default_answer.match(prompt)
+            answer = utils.our_raw_input(prompt)
+            m = queue.re_default_answer.match(prompt)
             if answer == "":
                 answer = m.group(1)
             answer = answer[:1].upper()
@@ -262,7 +262,7 @@ class Priority_Completer:
 ################################################################################
 
 def print_new (new, indexed, file=sys.stdout):
-    daklib.queue.check_valid(new)
+    queue.check_valid(new)
     broken = 0
     index = 0
     for pkg in new.keys():
@@ -301,17 +301,17 @@ def index_range (index):
 
 def edit_new (new):
     # Write the current data to a temporary file
-    temp_filename = daklib.utils.temp_filename()
-    temp_file = daklib.utils.open_file(temp_filename, 'w')
+    temp_filename = utils.temp_filename()
+    temp_file = utils.open_file(temp_filename, 'w')
     print_new (new, 0, temp_file)
     temp_file.close()
     # Spawn an editor on that file
     editor = os.environ.get("EDITOR","vi")
     result = os.system("%s %s" % (editor, temp_filename))
     if result != 0:
-        daklib.utils.fubar ("%s invocation failed for %s." % (editor, temp_filename), result)
+        utils.fubar ("%s invocation failed for %s." % (editor, temp_filename), result)
     # Read the edited data back in
-    temp_file = daklib.utils.open_file(temp_filename)
+    temp_file = utils.open_file(temp_filename)
     lines = temp_file.readlines()
     temp_file.close()
     os.unlink(temp_filename)
@@ -325,16 +325,16 @@ def edit_new (new):
         s[len(s):3] = [None] * (3-len(s))
         (pkg, priority, section) = s[:3]
         if not new.has_key(pkg):
-            daklib.utils.warn("Ignoring unknown package '%s'" % (pkg))
+            utils.warn("Ignoring unknown package '%s'" % (pkg))
         else:
             # Strip off any invalid markers, print_new will readd them.
             if section.endswith("[!]"):
                 section = section[:-3]
             if priority.endswith("[!]"):
                 priority = priority[:-3]
-            for file in new[pkg]["files"]:
-                Upload.pkg.files[file]["section"] = section
-                Upload.pkg.files[file]["priority"] = priority
+            for f in new[pkg]["files"]:
+                Upload.pkg.files[f]["section"] = section
+                Upload.pkg.files[f]["priority"] = priority
             new[pkg]["section"] = section
             new[pkg]["priority"] = priority
 
@@ -343,21 +343,21 @@ def edit_new (new):
 def edit_index (new, index):
     priority = new[index]["priority"]
     section = new[index]["section"]
-    type = new[index]["type"]
+    ftype = new[index]["type"]
     done = 0
     while not done:
         print "\t".join([index, priority, section])
 
         answer = "XXX"
-        if type != "dsc":
+        if ftype != "dsc":
             prompt = "[B]oth, Priority, Section, Done ? "
         else:
             prompt = "[S]ection, Done ? "
         edit_priority = edit_section = 0
 
         while prompt.find(answer) == -1:
-            answer = daklib.utils.our_raw_input(prompt)
-            m = daklib.queue.re_default_answer.match(prompt)
+            answer = utils.our_raw_input(prompt)
+            m = queue.re_default_answer.match(prompt)
             if answer == "":
                 answer = m.group(1)
             answer = answer[:1].upper()
@@ -376,7 +376,7 @@ def edit_index (new, index):
             readline.set_completer(Priorities.complete)
             got_priority = 0
             while not got_priority:
-                new_priority = daklib.utils.our_raw_input("New priority: ").strip()
+                new_priority = utils.our_raw_input("New priority: ").strip()
                 if new_priority not in Priorities.priorities:
                     print "E: '%s' is not a valid priority, try again." % (new_priority)
                 else:
@@ -388,7 +388,7 @@ def edit_index (new, index):
             readline.set_completer(Sections.complete)
             got_section = 0
             while not got_section:
-                new_section = daklib.utils.our_raw_input("New section: ").strip()
+                new_section = utils.our_raw_input("New section: ").strip()
                 if new_section not in Sections.sections:
                     print "E: '%s' is not a valid section, try again." % (new_section)
                 else:
@@ -398,9 +398,9 @@ def edit_index (new, index):
         # Reset the readline completer
         readline.set_completer(None)
 
-    for file in new[index]["files"]:
-        Upload.pkg.files[file]["section"] = section
-        Upload.pkg.files[file]["priority"] = priority
+    for f in new[index]["files"]:
+        Upload.pkg.files[f]["section"] = section
+        Upload.pkg.files[f]["priority"] = priority
     new[index]["priority"] = priority
     new[index]["section"] = section
     return new
@@ -422,12 +422,12 @@ def edit_overrides (new):
 
         got_answer = 0
         while not got_answer:
-            answer = daklib.utils.our_raw_input(prompt)
+            answer = utils.our_raw_input(prompt)
             if not answer.isdigit():
                 answer = answer[:1].upper()
             if answer == "E" or answer == "D":
                 got_answer = 1
-            elif daklib.queue.re_isanum.match (answer):
+            elif queue.re_isanum.match (answer):
                 answer = int(answer)
                 if (answer < 1) or (answer > index):
                     print "%s is not a valid index (%s).  Please retry." % (answer, index_range(index))
@@ -447,24 +447,24 @@ def edit_overrides (new):
 
 def edit_note(note):
     # Write the current data to a temporary file
-    temp_filename = daklib.utils.temp_filename()
-    temp_file = daklib.utils.open_file(temp_filename, 'w')
+    temp_filename = utils.temp_filename()
+    temp_file = utils.open_file(temp_filename, 'w')
     temp_file.write(note)
     temp_file.close()
     editor = os.environ.get("EDITOR","vi")
     answer = 'E'
     while answer == 'E':
         os.system("%s %s" % (editor, temp_filename))
-        temp_file = daklib.utils.open_file(temp_filename)
+        temp_file = utils.open_file(temp_filename)
         note = temp_file.read().rstrip()
         temp_file.close()
         print "Note:"
-        print daklib.utils.prefix_multi_line_string(note,"  ")
+        print utils.prefix_multi_line_string(note,"  ")
         prompt = "[D]one, Edit, Abandon, Quit ?"
         answer = "XXX"
         while prompt.find(answer) == -1:
-            answer = daklib.utils.our_raw_input(prompt)
-            m = daklib.queue.re_default_answer.search(prompt)
+            answer = utils.our_raw_input(prompt)
+            m = queue.re_default_answer.search(prompt)
             if answer == "":
                 answer = m.group(1)
             answer = answer[:1].upper()
@@ -487,23 +487,23 @@ def check_pkg ():
             sys.stdout = less_fd
             examine_package.display_changes(Upload.pkg.changes_file)
             files = Upload.pkg.files
-            for file in files.keys():
-                if files[file].has_key("new"):
-                    type = files[file]["type"]
-                    if type == "deb":
-                        examine_package.check_deb(file)
-                    elif type == "dsc":
-                        examine_package.check_dsc(file)
+            for f in files.keys():
+                if files[f].has_key("new"):
+                    ftype = files[f]["type"]
+                    if ftype == "deb":
+                        examine_package.check_deb(f)
+                    elif ftype == "dsc":
+                        examine_package.check_dsc(f)
         finally:
             sys.stdout = stdout_fd
     except IOError, e:
-        if errno.errorcode[e.errno] == 'EPIPE':
-            daklib.utils.warn("[examine_package] Caught EPIPE; skipping.")
+        if e.errno == errno.EPIPE:
+            utils.warn("[examine_package] Caught EPIPE; skipping.")
             pass
         else:
             raise
     except KeyboardInterrupt:
-        daklib.utils.warn("[examine_package] Caught C-c; skipping.")
+        utils.warn("[examine_package] Caught C-c; skipping.")
         pass
 
 ################################################################################
@@ -513,15 +513,15 @@ def check_pkg ():
 def do_bxa_notification():
     files = Upload.pkg.files
     summary = ""
-    for file in files.keys():
-        if files[file]["type"] == "deb":
-            control = apt_pkg.ParseSection(apt_inst.debExtractControl(daklib.utils.open_file(file)))
+    for f in files.keys():
+        if files[f]["type"] == "deb":
+            control = apt_pkg.ParseSection(apt_inst.debExtractControl(utils.open_file(f)))
             summary += "\n"
             summary += "Package: %s\n" % (control.Find("Package"))
             summary += "Description: %s\n" % (control.Find("Description"))
     Upload.Subst["__BINARY_DESCRIPTIONS__"] = summary
-    bxa_mail = daklib.utils.TemplateSubst(Upload.Subst,Cnf["Dir::Templates"]+"/process-new.bxa_notification")
-    daklib.utils.send_mail(bxa_mail)
+    bxa_mail = utils.TemplateSubst(Upload.Subst,Cnf["Dir::Templates"]+"/process-new.bxa_notification")
+    utils.send_mail(bxa_mail)
 
 ################################################################################
 
@@ -531,16 +531,16 @@ def add_overrides (new):
 
     projectB.query("BEGIN WORK")
     for suite in changes["suite"].keys():
-        suite_id = daklib.database.get_suite_id(suite)
+        suite_id = database.get_suite_id(suite)
         for pkg in new.keys():
-            component_id = daklib.database.get_component_id(new[pkg]["component"])
-            type_id = daklib.database.get_override_type_id(new[pkg]["type"])
+            component_id = database.get_component_id(new[pkg]["component"])
+            type_id = database.get_override_type_id(new[pkg]["type"])
             priority_id = new[pkg]["priority id"]
             section_id = new[pkg]["section id"]
             projectB.query("INSERT INTO override (suite, component, type, package, priority, section, maintainer) VALUES (%s, %s, %s, '%s', %s, %s, '')" % (suite_id, component_id, type_id, pkg, priority_id, section_id))
-            for file in new[pkg]["files"]:
-                if files[file].has_key("new"):
-                    del files[file]["new"]
+            for f in new[pkg]["files"]:
+                if files[f].has_key("new"):
+                    del files[f]["new"]
             del new[pkg]
 
     projectB.query("COMMIT WORK")
@@ -552,21 +552,21 @@ def add_overrides (new):
 
 def prod_maintainer ():
     # Here we prepare an editor and get them ready to prod...
-    temp_filename = daklib.utils.temp_filename()
+    temp_filename = utils.temp_filename()
     editor = os.environ.get("EDITOR","vi")
     answer = 'E'
     while answer == 'E':
         os.system("%s %s" % (editor, temp_filename))
-        file = daklib.utils.open_file(temp_filename)
-        prod_message = "".join(file.readlines())
-        file.close()
+        f = utils.open_file(temp_filename)
+        prod_message = "".join(f.readlines())
+        f.close()
         print "Prod message:"
-        print daklib.utils.prefix_multi_line_string(prod_message,"  ",include_blank_lines=1)
+        print utils.prefix_multi_line_string(prod_message,"  ",include_blank_lines=1)
         prompt = "[P]rod, Edit, Abandon, Quit ?"
         answer = "XXX"
         while prompt.find(answer) == -1:
-            answer = daklib.utils.our_raw_input(prompt)
-            m = daklib.queue.re_default_answer.search(prompt)
+            answer = utils.our_raw_input(prompt)
+            m = queue.re_default_answer.search(prompt)
             if answer == "":
                 answer = m.group(1)
             answer = answer[:1].upper()
@@ -577,7 +577,7 @@ def prod_maintainer ():
             end()
             sys.exit(0)
     # Otherwise, do the proding...
-    user_email_address = daklib.utils.whoami() + " <%s>" % (
+    user_email_address = utils.whoami() + " <%s>" % (
         Cnf["Dinstall::MyAdminAddress"])
 
     Subst = Upload.Subst
@@ -586,12 +586,12 @@ def prod_maintainer ():
     Subst["__PROD_MESSAGE__"] = prod_message
     Subst["__CC__"] = "Cc: " + Cnf["Dinstall::MyEmailAddress"]
 
-    prod_mail_message = daklib.utils.TemplateSubst(
+    prod_mail_message = utils.TemplateSubst(
         Subst,Cnf["Dir::Templates"]+"/process-new.prod")
 
     # Send the prod mail if appropriate
     if not Cnf["Dinstall::Options::No-Mail"]:
-        daklib.utils.send_mail(prod_mail_message)
+        utils.send_mail(prod_mail_message)
 
     print "Sent proding message"
 
@@ -609,8 +609,8 @@ def do_new():
     for suite in changes["suite"].keys():
         override = Cnf.Find("Suite::%s::OverrideSuite" % (suite))
         if override:
-            (olderr, newerr) = (daklib.database.get_suite_id(suite) == -1,
-              daklib.database.get_suite_id(override) == -1)
+            (olderr, newerr) = (database.get_suite_id(suite) == -1,
+              database.get_suite_id(override) == -1)
             if olderr or newerr:
                 (oinv, newinv) = ("", "")
                 if olderr: oinv = "invalid "
@@ -621,15 +621,15 @@ def do_new():
             changes["suite"][override] = 1
     # Validate suites
     for suite in changes["suite"].keys():
-        suite_id = daklib.database.get_suite_id(suite)
+        suite_id = database.get_suite_id(suite)
         if suite_id == -1:
-            daklib.utils.fubar("%s has invalid suite '%s' (possibly overriden).  say wha?" % (changes, suite))
+            utils.fubar("%s has invalid suite '%s' (possibly overriden).  say wha?" % (changes, suite))
 
     # The main NEW processing loop
     done = 0
     while not done:
         # Find out what's new
-        new = daklib.queue.determine_new(changes, files, projectB)
+        new = queue.determine_new(changes, files, projectB)
 
         if not new:
             break
@@ -652,8 +652,8 @@ def do_new():
         prompt += "Edit overrides, Check, Manual reject, Note edit, Prod, [S]kip, Quit ?"
 
         while prompt.find(answer) == -1:
-            answer = daklib.utils.our_raw_input(prompt)
-            m = daklib.queue.re_default_answer.search(prompt)
+            answer = utils.our_raw_input(prompt)
+            m = queue.re_default_answer.search(prompt)
             if answer == "":
                 answer = m.group(1)
             answer = answer[:1].upper()
@@ -674,7 +674,7 @@ def do_new():
         elif answer == 'P':
             prod_maintainer()
         elif answer == 'R':
-            confirm = daklib.utils.our_raw_input("Really clear note (y/N)? ").lower()
+            confirm = utils.our_raw_input("Really clear note (y/N)? ").lower()
             if confirm == "y":
                 del changes["process-new note"]
         elif answer == 'S':
@@ -702,7 +702,7 @@ def usage (exit_code=0):
 def init():
     global Cnf, Options, Logger, Upload, projectB, Sections, Priorities
 
-    Cnf = daklib.utils.get_conf()
+    Cnf = utils.get_conf()
 
     Arguments = [('a',"automatic","Process-New::Options::Automatic"),
                  ('h',"help","Process-New::Options::Help"),
@@ -720,10 +720,10 @@ def init():
     if Options["Help"]:
         usage()
 
-    Upload = daklib.queue.Upload(Cnf)
+    Upload = queue.Upload(Cnf)
 
     if not Options["No-Action"]:
-        Logger = Upload.Logger = daklib.logging.Logger(Cnf, "process-new")
+        Logger = Upload.Logger = logging.Logger(Cnf, "process-new")
 
     projectB = Upload.projectB
 
@@ -742,13 +742,13 @@ def do_byhand():
         will_install = 1
         byhand = []
 
-        for file in files.keys():
-            if files[file]["type"] == "byhand":
-                if os.path.exists(file):
-                    print "W: %s still present; please process byhand components and try again." % (file)
+        for f in files.keys():
+            if files[f]["type"] == "byhand":
+                if os.path.exists(f):
+                    print "W: %s still present; please process byhand components and try again." % (f)
                     will_install = 0
                 else:
-                    byhand.append(file)
+                    byhand.append(f)
 
         answer = "XXXX"
         if Options["No-Action"]:
@@ -761,16 +761,16 @@ def do_byhand():
             prompt = "Manual reject, [S]kip, Quit ?"
 
         while prompt.find(answer) == -1:
-            answer = daklib.utils.our_raw_input(prompt)
-            m = daklib.queue.re_default_answer.search(prompt)
+            answer = utils.our_raw_input(prompt)
+            m = queue.re_default_answer.search(prompt)
             if answer == "":
                 answer = m.group(1)
             answer = answer[:1].upper()
 
         if answer == 'A':
             done = 1
-            for file in byhand:
-                del files[file]
+            for f in byhand:
+                del files[f]
         elif answer == 'M':
             Upload.do_reject(1, Options["Manual-Reject"])
             os.unlink(Upload.pkg.changes_file[:-8]+".dak")
@@ -787,13 +787,13 @@ def get_accept_lock():
     retry = 0
     while retry < 10:
         try:
-            lock_fd = os.open(Cnf["Process-New::AcceptedLockFile"], os.O_RDONLY | os.O_CREAT | os.O_EXCL)
+            os.open(Cnf["Process-New::AcceptedLockFile"], os.O_RDONLY | os.O_CREAT | os.O_EXCL)
             retry = 10
         except OSError, e:
-            if errno.errorcode[e.errno] == 'EACCES' or errno.errorcode[e.errno] == 'EEXIST':
+            if e.errno == errno.EACCES or e.errno == errno.EEXIST:
                 retry += 1
                 if (retry >= 10):
-                    daklib.utils.fubar("Couldn't obtain lock; assuming 'dak process-unchecked' is already running.")
+                    utils.fubar("Couldn't obtain lock; assuming 'dak process-unchecked' is already running.")
                 else:
                     print("Unable to get accepted lock (try %d of 10)" % retry)
                 time.sleep(60)
@@ -801,10 +801,10 @@ def get_accept_lock():
                 raise
 
 def move_to_dir (dest, perms=0660, changesperms=0664):
-    daklib.utils.move (Upload.pkg.changes_file, dest, perms=changesperms)
+    utils.move (Upload.pkg.changes_file, dest, perms=changesperms)
     file_keys = Upload.pkg.files.keys()
-    for file in file_keys:
-        daklib.utils.move (file, dest, perms=perms)
+    for f in file_keys:
+        utils.move (f, dest, perms=perms)
 
 def do_accept():
     print "ACCEPT"
@@ -824,10 +824,10 @@ def do_accept():
 
 def check_status(files):
     new = byhand = 0
-    for file in files.keys():
-        if files[file]["type"] == "byhand":
+    for f in files.keys():
+        if files[f]["type"] == "byhand":
             byhand = 1
-        elif files[file].has_key("new"):
+        elif files[f].has_key("new"):
             new = 1
     return (new, byhand)
 
@@ -862,7 +862,7 @@ def end():
         sets = "set"
         if accept_count > 1:
             sets = "sets"
-        sys.stderr.write("Accepted %d package %s, %s.\n" % (accept_count, sets, daklib.utils.size_type(int(accept_bytes))))
+        sys.stderr.write("Accepted %d package %s, %s.\n" % (accept_count, sets, utils.size_type(int(accept_bytes))))
         Logger.log(["total",accept_count,accept_bytes])
 
     if not Options["No-Action"]:
@@ -878,7 +878,7 @@ def do_comments(dir, opref, npref, line, fn):
                                 and x.endswith(".changes") ]
         changes_files = sort_changes(changes_files)
         for f in changes_files:
-            f = daklib.utils.validate_changes_file_arg(f, 0)
+            f = utils.validate_changes_file_arg(f, 0)
             if not f: continue
             print "\n" + f
             fn(f, "".join(lines[1:]))
@@ -910,7 +910,6 @@ def comment_reject(changes_file, comments):
     Upload.init_vars()
     Upload.update_vars()
     Upload.update_subst()
-    files = Upload.pkg.files
 
     if not recheck():
         pass # dak has its own reasons to reject as well, which is fine
@@ -946,7 +945,7 @@ def main():
         do_comments(commentsdir, "REJECT.", "REJECTED.", "NOTOK", comment_reject)
     else:
         for changes_file in changes_files:
-            changes_file = daklib.utils.validate_changes_file_arg(changes_file, 0)
+            changes_file = utils.validate_changes_file_arg(changes_file, 0)
             if not changes_file:
                 continue
             print "\n" + changes_file
old mode 100644 (file)
new mode 100755 (executable)
index 6a6c52d..fbd7d74
 
 import commands, errno, fcntl, os, re, shutil, stat, sys, time, tempfile, traceback
 import apt_inst, apt_pkg
-import daklib.database
-import daklib.logging
-import daklib.queue
-import daklib.utils
+import daklib.database as database
+import daklib.logging as logging
+import daklib.queue as queue
+import daklib.utils as utils
 
 from types import *
 
@@ -73,7 +73,7 @@ def init():
     apt_pkg.init()
 
     Cnf = apt_pkg.newConfiguration()
-    apt_pkg.ReadConfigFileISC(Cnf,daklib.utils.which_conf_file())
+    apt_pkg.ReadConfigFileISC(Cnf,utils.which_conf_file())
 
     Arguments = [('a',"automatic","Dinstall::Options::Automatic"),
                  ('h',"help","Dinstall::Options::Help"),
@@ -91,7 +91,7 @@ def init():
     if Options["Help"]:
         usage()
 
-    Upload = daklib.queue.Upload(Cnf)
+    Upload = queue.Upload(Cnf)
 
     changes = Upload.pkg.changes
     dsc = Upload.pkg.dsc
@@ -164,12 +164,12 @@ def clean_holding():
 
     cwd = os.getcwd()
     os.chdir(Cnf["Dir::Queue::Holding"])
-    for file in in_holding.keys():
-        if os.path.exists(file):
-            if file.find('/') != -1:
-                daklib.utils.fubar("WTF? clean_holding() got a file ('%s') with / in it!" % (file))
+    for f in in_holding.keys():
+        if os.path.exists(f):
+            if f.find('/') != -1:
+                utils.fubar("WTF? clean_holding() got a file ('%s') with / in it!" % (f))
             else:
-                os.unlink(file)
+                os.unlink(f)
     in_holding = {}
     os.chdir(cwd)
 
@@ -180,20 +180,20 @@ def check_changes():
 
     # Parse the .changes field into a dictionary
     try:
-        changes.update(daklib.utils.parse_changes(filename))
-    except daklib.utils.cant_open_exc:
+        changes.update(utils.parse_changes(filename))
+    except utils.cant_open_exc:
         reject("%s: can't read file." % (filename))
         return 0
-    except daklib.utils.changes_parse_error_exc, line:
+    except utils.changes_parse_error_exc, line:
         reject("%s: parse error, can't grok: %s." % (filename, line))
         return 0
 
     # Parse the Files field from the .changes into another dictionary
     try:
-        files.update(daklib.utils.build_file_list(changes))
-    except daklib.utils.changes_parse_error_exc, line:
+        files.update(utils.build_file_list(changes))
+    except utils.changes_parse_error_exc, line:
         reject("%s: parse error, can't grok: %s." % (filename, line))
-    except daklib.utils.nk_format_exc, format:
+    except utils.nk_format_exc, format:
         reject("%s: unknown format '%s'." % (filename, format))
         return 0
 
@@ -225,8 +225,8 @@ def check_changes():
     try:
         (changes["maintainer822"], changes["maintainer2047"],
          changes["maintainername"], changes["maintaineremail"]) = \
-         daklib.utils.fix_maintainer (changes["maintainer"])
-    except daklib.utils.ParseMaintError, msg:
+         utils.fix_maintainer (changes["maintainer"])
+    except utils.ParseMaintError, msg:
         reject("%s: Maintainer field ('%s') failed to parse: %s" \
                % (filename, changes["maintainer"], msg))
 
@@ -234,8 +234,8 @@ def check_changes():
     try:
         (changes["changedby822"], changes["changedby2047"],
          changes["changedbyname"], changes["changedbyemail"]) = \
-         daklib.utils.fix_maintainer (changes.get("changed-by", ""))
-    except daklib.utils.ParseMaintError, msg:
+         utils.fix_maintainer (changes.get("changed-by", ""))
+    except utils.ParseMaintError, msg:
         (changes["changedby822"], changes["changedby2047"],
          changes["changedbyname"], changes["changedbyemail"]) = \
          ("", "", "", "")
@@ -245,20 +245,20 @@ def check_changes():
     # Ensure all the values in Closes: are numbers
     if changes.has_key("closes"):
         for i in changes["closes"].keys():
-            if daklib.queue.re_isanum.match (i) == None:
+            if queue.re_isanum.match (i) == None:
                 reject("%s: `%s' from Closes field isn't a number." % (filename, i))
 
 
     # chopversion = no epoch; chopversion2 = no epoch and no revision (e.g. for .orig.tar.gz comparison)
-    changes["chopversion"] = daklib.utils.re_no_epoch.sub('', changes["version"])
-    changes["chopversion2"] = daklib.utils.re_no_revision.sub('', changes["chopversion"])
+    changes["chopversion"] = utils.re_no_epoch.sub('', changes["version"])
+    changes["chopversion2"] = utils.re_no_revision.sub('', changes["chopversion"])
 
     # Check there isn't already a changes file of the same name in one
     # of the queue directories.
     base_filename = os.path.basename(filename)
-    for dir in [ "Accepted", "Byhand", "Done", "New", "ProposedUpdates", "OldProposedUpdates" ]:
-        if os.path.exists(Cnf["Dir::Queue::%s" % (dir) ]+'/'+base_filename):
-            reject("%s: a file with this name already exists in the %s directory." % (base_filename, dir))
+    for d in [ "Accepted", "Byhand", "Done", "New", "ProposedUpdates", "OldProposedUpdates" ]:
+        if os.path.exists(Cnf["Dir::Queue::%s" % (d) ]+'/'+base_filename):
+            reject("%s: a file with this name already exists in the %s directory." % (base_filename, d))
 
     # Check the .changes is non-empty
     if not files:
@@ -273,20 +273,20 @@ def check_distributions():
     "Check and map the Distribution field of a .changes file."
 
     # Handle suite mappings
-    for map in Cnf.ValueList("SuiteMappings"):
-        args = map.split()
-        type = args[0]
-        if type == "map" or type == "silent-map":
+    for m in Cnf.ValueList("SuiteMappings"):
+        args = m.split()
+        mtype = args[0]
+        if mtype == "map" or mtype == "silent-map":
             (source, dest) = args[1:3]
             if changes["distribution"].has_key(source):
                 del changes["distribution"][source]
                 changes["distribution"][dest] = 1
-                if type != "silent-map":
+                if mtype != "silent-map":
                     reject("Mapping %s to %s." % (source, dest),"")
             if changes.has_key("distribution-version"):
                 if changes["distribution-version"].has_key(source):
                     changes["distribution-version"][source]=dest
-        elif type == "map-unreleased":
+        elif mtype == "map-unreleased":
             (source, dest) = args[1:3]
             if changes["distribution"].has_key(source):
                 for arch in changes["architecture"].keys():
@@ -295,16 +295,16 @@ def check_distributions():
                         del changes["distribution"][source]
                         changes["distribution"][dest] = 1
                         break
-        elif type == "ignore":
+        elif mtype == "ignore":
             suite = args[1]
             if changes["distribution"].has_key(suite):
                 del changes["distribution"][suite]
                 reject("Ignoring %s as a target suite." % (suite), "Warning: ")
-        elif type == "reject":
+        elif mtype == "reject":
             suite = args[1]
             if changes["distribution"].has_key(suite):
                 reject("Uploads to %s are not accepted." % (suite))
-        elif type == "propup-version":
+        elif mtype == "propup-version":
             # give these as "uploaded-to(non-mapped) suites-to-add-when-upload-obsoletes"
             #
             # changes["distribution-version"] looks like: {'testing': 'testing-proposed-updates'}
@@ -323,7 +323,7 @@ def check_distributions():
 
 ################################################################################
 
-def check_deb_ar(filename, control):
+def check_deb_ar(filename):
     """Sanity check the ar of a .deb, i.e. that there is:
 
  o debian-binary
@@ -335,7 +335,7 @@ in that order, and nothing else."""
     (result, output) = commands.getstatusoutput(cmd)
     if result != 0:
         reject("%s: 'ar t' invocation failed." % (filename))
-        reject(daklib.utils.prefix_multi_line_string(output, " [ar output:] "), "")
+        reject(utils.prefix_multi_line_string(output, " [ar output:] "), "")
     chunks = output.split('\n')
     if len(chunks) != 3:
         reject("%s: found %d chunks, expected 3." % (filename, len(chunks)))
@@ -351,7 +351,7 @@ in that order, and nothing else."""
 def check_files():
     global reprocess
 
-    archive = daklib.utils.where_am_i()
+    archive = utils.where_am_i()
     file_keys = files.keys()
 
     # if reprocess is 2 we've already done this and we're checking
@@ -360,8 +360,8 @@ def check_files():
     if not Options["No-Action"] and reprocess < 2:
         cwd = os.getcwd()
         os.chdir(pkg.directory)
-        for file in file_keys:
-            copy_to_holding(file)
+        for f in file_keys:
+            copy_to_holding(f)
         os.chdir(cwd)
 
     # Check there isn't already a .changes or .dak file of the same name in
@@ -386,40 +386,40 @@ def check_files():
     has_binaries = 0
     has_source = 0
 
-    for file in file_keys:
+    for f in file_keys:
         # Ensure the file does not already exist in one of the accepted directories
-        for dir in [ "Accepted", "Byhand", "New", "ProposedUpdates", "OldProposedUpdates", "Embargoed", "Unembargoed" ]:
-            if not Cnf.has_key("Dir::Queue::%s" % (dir)): continue
-            if os.path.exists(Cnf["Dir::Queue::%s" % (dir) ]+'/'+file):
-                reject("%s file already exists in the %s directory." % (file, dir))
-        if not daklib.utils.re_taint_free.match(file):
-            reject("!!WARNING!! tainted filename: '%s'." % (file))
+        for d in [ "Accepted", "Byhand", "New", "ProposedUpdates", "OldProposedUpdates", "Embargoed", "Unembargoed" ]:
+            if not Cnf.has_key("Dir::Queue::%s" % (d)): continue
+            if os.path.exists(Cnf["Dir::Queue::%s" % (d) ] + '/' + f):
+                reject("%s file already exists in the %s directory." % (f, d))
+        if not utils.re_taint_free.match(f):
+            reject("!!WARNING!! tainted filename: '%s'." % (f))
         # Check the file is readable
-        if os.access(file,os.R_OK) == 0:
+        if os.access(fos.R_OK) == 0:
             # When running in -n, copy_to_holding() won't have
             # generated the reject_message, so we need to.
             if Options["No-Action"]:
-                if os.path.exists(file):
-                    reject("Can't read `%s'. [permission denied]" % (file))
+                if os.path.exists(f):
+                    reject("Can't read `%s'. [permission denied]" % (f))
                 else:
-                    reject("Can't read `%s'. [file not found]" % (file))
-            files[file]["type"] = "unreadable"
+                    reject("Can't read `%s'. [file not found]" % (f))
+            files[f]["type"] = "unreadable"
             continue
         # If it's byhand skip remaining checks
-        if files[file]["section"] == "byhand" or files[file]["section"][:4] == "raw-":
-            files[file]["byhand"] = 1
-            files[file]["type"] = "byhand"
+        if files[f]["section"] == "byhand" or files[f]["section"][:4] == "raw-":
+            files[f]["byhand"] = 1
+            files[f]["type"] = "byhand"
         # Checks for a binary package...
-        elif daklib.utils.re_isadeb.match(file):
+        elif utils.re_isadeb.match(f):
             has_binaries = 1
-            files[file]["type"] = "deb"
+            files[f]["type"] = "deb"
 
             # Extract package control information
-            deb_file = daklib.utils.open_file(file)
+            deb_file = utils.open_file(f)
             try:
                 control = apt_pkg.ParseSection(apt_inst.debExtractControl(deb_file))
             except:
-                reject("%s: debExtractControl() raised %s." % (file, sys.exc_type))
+                reject("%s: debExtractControl() raised %s." % (f, sys.exc_type))
                 deb_file.close()
                 # Can't continue, none of the checks on control would work.
                 continue
@@ -428,23 +428,23 @@ def check_files():
             # Check for mandatory fields
             for field in [ "Package", "Architecture", "Version" ]:
                 if control.Find(field) == None:
-                    reject("%s: No %s field in control." % (file, field))
+                    reject("%s: No %s field in control." % (f, field))
                     # Can't continue
                     continue
 
             # Ensure the package name matches the one give in the .changes
             if not changes["binary"].has_key(control.Find("Package", "")):
-                reject("%s: control file lists name as `%s', which isn't in changes file." % (file, control.Find("Package", "")))
+                reject("%s: control file lists name as `%s', which isn't in changes file." % (f, control.Find("Package", "")))
 
             # Validate the package field
             package = control.Find("Package")
             if not re_valid_pkg_name.match(package):
-                reject("%s: invalid package name '%s'." % (file, package))
+                reject("%s: invalid package name '%s'." % (f, package))
 
             # Validate the version field
             version = control.Find("Version")
             if not re_valid_version.match(version):
-                reject("%s: invalid version number '%s'." % (file, version))
+                reject("%s: invalid version number '%s'." % (f, version))
 
             # Ensure the architecture of the .deb is one we know about.
             default_suite = Cnf.get("Dinstall::DefaultSuite", "Unstable")
@@ -455,86 +455,86 @@ def check_files():
             # Ensure the architecture of the .deb is one of the ones
             # listed in the .changes.
             if not changes["architecture"].has_key(architecture):
-                reject("%s: control file lists arch as `%s', which isn't in changes file." % (file, architecture))
+                reject("%s: control file lists arch as `%s', which isn't in changes file." % (f, architecture))
 
             # Sanity-check the Depends field
             depends = control.Find("Depends")
             if depends == '':
-                reject("%s: Depends field is empty." % (file))
+                reject("%s: Depends field is empty." % (f))
 
             # Sanity-check the Provides field
             provides = control.Find("Provides")
             if provides:
                 provide = re_spacestrip.sub('', provides)
                 if provide == '':
-                    reject("%s: Provides field is empty." % (file))
+                    reject("%s: Provides field is empty." % (f))
                 prov_list = provide.split(",")
                 for prov in prov_list:
                     if not re_valid_pkg_name.match(prov):
-                        reject("%s: Invalid Provides field content %s." % (file, prov))
+                        reject("%s: Invalid Provides field content %s." % (f, prov))
 
 
             # Check the section & priority match those given in the .changes (non-fatal)
-            if control.Find("Section") and files[file]["section"] != "" and files[file]["section"] != control.Find("Section"):
-                reject("%s control file lists section as `%s', but changes file has `%s'." % (file, control.Find("Section", ""), files[file]["section"]), "Warning: ")
-            if control.Find("Priority") and files[file]["priority"] != "" and files[file]["priority"] != control.Find("Priority"):
-                reject("%s control file lists priority as `%s', but changes file has `%s'." % (file, control.Find("Priority", ""), files[file]["priority"]),"Warning: ")
-
-            files[file]["package"] = package
-            files[file]["architecture"] = architecture
-            files[file]["version"] = version
-            files[file]["maintainer"] = control.Find("Maintainer", "")
-            if file.endswith(".udeb"):
-                files[file]["dbtype"] = "udeb"
-            elif file.endswith(".deb"):
-                files[file]["dbtype"] = "deb"
+            if control.Find("Section") and files[f]["section"] != "" and files[f]["section"] != control.Find("Section"):
+                reject("%s control file lists section as `%s', but changes file has `%s'." % (f, control.Find("Section", ""), files[f]["section"]), "Warning: ")
+            if control.Find("Priority") and files[f]["priority"] != "" and files[f]["priority"] != control.Find("Priority"):
+                reject("%s control file lists priority as `%s', but changes file has `%s'." % (f, control.Find("Priority", ""), files[f]["priority"]),"Warning: ")
+
+            files[f]["package"] = package
+            files[f]["architecture"] = architecture
+            files[f]["version"] = version
+            files[f]["maintainer"] = control.Find("Maintainer", "")
+            if f.endswith(".udeb"):
+                files[f]["dbtype"] = "udeb"
+            elif f.endswith(".deb"):
+                files[f]["dbtype"] = "deb"
             else:
-                reject("%s is neither a .deb or a .udeb." % (file))
-            files[file]["source"] = control.Find("Source", files[file]["package"])
+                reject("%s is neither a .deb or a .udeb." % (f))
+            files[f]["source"] = control.Find("Source", files[f]["package"])
             # Get the source version
-            source = files[file]["source"]
+            source = files[f]["source"]
             source_version = ""
             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)
                 source_version = m.group(2)
             if not source_version:
-                source_version = files[file]["version"]
-            files[file]["source package"] = source
-            files[file]["source version"] = source_version
+                source_version = files[f]["version"]
+            files[f]["source package"] = source
+            files[f]["source version"] = source_version
 
             # Ensure the filename matches the contents of the .deb
-            m = daklib.utils.re_isadeb.match(file)
+            m = utils.re_isadeb.match(f)
             #  package name
             file_package = m.group(1)
-            if files[file]["package"] != file_package:
-                reject("%s: package part of filename (%s) does not match package name in the %s (%s)." % (file, file_package, files[file]["dbtype"], files[file]["package"]))
-            epochless_version = daklib.utils.re_no_epoch.sub('', control.Find("Version"))
+            if files[f]["package"] != file_package:
+                reject("%s: package part of filename (%s) does not match package name in the %s (%s)." % (f, file_package, files[f]["dbtype"], files[f]["package"]))
+            epochless_version = utils.re_no_epoch.sub('', control.Find("Version"))
             #  version
             file_version = m.group(2)
             if epochless_version != file_version:
-                reject("%s: version part of filename (%s) does not match package version in the %s (%s)." % (file, file_version, files[file]["dbtype"], epochless_version))
+                reject("%s: version part of filename (%s) does not match package version in the %s (%s)." % (f, file_version, files[f]["dbtype"], epochless_version))
             #  architecture
             file_architecture = m.group(3)
-            if files[file]["architecture"] != file_architecture:
-                reject("%s: architecture part of filename (%s) does not match package architecture in the %s (%s)." % (file, file_architecture, files[file]["dbtype"], files[file]["architecture"]))
+            if files[f]["architecture"] != file_architecture:
+                reject("%s: architecture part of filename (%s) does not match package architecture in the %s (%s)." % (f, file_architecture, files[f]["dbtype"], files[f]["architecture"]))
 
             # Check for existent source
-            source_version = files[file]["source version"]
-            source_package = files[file]["source package"]
+            source_version = files[f]["source version"]
+            source_package = files[f]["source package"]
             if changes["architecture"].has_key("source"):
                 if source_version != changes["version"]:
-                    reject("source version (%s) for %s doesn't match changes version %s." % (source_version, file, changes["version"]))
+                    reject("source version (%s) for %s doesn't match changes version %s." % (source_version, f, changes["version"]))
             else:
                 # Check in the SQL database
                 if not Upload.source_exists(source_package, source_version, changes["distribution"].keys()):
                     # Check in one of the other directories
-                    source_epochless_version = daklib.utils.re_no_epoch.sub('', source_version)
+                    source_epochless_version = utils.re_no_epoch.sub('', source_version)
                     dsc_filename = "%s_%s.dsc" % (source_package, source_epochless_version)
                     if os.path.exists(Cnf["Dir::Queue::Byhand"] + '/' + dsc_filename):
-                        files[file]["byhand"] = 1
+                        files[f]["byhand"] = 1
                     elif os.path.exists(Cnf["Dir::Queue::New"] + '/' + dsc_filename):
-                        files[file]["new"] = 1
+                        files[f]["new"] = 1
                     else:
                         dsc_file_exists = 0
                         for myq in ["Accepted", "Embargoed", "Unembargoed", "ProposedUpdates", "OldProposedUpdates"]:
@@ -543,98 +543,98 @@ def check_files():
                                     dsc_file_exists = 1
                                     break
                         if not dsc_file_exists:
-                            reject("no source found for %s %s (%s)." % (source_package, source_version, file))
+                            reject("no source found for %s %s (%s)." % (source_package, source_version, f))
             # Check the version and for file overwrites
-            reject(Upload.check_binary_against_db(file),"")
+            reject(Upload.check_binary_against_db(f),"")
 
-            check_deb_ar(file, control)
+            check_deb_ar(f)
 
         # Checks for a source package...
         else:
-            m = daklib.utils.re_issource.match(file)
+            m = utils.re_issource.match(f)
             if m:
                 has_source = 1
-                files[file]["package"] = m.group(1)
-                files[file]["version"] = m.group(2)
-                files[file]["type"] = m.group(3)
+                files[f]["package"] = m.group(1)
+                files[f]["version"] = m.group(2)
+                files[f]["type"] = m.group(3)
 
                 # Ensure the source package name matches the Source filed in the .changes
-                if changes["source"] != files[file]["package"]:
-                    reject("%s: changes file doesn't say %s for Source" % (file, files[file]["package"]))
+                if changes["source"] != files[f]["package"]:
+                    reject("%s: changes file doesn't say %s for Source" % (f, files[f]["package"]))
 
                 # Ensure the source version matches the version in the .changes file
-                if files[file]["type"] == "orig.tar.gz":
+                if files[f]["type"] == "orig.tar.gz":
                     changes_version = changes["chopversion2"]
                 else:
                     changes_version = changes["chopversion"]
-                if changes_version != files[file]["version"]:
-                    reject("%s: should be %s according to changes file." % (file, changes_version))
+                if changes_version != files[f]["version"]:
+                    reject("%s: should be %s according to changes file." % (f, changes_version))
 
                 # Ensure the .changes lists source in the Architecture field
                 if not changes["architecture"].has_key("source"):
-                    reject("%s: changes file doesn't list `source' in Architecture field." % (file))
+                    reject("%s: changes file doesn't list `source' in Architecture field." % (f))
 
                 # Check the signature of a .dsc file
-                if files[file]["type"] == "dsc":
-                    dsc["fingerprint"] = daklib.utils.check_signature(file, reject)
+                if files[f]["type"] == "dsc":
+                    dsc["fingerprint"] = utils.check_signature(f, reject)
 
-                files[file]["architecture"] = "source"
+                files[f]["architecture"] = "source"
 
             # Not a binary or source package?  Assume byhand...
             else:
-                files[file]["byhand"] = 1
-                files[file]["type"] = "byhand"
+                files[f]["byhand"] = 1
+                files[f]["type"] = "byhand"
 
         # Per-suite file checks
-        files[file]["oldfiles"] = {}
+        files[f]["oldfiles"] = {}
         for suite in changes["distribution"].keys():
             # Skip byhand
-            if files[file].has_key("byhand"):
+            if files[f].has_key("byhand"):
                 continue
 
             # Handle component mappings
-            for map in Cnf.ValueList("ComponentMappings"):
-                (source, dest) = map.split()
-                if files[file]["component"] == source:
-                    files[file]["original component"] = source
-                    files[file]["component"] = dest
+            for m in Cnf.ValueList("ComponentMappings"):
+                (source, dest) = m.split()
+                if files[f]["component"] == source:
+                    files[f]["original component"] = source
+                    files[f]["component"] = dest
 
             # Ensure the component is valid for the target suite
             if Cnf.has_key("Suite:%s::Components" % (suite)) and \
-               files[file]["component"] not in Cnf.ValueList("Suite::%s::Components" % (suite)):
-                reject("unknown component `%s' for suite `%s'." % (files[file]["component"], suite))
+               files[f]["component"] not in Cnf.ValueList("Suite::%s::Components" % (suite)):
+                reject("unknown component `%s' for suite `%s'." % (files[f]["component"], suite))
                 continue
 
             # Validate the component
-            component = files[file]["component"]
-            component_id = daklib.database.get_component_id(component)
+            component = files[f]["component"]
+            component_id = database.get_component_id(component)
             if component_id == -1:
-                reject("file '%s' has unknown component '%s'." % (file, component))
+                reject("file '%s' has unknown component '%s'." % (f, component))
                 continue
 
             # See if the package is NEW
-            if not Upload.in_override_p(files[file]["package"], files[file]["component"], suite, files[file].get("dbtype",""), file):
-                files[file]["new"] = 1
+            if not Upload.in_override_p(files[f]["package"], files[f]["component"], suite, files[f].get("dbtype",""), f):
+                files[f]["new"] = 1
 
             # Validate the priority
-            if files[file]["priority"].find('/') != -1:
-                reject("file '%s' has invalid priority '%s' [contains '/']." % (file, files[file]["priority"]))
+            if files[f]["priority"].find('/') != -1:
+                reject("file '%s' has invalid priority '%s' [contains '/']." % (f, files[f]["priority"]))
 
             # Determine the location
             location = Cnf["Dir::Pool"]
-            location_id = daklib.database.get_location_id (location, component, archive)
+            location_id = database.get_location_id (location, component, archive)
             if location_id == -1:
                 reject("[INTERNAL ERROR] couldn't determine location (Component: %s, Archive: %s)" % (component, archive))
-            files[file]["location id"] = location_id
+            files[f]["location id"] = location_id
 
             # Check the md5sum & size against existing files (if any)
-            files[file]["pool name"] = daklib.utils.poolify (changes["source"], files[file]["component"])
-            files_id = daklib.database.get_files_id(files[file]["pool name"] + file, files[file]["size"], files[file]["md5sum"], files[file]["location id"])
+            files[f]["pool name"] = utils.poolify (changes["source"], files[f]["component"])
+            files_id = database.get_files_id(files[f]["pool name"] + f, files[f]["size"], files[f]["md5sum"], files[f]["location id"])
             if files_id == -1:
-                reject("INTERNAL ERROR, get_files_id() returned multiple matches for %s." % (file))
+                reject("INTERNAL ERROR, get_files_id() returned multiple matches for %s." % (f))
             elif files_id == -2:
-                reject("md5sum and/or size mismatch on existing copy of %s." % (file))
-            files[file]["files id"] = files_id
+                reject("md5sum and/or size mismatch on existing copy of %s." % (f))
+            files[f]["files id"] = files_id
 
             # Check for packages that have moved from one component to another
             q = Upload.projectB.query("""
@@ -644,11 +644,11 @@ SELECT c.name FROM binaries b, bin_associations ba, suite s, location l,
    AND (a.arch_string = '%s' OR a.arch_string = 'all')
    AND ba.bin = b.id AND ba.suite = s.id AND b.architecture = a.id
    AND f.location = l.id AND l.component = c.id AND b.file = f.id"""
-                               % (files[file]["package"], suite,
-                                  files[file]["architecture"]))
+                               % (files[f]["package"], suite,
+                                  files[f]["architecture"]))
             ql = q.getresult()
             if ql:
-                files[file]["othercomponents"] = ql[0][0]
+                files[f]["othercomponents"] = ql[0][0]
 
     # If the .changes file says it has source, it must have source.
     if changes["architecture"].has_key("source"):
@@ -669,13 +669,13 @@ def check_dsc():
 
     # Find the .dsc
     dsc_filename = None
-    for file in files.keys():
-        if files[file]["type"] == "dsc":
+    for f in files.keys():
+        if files[f]["type"] == "dsc":
             if dsc_filename:
                 reject("can not process a .changes file with multiple .dsc's.")
                 return 0
             else:
-                dsc_filename = file
+                dsc_filename = f
 
     # If there isn't one, we have nothing to do. (We have reject()ed the upload already)
     if not dsc_filename:
@@ -684,22 +684,22 @@ def check_dsc():
 
     # Parse the .dsc file
     try:
-        dsc.update(daklib.utils.parse_changes(dsc_filename, signing_rules=1))
-    except daklib.utils.cant_open_exc:
+        dsc.update(utils.parse_changes(dsc_filename, signing_rules=1))
+    except utils.cant_open_exc:
         # if not -n copy_to_holding() will have done this for us...
         if Options["No-Action"]:
             reject("%s: can't read file." % (dsc_filename))
-    except daklib.utils.changes_parse_error_exc, line:
+    except utils.changes_parse_error_exc, line:
         reject("%s: parse error, can't grok: %s." % (dsc_filename, line))
-    except daklib.utils.invalid_dsc_format_exc, line:
+    except utils.invalid_dsc_format_exc, line:
         reject("%s: syntax error on line %s." % (dsc_filename, line))
     # Build up the file list of files mentioned by the .dsc
     try:
-        dsc_files.update(daklib.utils.build_file_list(dsc, is_a_dsc=1))
-    except daklib.utils.no_files_exc:
+        dsc_files.update(utils.build_file_list(dsc, is_a_dsc=1))
+    except utils.no_files_exc:
         reject("%s: no Files: field." % (dsc_filename))
         return 0
-    except daklib.utils.changes_parse_error_exc, line:
+    except utils.changes_parse_error_exc, line:
         reject("%s: parse error, can't grok: %s." % (dsc_filename, line))
         return 0
 
@@ -722,8 +722,8 @@ def check_dsc():
 
     # Validate the Maintainer field
     try:
-        daklib.utils.fix_maintainer (dsc["maintainer"])
-    except daklib.utils.ParseMaintError, msg:
+        utils.fix_maintainer (dsc["maintainer"])
+    except utils.ParseMaintError, msg:
         reject("%s: Maintainer field ('%s') failed to parse: %s" \
                % (dsc_filename, dsc["maintainer"], msg))
 
@@ -743,7 +743,7 @@ def check_dsc():
                 pass
 
     # Ensure the version number in the .dsc matches the version number in the .changes
-    epochless_dsc_version = daklib.utils.re_no_epoch.sub('', dsc["version"])
+    epochless_dsc_version = utils.re_no_epoch.sub('', dsc["version"])
     changes_version = files[dsc_filename]["version"]
     if epochless_dsc_version != files[dsc_filename]["version"]:
         reject("version ('%s') in .dsc does not match version ('%s') in .changes." % (epochless_dsc_version, changes_version))
@@ -751,12 +751,12 @@ def check_dsc():
     # Ensure there is a .tar.gz in the .dsc file
     has_tar = 0
     for f in dsc_files.keys():
-        m = daklib.utils.re_issource.match(f)
+        m = utils.re_issource.match(f)
         if not m:
             reject("%s: %s in Files field not recognised as source." % (dsc_filename, f))
             continue
-        type = m.group(3)
-        if type == "orig.tar.gz" or type == "tar.gz":
+        ftype = m.group(3)
+        if ftype == "orig.tar.gz" or ftype == "tar.gz":
             has_tar = 1
     if not has_tar:
         reject("%s: no .tar.gz or .orig.tar.gz in 'Files' field." % (dsc_filename))
@@ -789,9 +789,9 @@ def get_changelog_versions(source_dir):
 
     # Find the .dsc (again)
     dsc_filename = None
-    for file in files.keys():
-        if files[file]["type"] == "dsc":
-            dsc_filename = file
+    for f in files.keys():
+        if files[f]["type"] == "dsc":
+            dsc_filename = f
 
     # If there isn't one, we have nothing to do. (We have reject()ed the upload already)
     if not dsc_filename:
@@ -799,14 +799,14 @@ def get_changelog_versions(source_dir):
 
     # Create a symlink mirror of the source files in our temporary directory
     for f in files.keys():
-        m = daklib.utils.re_issource.match(f)
+        m = utils.re_issource.match(f)
         if m:
             src = os.path.join(source_dir, f)
             # If a file is missing for whatever reason, give up.
             if not os.path.exists(src):
                 return
-            type = m.group(3)
-            if type == "orig.tar.gz" and pkg.orig_tar_gz:
+            ftype = m.group(3)
+            if ftype == "orig.tar.gz" and pkg.orig_tar_gz:
                 continue
             dest = os.path.join(os.getcwd(), f)
             os.symlink(src, dest)
@@ -822,14 +822,14 @@ def get_changelog_versions(source_dir):
     (result, output) = commands.getstatusoutput(cmd)
     if (result != 0):
         reject("'dpkg-source -x' failed for %s [return code: %s]." % (dsc_filename, result))
-        reject(daklib.utils.prefix_multi_line_string(output, " [dpkg-source output:] "), "")
+        reject(utils.prefix_multi_line_string(output, " [dpkg-source output:] "), "")
         return
 
     if not Cnf.Find("Dir::Queue::BTSVersionTrack"):
         return
 
     # Get the upstream version
-    upstr_version = daklib.utils.re_no_epoch.sub('', dsc["version"])
+    upstr_version = utils.re_no_epoch.sub('', dsc["version"])
     if re_strip_revision.search(upstr_version):
         upstr_version = re_strip_revision.sub('', upstr_version)
 
@@ -841,7 +841,7 @@ def get_changelog_versions(source_dir):
 
     # Parse the changelog
     dsc["bts changelog"] = ""
-    changelog_file = daklib.utils.open_file(changelog_filename)
+    changelog_file = utils.open_file(changelog_filename)
     for line in changelog_file.readlines():
         m = re_changelog_versions.match(line)
         if m:
@@ -865,11 +865,11 @@ def check_source():
 
     # Create a temporary directory to extract the source into
     if Options["No-Action"]:
-        tmpdir = tempfile.mktemp()
+        tmpdir = tempfile.mkdtemp()
     else:
         # We're in queue/holding and can create a random directory.
         tmpdir = "%s" % (os.getpid())
-    os.mkdir(tmpdir)
+        os.mkdir(tmpdir)
 
     # Move into the temporary directory
     cwd = os.getcwd()
@@ -884,7 +884,7 @@ def check_source():
         shutil.rmtree(tmpdir)
     except OSError, e:
         if errno.errorcode[e.errno] != 'EACCES':
-            daklib.utils.fubar("%s: couldn't remove tmp dir for source tree." % (dsc["source"]))
+            utils.fubar("%s: couldn't remove tmp dir for source tree." % (dsc["source"]))
 
         reject("%s: source tree could not be cleanly removed." % (dsc["source"]))
         # We probably have u-r or u-w directories so chmod everything
@@ -892,10 +892,10 @@ def check_source():
         cmd = "chmod -R u+rwx %s" % (tmpdir)
         result = os.system(cmd)
         if result != 0:
-            daklib.utils.fubar("'%s' failed with result %s." % (cmd, result))
+            utils.fubar("'%s' failed with result %s." % (cmd, result))
         shutil.rmtree(tmpdir)
     except:
-        daklib.utils.fubar("%s: couldn't remove tmp dir for source tree." % (dsc["source"]))
+        utils.fubar("%s: couldn't remove tmp dir for source tree." % (dsc["source"]))
 
 ################################################################################
 
@@ -943,50 +943,50 @@ def check_hashes ():
 
     for h,f in hashes:
         try:
-            fs = daklib.utils.build_file_list(changes, 0, "checksums-%s" % h, h)
+            fs = utils.build_file_list(changes, 0, "checksums-%s" % h, h)
             check_hash(".changes %s" % (h), fs, h, f, files)
-        except daklib.utils.no_files_exc:
+        except utils.no_files_exc:
             reject("No Checksums-%s: field in .changes" % (h))
-        except daklib.utils.changes_parse_error_exc, line:
+        except utils.changes_parse_error_exc, line:
             reject("parse error for Checksums-%s in .changes, can't grok: %s." % (h, line))
 
         if "source" not in changes["architecture"]: continue
 
         try:
-            fs = daklib.utils.build_file_list(dsc, 1, "checksums-%s" % h, h)
+            fs = utils.build_file_list(dsc, 1, "checksums-%s" % h, h)
             check_hash(".dsc %s" % (h), fs, h, f, dsc_files)
-        except daklib.utils.no_files_exc:
+        except utils.no_files_exc:
             reject("No Checksums-%s: field in .dsc" % (h))
-        except daklib.utils.changes_parse_error_exc, line:
+        except utils.changes_parse_error_exc, line:
             reject("parse error for Checksums-%s in .dsc, can't grok: %s." % (h, line))
 
 ################################################################################
 
-def check_hash (where, files, key, testfn, basedict = None):
+def check_hash (where, lfiles, key, testfn, basedict = None):
     if basedict:
-        for file in basedict.keys():
-            if file not in files:
-                reject("%s: no %s checksum" % (file, key))
+        for f in basedict.keys():
+            if f not in lfiles:
+                reject("%s: no %s checksum" % (f, key))
 
-    for file in files.keys():
-        if basedict and file not in basedict:
-            reject("%s: extraneous entry in %s checksums" % (file, key))
+    for f in lfiles.keys():
+        if basedict and f not in basedict:
+            reject("%s: extraneous entry in %s checksums" % (f, key))
 
         try:
-            file_handle = daklib.utils.open_file(file)
-        except daklib.utils.cant_open_exc:
+            file_handle = utils.open_file(f)
+        except utils.cant_open_exc:
             continue
 
         # Check hash
-        if testfn(file_handle) != files[file][key]:
-            reject("%s: %s check failed." % (file, key))
+        if testfn(file_handle) != lfiles[f][key]:
+            reject("%s: %s check failed." % (f, key))
         file_handle.close()
         # Check size
-        actual_size = os.stat(file)[stat.ST_SIZE]
-        size = int(files[file]["size"])
+        actual_size = os.stat(f)[stat.ST_SIZE]
+        size = int(lfiles[f]["size"])
         if size != actual_size:
             reject("%s: actual file size (%s) does not match size (%s) in %s"
-                   % (file, actual_size, size, where))
+                   % (f, actual_size, size, where))
 
 ################################################################################
 
@@ -1019,7 +1019,7 @@ def check_timestamps():
         if files[filename]["type"] == "deb":
             tar.reset()
             try:
-                deb_file = daklib.utils.open_file(filename)
+                deb_file = utils.open_file(filename)
                 apt_inst.debExtract(deb_file,tar.callback,"control.tar.gz")
                 deb_file.seek(0)
                 try:
@@ -1090,8 +1090,8 @@ def check_signed_by_key():
     else:
         sponsored = 1
         if ("source" in changes["architecture"] and
-            uid_email and daklib.utils.is_email_alias(uid_email)):
-            sponsor_addresses = daklib.utils.gpg_get_key_addresses(changes["fingerprint"])
+            uid_email and utils.is_email_alias(uid_email)):
+            sponsor_addresses = utils.gpg_get_key_addresses(changes["fingerprint"])
             if (changes["maintaineremail"] not in sponsor_addresses and
                 changes["changedbyemail"] not in sponsor_addresses):
                 changes["sponsoremail"] = uid_email
@@ -1104,7 +1104,7 @@ def check_signed_by_key():
         check_suites = changes["distribution"].keys()
         if "unstable" not in check_suites: check_suites.append("unstable")
         for suite in check_suites:
-            suite_id = daklib.database.get_suite_id(suite)
+            suite_id = database.get_suite_id(suite)
             q = Upload.projectB.query("SELECT s.id FROM source s JOIN src_associations sa ON (s.id = sa.source) WHERE s.source = '%s' AND sa.suite = %d" % (changes["source"], suite_id))
             for si in q.getresult():
                 if si[0] not in source_ids: source_ids.append(si[0])
@@ -1116,7 +1116,7 @@ def check_signed_by_key():
             is_nmu = 1
             q = Upload.projectB.query("SELECT m.name FROM maintainer m WHERE m.id IN (SELECT maintainer FROM src_uploaders WHERE src_uploaders.source = %s)" % (si))
             for m in q.getresult():
-                (rfc822, rfc2047, name, email) = daklib.utils.fix_maintainer(m[0])
+                (rfc822, rfc2047, name, email) = utils.fix_maintainer(m[0])
                 if email == uid_email or name == uid_name:
                     is_nmu=0
                     break
@@ -1125,17 +1125,17 @@ def check_signed_by_key():
 
         for b in changes["binary"].keys():
             for suite in changes["distribution"].keys():
-                suite_id = daklib.database.get_suite_id(suite)
+                suite_id = database.get_suite_id(suite)
                 q = Upload.projectB.query("SELECT DISTINCT s.source FROM source s JOIN binaries b ON (s.id = b.source) JOIN bin_associations ba On (b.id = ba.bin) WHERE b.package = '%s' AND ba.suite = %s" % (b, suite_id))
                 for s in q.getresult():
                     if s[0] != changes["source"]:
                         reject("%s may not hijack %s from source package %s in suite %s" % (uid, b, s, suite))
 
-        for file in files.keys():
-            if files[file].has_key("byhand"):
-                reject("%s may not upload BYHAND file %s" % (uid, file))
-            if files[file].has_key("new"):
-                reject("%s may not upload NEW file %s" % (uid, file))
+        for f in files.keys():
+            if files[f].has_key("byhand"):
+                reject("%s may not upload BYHAND file %s" % (uid, f))
+            if files[f].has_key("new"):
+                reject("%s may not upload NEW file %s" % (uid, f))
 
     # The remaining checks only apply to binary-only uploads right now
     if changes["architecture"].has_key("source"):
@@ -1151,8 +1151,8 @@ def check_signed_by_key():
     if restrictions.Exists("Components"):
         restricted_components = restrictions.SubTree("Components").ValueList()
         is_restricted = False
-        for file in files:
-            if files[file]["component"] in restricted_components:
+        for f in files:
+            if files[f]["component"] in restricted_components:
                 is_restricted = True
                 break
         if not is_restricted:
@@ -1188,9 +1188,9 @@ def upload_too_new():
     file_list = pkg.files.keys()
     file_list.extend(pkg.dsc_files.keys())
     file_list.append(pkg.changes_file)
-    for file in file_list:
+    for f in file_list:
         try:
-            last_modified = time.time()-os.path.getmtime(file)
+            last_modified = time.time()-os.path.getmtime(f)
             if last_modified < int(Cnf["Dinstall::SkipTime"]):
                 too_new = 1
                 break
@@ -1242,21 +1242,21 @@ def action ():
             if Options["Automatic"]:
                 answer = 'R'
     else:
-        queue = None
+        qu = None
         for q in queues:
             if queue_info[q]["is"]():
-                queue = q
+                qu = q
                 break
-        if queue:
+        if qu:
             print "%s for %s\n%s%s" % (
-                queue.upper(), ", ".join(changes["distribution"].keys()),
+                qu.upper(), ", ".join(changes["distribution"].keys()),
                 reject_message, summary),
-            queuekey = queue[0].upper()
+            queuekey = qu[0].upper()
             if queuekey in "RQSA":
                 queuekey = "D"
                 prompt = "[D]ivert, Skip, Quit ?"
             else:
-                prompt = "[%s]%s, Skip, Quit ?" % (queuekey, queue[1:].lower())
+                prompt = "[%s]%s, Skip, Quit ?" % (queuekey, qu[1:].lower())
             if Options["Automatic"]:
                 answer = queuekey
         else:
@@ -1266,8 +1266,8 @@ def action ():
                 answer = 'A'
 
     while prompt.find(answer) == -1:
-        answer = daklib.utils.our_raw_input(prompt)
-        m = daklib.queue.re_default_answer.match(prompt)
+        answer = utils.our_raw_input(prompt)
+        m = queue.re_default_answer.match(prompt)
         if answer == "":
             answer = m.group(1)
         answer = answer[:1].upper()
@@ -1279,15 +1279,15 @@ def action ():
         accept(summary, short_summary)
         remove_from_unchecked()
     elif answer == queuekey:
-        queue_info[queue]["process"](summary, short_summary)
+        queue_info[qu]["process"](summary, short_summary)
         remove_from_unchecked()
     elif answer == 'Q':
         sys.exit(0)
 
 def remove_from_unchecked():
     os.chdir (pkg.directory)
-    for file in files.keys():
-        os.unlink(file)
+    for f in files.keys():
+        os.unlink(f)
     os.unlink(pkg.changes_file)
 
 ################################################################################
@@ -1299,10 +1299,10 @@ def accept (summary, short_summary):
 ################################################################################
 
 def move_to_dir (dest, perms=0660, changesperms=0664):
-    daklib.utils.move (pkg.changes_file, dest, perms=changesperms)
+    utils.move (pkg.changes_file, dest, perms=changesperms)
     file_keys = files.keys()
-    for file in file_keys:
-        daklib.utils.move (file, dest, perms=perms)
+    for f in file_keys:
+        utils.move (f, dest, perms=perms)
 
 ################################################################################
 
@@ -1367,7 +1367,7 @@ def is_stableupdate ():
         return 0
 
     if not changes["architecture"].has_key("source"):
-        pusuite = daklib.database.get_suite_id("proposed-updates")
+        pusuite = database.get_suite_id("proposed-updates")
         q = Upload.projectB.query(
           "SELECT S.source FROM source s JOIN src_associations sa ON (s.id = sa.source) WHERE s.source = '%s' AND s.version = '%s' AND sa.suite = %d" %
           (changes["source"], changes["version"], pusuite))
@@ -1396,7 +1396,7 @@ def is_oldstableupdate ():
         return 0
 
     if not changes["architecture"].has_key("source"):
-        pusuite = daklib.database.get_suite_id("oldstable-proposed-updates")
+        pusuite = database.get_suite_id("oldstable-proposed-updates")
         q = Upload.projectB.query(
           "SELECT S.source FROM source s JOIN src_associations sa ON (s.id = sa.source) WHERE s.source = '%s' AND s.version = '%s' AND sa.suite = %d" %
           (changes["source"], changes["version"], pusuite))
@@ -1423,27 +1423,27 @@ def do_oldstableupdate (summary, short_summary):
 def is_autobyhand ():
     all_auto = 1
     any_auto = 0
-    for file in files.keys():
-        if files[file].has_key("byhand"):
+    for f in files.keys():
+        if files[f].has_key("byhand"):
             any_auto = 1
 
             # filename is of form "PKG_VER_ARCH.EXT" where PKG, VER and ARCH
             # don't contain underscores, and ARCH doesn't contain dots.
             # further VER matches the .changes Version:, and ARCH should be in
             # the .changes Architecture: list.
-            if file.count("_") < 2:
+            if f.count("_") < 2:
                 all_auto = 0
                 continue
 
-            (pkg, ver, archext) = file.split("_", 2)
+            (pckg, ver, archext) = f.split("_", 2)
             if archext.count(".") < 1 or changes["version"] != ver:
                 all_auto = 0
                 continue
 
             ABH = Cnf.SubTree("AutomaticByHandPackages")
-            if not ABH.has_key(pkg) or \
-              ABH["%s::Source" % (pkg)] != changes["source"]:
-                print "not match %s %s" % (pkg, changes["source"])
+            if not ABH.has_key(pckg) or \
+              ABH["%s::Source" % (pckg)] != changes["source"]:
+                print "not match %s %s" % (pckg, changes["source"])
                 all_auto = 0
                 continue
 
@@ -1452,32 +1452,32 @@ def is_autobyhand ():
                 all_auto = 0
                 continue
 
-            files[file]["byhand-arch"] = arch
-            files[file]["byhand-script"] = ABH["%s::Script" % (pkg)]
+            files[f]["byhand-arch"] = arch
+            files[f]["byhand-script"] = ABH["%s::Script" % (pckg)]
 
     return any_auto and all_auto
 
 def do_autobyhand (summary, short_summary):
     print "Attempting AUTOBYHAND."
     byhandleft = 0
-    for file in files.keys():
-        byhandfile = file
-        if not files[file].has_key("byhand"):
+    for f in files.keys():
+        byhandfile = f
+        if not files[f].has_key("byhand"):
             continue
-        if not files[file].has_key("byhand-script"):
+        if not files[f].has_key("byhand-script"):
             byhandleft = 1
             continue
 
         os.system("ls -l %s" % byhandfile)
         result = os.system("%s %s %s %s %s" % (
-                files[file]["byhand-script"], byhandfile,
-                changes["version"], files[file]["byhand-arch"],
+                files[f]["byhand-script"], byhandfile,
+                changes["version"], files[f]["byhand-arch"],
                 os.path.abspath(pkg.changes_file)))
         if result == 0:
             os.unlink(byhandfile)
-            del files[file]
+            del files[f]
         else:
-            print "Error processing %s, left as byhand." % (file)
+            print "Error processing %s, left as byhand." % (f)
             byhandleft = 1
 
     if byhandleft:
@@ -1488,8 +1488,8 @@ def do_autobyhand (summary, short_summary):
 ################################################################################
 
 def is_byhand ():
-    for file in files.keys():
-        if files[file].has_key("byhand"):
+    for f in files.keys():
+        if files[f].has_key("byhand"):
             return 1
     return 0
 
@@ -1507,8 +1507,8 @@ def do_byhand (summary, short_summary):
 ################################################################################
 
 def is_new ():
-    for file in files.keys():
-        if files[file].has_key("new"):
+    for f in files.keys():
+        if files[f].has_key("new"):
             return 1
     return 0
 
@@ -1524,8 +1524,8 @@ def acknowledge_new (summary, short_summary):
     if not Options["No-Mail"]:
         print "Sending new ack."
         Subst["__SUMMARY__"] = summary
-        new_ack_message = daklib.utils.TemplateSubst(Subst,Cnf["Dir::Templates"]+"/process-unchecked.new")
-        daklib.utils.send_mail(new_ack_message)
+        new_ack_message = utils.TemplateSubst(Subst,Cnf["Dir::Templates"]+"/process-unchecked.new")
+        utils.send_mail(new_ack_message)
 
 ################################################################################
 
@@ -1566,7 +1566,7 @@ def process_it (changes_file):
             # Relativize the filename so we use the copy in holding
             # rather than the original...
             pkg.changes_file = os.path.basename(pkg.changes_file)
-        changes["fingerprint"] = daklib.utils.check_signature(pkg.changes_file, reject)
+        changes["fingerprint"] = utils.check_signature(pkg.changes_file, reject)
         if changes["fingerprint"]:
             valid_changes_p = check_changes()
         else:
@@ -1606,18 +1606,18 @@ def main():
         Options["Automatic"] = ""
 
     # Ensure all the arguments we were given are .changes files
-    for file in changes_files:
-        if not file.endswith(".changes"):
-            daklib.utils.warn("Ignoring '%s' because it's not a .changes file." % (file))
-            changes_files.remove(file)
+    for f in changes_files:
+        if not f.endswith(".changes"):
+            utils.warn("Ignoring '%s' because it's not a .changes file." % (f))
+            changes_files.remove(f)
 
     if changes_files == []:
-        daklib.utils.fubar("Need at least one .changes file as an argument.")
+        utils.fubar("Need at least one .changes file as an argument.")
 
     # Check that we aren't going to clash with the daily cron job
 
     if not Options["No-Action"] and os.path.exists("%s/daily.lock" % (Cnf["Dir::Lock"])) and not Options["No-Lock"]:
-        daklib.utils.fubar("Archive maintenance in progress.  Try again later.")
+        utils.fubar("Archive maintenance in progress.  Try again later.")
 
     # Obtain lock if not in no-action mode and initialize the log
 
@@ -1627,10 +1627,10 @@ def main():
             fcntl.lockf(lock_fd, fcntl.LOCK_EX | fcntl.LOCK_NB)
         except IOError, e:
             if errno.errorcode[e.errno] == 'EACCES' or errno.errorcode[e.errno] == 'EAGAIN':
-                daklib.utils.fubar("Couldn't obtain lock; assuming another 'dak process-unchecked' is already running.")
+                utils.fubar("Couldn't obtain lock; assuming another 'dak process-unchecked' is already running.")
             else:
                 raise
-        Logger = Upload.Logger = daklib.logging.Logger(Cnf, "process-unchecked")
+        Logger = Upload.Logger = logging.Logger(Cnf, "process-unchecked")
 
     # debian-{devel-,}-changes@lists.debian.org toggles writes access based on this header
     bcc = "X-DAK: dak process-unchecked\nX-Katie: $Revision: 1.65 $"
@@ -1641,7 +1641,7 @@ def main():
 
 
     # Sort the .changes files so that we process sourceful ones first
-    changes_files.sort(daklib.utils.changes_compare)
+    changes_files.sort(utils.changes_compare)
 
     # Process the changes files
     for changes_file in changes_files:
@@ -1658,7 +1658,7 @@ def main():
         sets = "set"
         if accept_count > 1:
             sets = "sets"
-        print "Accepted %d package %s, %s." % (accept_count, sets, daklib.utils.size_type(int(accept_bytes)))
+        print "Accepted %d package %s, %s." % (accept_count, sets, utils.size_type(int(accept_bytes)))
         Logger.log(["total",accept_count,accept_bytes])
 
     if not Options["No-Action"]:
index af3bc58d534a9f445bbc3997f6d29c63fd85b5a0..f1e5287f9b29f337a6d1629a194a2ae7b6a6f267 100644 (file)
@@ -36,8 +36,8 @@
 
 import copy, glob, os, stat, sys, time
 import apt_pkg
-import daklib.queue
-import daklib.utils
+import daklib.queue as queue
+import daklib.utils as utils
 
 Cnf = None
 Upload = None
@@ -309,7 +309,6 @@ def process_changes_files(changes_files, type):
     maint=""
     distribution=""
     closes=""
-    source_exists=""
     for i in per_source_items:
         last_modified = time.time()-i[1]["oldest"]
         source = i[1]["list"][0]["source"]
@@ -322,8 +321,8 @@ def process_changes_files(changes_files, type):
                 try:
                     (maintainer["maintainer822"], maintainer["maintainer2047"],
                     maintainer["maintainername"], maintainer["maintaineremail"]) = \
-                    daklib.utils.fix_maintainer (j["maintainer"])
-                except daklib.utils.ParseMaintError, msg:
+                    utils.fix_maintainer (j["maintainer"])
+                except utils.ParseMaintError, msg:
                     print "Problems while parsing maintainer address\n"
                     maintainer["maintainername"] = "Unknown"
                     maintainer["maintaineremail"] = "Unknown"
@@ -335,7 +334,7 @@ def process_changes_files(changes_files, type):
             version = j["version"]
             versions[version] = ""
         arches_list = arches.keys()
-        arches_list.sort(daklib.utils.arch_compare_sw)
+        arches_list.sort(utils.arch_compare_sw)
         arch_list = " ".join(arches_list)
         version_list = " ".join(versions.keys())
         if len(version_list) > max_version_len:
@@ -423,7 +422,7 @@ def process_changes_files(changes_files, type):
 def main():
     global Cnf, Upload
 
-    Cnf = daklib.utils.get_conf()
+    Cnf = utils.get_conf()
     Arguments = [('h',"help","Queue-Report::Options::Help"),
                  ('n',"new","Queue-Report::Options::New"),
                  ('s',"sort","Queue-Report::Options::Sort", "HasArg"),
@@ -438,7 +437,7 @@ def main():
     if Options["Help"]:
         usage()
 
-    Upload = daklib.queue.Upload(Cnf)
+    Upload = queue.Upload(Cnf)
 
     if Cnf.has_key("Queue-Report::Options::New"):
         header()
index d04dbeb39a6b4a800de4717d0134b0dfa6a97866..060ad51337754d69b866e1e488e71ddd0e15a492 100644 (file)
 
 import os, pg, sys
 import apt_pkg
-import daklib.database
-import daklib.logging
-import daklib.queue
-import daklib.utils
+import daklib.database as database
+import daklib.logging as logging
+import daklib.queue as queue
+import daklib.utils as utils
 
 ################################################################################
 
@@ -51,7 +51,7 @@ Manually reject the .CHANGES file(s).
 def main():
     global Cnf, Logger, Options, projectB, Upload
 
-    Cnf = daklib.utils.get_conf()
+    Cnf = utils.get_conf()
     Arguments = [('h',"help","Reject-Proposed-Updates::Options::Help"),
                  ('m',"manual-reject","Reject-Proposed-Updates::Options::Manual-Reject", "HasArg"),
                  ('s',"no-mail", "Reject-Proposed-Updates::Options::No-Mail")]
@@ -65,13 +65,13 @@ def main():
     if Options["Help"]:
         usage()
     if not arguments:
-        daklib.utils.fubar("need at least one .changes filename as an argument.")
+        utils.fubar("need at least one .changes filename 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)
 
-    Upload = daklib.queue.Upload(Cnf)
-    Logger = Upload.Logger = daklib.logging.Logger(Cnf, "reject-proposed-updates")
+    Upload = queue.Upload(Cnf)
+    Logger = Upload.Logger = logging.Logger(Cnf, "reject-proposed-updates")
 
     bcc = "X-DAK: dak rejected-proposed-updates\nX-Katie: lauren $Revision: 1.4 $"
     if Cnf.has_key("Dinstall::Bcc"):
@@ -80,7 +80,7 @@ def main():
         Upload.Subst["__BCC__"] = bcc
 
     for arg in arguments:
-        arg = daklib.utils.validate_changes_file_arg(arg)
+        arg = utils.validate_changes_file_arg(arg)
         Upload.pkg.changes_file = arg
         Upload.init_vars()
         cwd = os.getcwd()
@@ -96,8 +96,8 @@ def main():
             answer = "XXX"
 
             while prompt.find(answer) == -1:
-                answer = daklib.utils.our_raw_input(prompt)
-                m = daklib.queue.re_default_answer.search(prompt)
+                answer = utils.our_raw_input(prompt)
+                m = queue.re_default_answer.search(prompt)
                 if answer == "":
                     answer = m.group(1)
                 answer = answer[:1].upper()
@@ -123,21 +123,21 @@ def reject (reject_message = ""):
     # If we weren't given a manual rejection message, spawn an editor
     # so the user can add one in...
     if not reject_message:
-        temp_filename = daklib.utils.temp_filename()
+        temp_filename = utils.temp_filename()
         editor = os.environ.get("EDITOR","vi")
         answer = 'E'
         while answer == 'E':
             os.system("%s %s" % (editor, temp_filename))
-            file = daklib.utils.open_file(temp_filename)
-            reject_message = "".join(file.readlines())
-            file.close()
+            f = utils.open_file(temp_filename)
+            reject_message = "".join(f.readlines())
+            f.close()
             print "Reject message:"
-            print daklib.utils.prefix_multi_line_string(reject_message,"  ", include_blank_lines=1)
+            print utils.prefix_multi_line_string(reject_message,"  ", include_blank_lines=1)
             prompt = "[R]eject, Edit, Abandon, Quit ?"
             answer = "XXX"
             while prompt.find(answer) == -1:
-                answer = daklib.utils.our_raw_input(prompt)
-                m = daklib.queue.re_default_answer.search(prompt)
+                answer = utils.our_raw_input(prompt)
+                m = queue.re_default_answer.search(prompt)
                 if answer == "":
                     answer = m.group(1)
                 answer = answer[:1].upper()
@@ -163,38 +163,38 @@ def reject (reject_message = ""):
     reject_fd = os.open(reject_filename, os.O_RDWR|os.O_CREAT|os.O_EXCL, 0644)
 
     # Build up the rejection email
-    user_email_address = daklib.utils.whoami() + " <%s>" % (Cnf["Dinstall::MyAdminAddress"])
+    user_email_address = utils.whoami() + " <%s>" % (Cnf["Dinstall::MyAdminAddress"])
 
     Upload.Subst["__REJECTOR_ADDRESS__"] = user_email_address
     Upload.Subst["__MANUAL_REJECT_MESSAGE__"] = reject_message
     Upload.Subst["__STABLE_REJECTOR__"] = Cnf["Reject-Proposed-Updates::StableRejector"]
     Upload.Subst["__MORE_INFO_URL__"] = Cnf["Reject-Proposed-Updates::MoreInfoURL"]
     Upload.Subst["__CC__"] = "Cc: " + Cnf["Dinstall::MyEmailAddress"]
-    reject_mail_message = daklib.utils.TemplateSubst(Upload.Subst,Cnf["Dir::Templates"]+"/reject-proposed-updates.rejected")
+    reject_mail_message = utils.TemplateSubst(Upload.Subst,Cnf["Dir::Templates"]+"/reject-proposed-updates.rejected")
 
     # Write the rejection email out as the <foo>.reason file
     os.write(reject_fd, reject_mail_message)
     os.close(reject_fd)
 
     # Remove the packages from proposed-updates
-    suite_id = daklib.database.get_suite_id('proposed-updates')
+    suite_id = database.get_suite_id('proposed-updates')
 
     projectB.query("BEGIN WORK")
     # Remove files from proposed-updates suite
-    for file in files.keys():
-        if files[file]["type"] == "dsc":
+    for f in files.keys():
+        if files[f]["type"] == "dsc":
             package = dsc["source"]
-            version = dsc["version"];  # NB: not files[file]["version"], that has no epoch
+            version = dsc["version"];  # NB: not files[f]["version"], that has no epoch
             q = projectB.query("SELECT id FROM source WHERE source = '%s' AND version = '%s'" % (package, version))
             ql = q.getresult()
             if not ql:
-                daklib.utils.fubar("reject: Couldn't find %s_%s in source table." % (package, version))
+                utils.fubar("reject: Couldn't find %s_%s in source table." % (package, version))
             source_id = ql[0][0]
             projectB.query("DELETE FROM src_associations WHERE suite = '%s' AND source = '%s'" % (suite_id, source_id))
-        elif files[file]["type"] == "deb":
-            package = files[file]["package"]
-            version = files[file]["version"]
-            architecture = files[file]["architecture"]
+        elif files[f]["type"] == "deb":
+            package = files[f]["package"]
+            version = files[f]["version"]
+            architecture = files[f]["architecture"]
             q = projectB.query("SELECT b.id FROM binaries b, architecture a WHERE b.package = '%s' AND b.version = '%s' AND (a.arch_string = '%s' OR a.arch_string = 'all') AND b.architecture = a.id" % (package, version, architecture))
             ql = q.getresult()
 
@@ -204,7 +204,7 @@ def reject (reject_message = ""):
             # newer version of the package and only do the
             # warn&continue thing if it finds one.
             if not ql:
-                daklib.utils.warn("reject: Couldn't find %s_%s_%s in binaries table." % (package, version, architecture))
+                utils.warn("reject: Couldn't find %s_%s_%s in binaries table." % (package, version, architecture))
             else:
                 binary_id = ql[0][0]
                 projectB.query("DELETE FROM bin_associations WHERE suite = '%s' AND bin = '%s'" % (suite_id, binary_id))
@@ -212,7 +212,7 @@ def reject (reject_message = ""):
 
     # Send the rejection mail if appropriate
     if not Options["No-Mail"]:
-        daklib.utils.send_mail(reject_mail_message)
+        utils.send_mail(reject_mail_message)
 
     # Finally remove the .dak file
     dot_dak_file = os.path.join(Cnf["Suite::Proposed-Updates::CopyDotDak"], os.path.basename(changes_file[:-8]+".dak"))
old mode 100644 (file)
new mode 100755 (executable)
index 262039b..d5663e3
--- a/dak/rm.py
+++ b/dak/rm.py
@@ -41,8 +41,8 @@
 
 import commands, os, pg, re, sys
 import apt_pkg, apt_inst
-import daklib.database
-import daklib.utils
+import daklib.database as database
+import daklib.utils as utils
 
 ################################################################################
 
@@ -87,7 +87,7 @@ ARCH, BUG#, COMPONENT and SUITE can be comma (or space) separated lists, e.g.
 #  the fuck are we gonna do now? What are we gonna do?"
 
 def game_over():
-    answer = daklib.utils.our_raw_input("Continue (y/N)? ").lower()
+    answer = utils.our_raw_input("Continue (y/N)? ").lower()
     if answer != "y":
         print "Aborted."
         sys.exit(1)
@@ -107,11 +107,11 @@ def reverse_depends_check(removals, suites):
         for component in components:
             filename = "%s/dists/%s/%s/binary-%s/Packages.gz" % (Cnf["Dir::Root"], suites[0], component, architecture)
             # 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):
-                daklib.utils.fubar("Gunzip invocation failed!\n%s\n" % (output), result)
-            packages = daklib.utils.open_file(temp_filename)
+                utils.fubar("Gunzip invocation failed!\n%s\n" % (output), result)
+            packages = utils.open_file(temp_filename)
             Packages = apt_pkg.ParseTagFile(packages)
             while Packages.Step():
                 package = Packages.Section.Find("Package")
@@ -165,19 +165,19 @@ def reverse_depends_check(removals, suites):
                         what = "%s/%s" % (package, component)
                     else:
                         what = "** %s" % (package)
-                    print "%s has an unsatisfied dependency on %s: %s" % (what, architecture, daklib.utils.pp_deps(dep))
+                    print "%s has an unsatisfied dependency on %s: %s" % (what, architecture, utils.pp_deps(dep))
                     dep_problem = 1
 
     # Check source dependencies (Build-Depends and Build-Depends-Indep)
     for component in components:
         filename = "%s/dists/%s/%s/source/Sources.gz" % (Cnf["Dir::Root"], suites[0], 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, "r")
+        sources = utils.open_file(temp_filename, "r")
         Sources = apt_pkg.ParseTagFile(sources)
         while Sources.Step():
             source = Sources.Section.Find("Package")
@@ -202,7 +202,7 @@ def reverse_depends_check(removals, suites):
                         source = "%s/%s" % (source, component)
                     else:
                         source = "** %s" % (source)
-                    print "%s has an unsatisfied build-dependency: %s" % (source, daklib.utils.pp_deps(dep))
+                    print "%s has an unsatisfied build-dependency: %s" % (source, utils.pp_deps(dep))
                     dep_problem = 1
         sources.close()
         os.unlink(temp_filename)
@@ -220,7 +220,7 @@ def reverse_depends_check(removals, suites):
 def main ():
     global Cnf, Options, projectB
 
-    Cnf = daklib.utils.get_conf()
+    Cnf = utils.get_conf()
 
     Arguments = [('h',"help","Rm::Options::Help"),
                  ('a',"architecture","Rm::Options::Architecture", "HasArg"),
@@ -251,19 +251,19 @@ def main ():
         usage()
 
     projectB = pg.connect(Cnf["DB::Name"], Cnf["DB::Host"], int(Cnf["DB::Port"]))
-    daklib.database.init(Cnf, projectB)
+    database.init(Cnf, projectB)
 
     # Sanity check options
     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.")
     if Options["Architecture"] and Options["Source-Only"]:
-        daklib.utils.fubar("can't use -a/--architecutre and -S/--source-only options simultaneously.")
+        utils.fubar("can't use -a/--architecutre and -S/--source-only options simultaneously.")
     if Options["Binary-Only"] and Options["Source-Only"]:
-        daklib.utils.fubar("can't use -b/--binary-only and -S/--source-only options simultaneously.")
+        utils.fubar("can't use -b/--binary-only and -S/--source-only options simultaneously.")
     if Options.has_key("Carbon-Copy") and not Options.has_key("Done"):
-        daklib.utils.fubar("can't use -C/--carbon-copy without also using -d/--done option.")
+        utils.fubar("can't use -C/--carbon-copy without also using -d/--done option.")
     if Options["Architecture"] and not Options["Partial"]:
-        daklib.utils.warn("-a/--architecture implies -p/--partial.")
+        utils.warn("-a/--architecture implies -p/--partial.")
         Options["Partial"] = "true"
 
     # Force the admin to tell someone if we're not doing a 'dak
@@ -271,7 +271,7 @@ def main ():
     # as telling someone).
     if not Options["No-Action"] and not Options["Carbon-Copy"] \
            and not Options["Done"] and Options["Reason"].find("[auto-cruft]") == -1:
-        daklib.utils.fubar("Need a -C/--carbon-copy if not closing a bug and not doing a cruft removal.")
+        utils.fubar("Need a -C/--carbon-copy if not closing a bug and not doing a cruft removal.")
 
     # Process -C/--carbon-copy
     #
@@ -281,7 +281,7 @@ def main ():
     #  3) contains a '@' - assumed to be an email address, used unmofidied
     #
     carbon_copy = []
-    for copy_to in daklib.utils.split_args(Options.get("Carbon-Copy")):
+    for copy_to in utils.split_args(Options.get("Carbon-Copy")):
         if copy_to.isdigit():
             carbon_copy.append(copy_to + "@" + Cnf["Dinstall::BugServer"])
         elif copy_to == 'package':
@@ -292,7 +292,7 @@ def main ():
         elif '@' in copy_to:
             carbon_copy.append(copy_to)
         else:
-            daklib.utils.fubar("Invalid -C/--carbon-copy argument '%s'; not a bug number, 'package' or email address." % (copy_to))
+            utils.fubar("Invalid -C/--carbon-copy argument '%s'; not a bug number, 'package' or email address." % (copy_to))
 
     if Options["Binary-Only"]:
         field = "b.package"
@@ -301,15 +301,15 @@ def main ():
     con_packages = "AND %s IN (%s)" % (field, ", ".join([ repr(i) for i in arguments ]))
 
     (con_suites, con_architectures, con_components, check_source) = \
-                 daklib.utils.parse_args(Options)
+                 utils.parse_args(Options)
 
     # Additional suite checks
     suite_ids_list = []
-    suites = daklib.utils.split_args(Options["Suite"])
-    suites_list = daklib.utils.join_with_commas_and(suites)
+    suites = utils.split_args(Options["Suite"])
+    suites_list = utils.join_with_commas_and(suites)
     if not Options["No-Action"]:
         for suite in suites:
-            suite_id = daklib.database.get_suite_id(suite)
+            suite_id = database.get_suite_id(suite)
             if suite_id != -1:
                 suite_ids_list.append(suite_id)
             if suite == "stable":
@@ -325,7 +325,7 @@ def main ():
 
     # Additional architecture checks
     if Options["Architecture"] and check_source:
-        daklib.utils.warn("'source' in -a/--argument makes no sense and is ignored.")
+        utils.warn("'source' in -a/--argument makes no sense and is ignored.")
 
     # Additional component processing
     over_con_components = con_components.replace("c.id", "component")
@@ -363,9 +363,9 @@ def main ():
             for i in source_packages.keys():
                 filename = "/".join(source_packages[i])
                 try:
-                    dsc = daklib.utils.parse_changes(filename)
-                except daklib.utils.cant_open_exc:
-                    daklib.utils.warn("couldn't open '%s'." % (filename))
+                    dsc = utils.parse_changes(filename)
+                except utils.cant_open_exc:
+                    utils.warn("couldn't open '%s'." % (filename))
                     continue
                 for package in dsc.get("binary").split(','):
                     package = package.strip()
@@ -378,7 +378,7 @@ def main ():
                 q = projectB.query("SELECT l.path, f.filename, b.package, b.version, a.arch_string, b.id, b.maintainer FROM binaries b, bin_associations ba, architecture a, suite su, files f, location l, component c WHERE ba.bin = b.id AND ba.suite = su.id AND b.architecture = a.id AND b.file = f.id AND f.location = l.id AND l.component = c.id %s %s %s AND b.package = '%s'" % (con_suites, con_components, con_architectures, package))
                 for i in q.getresult():
                     filename = "/".join(i[:2])
-                    control = apt_pkg.ParseSection(apt_inst.debExtractControl(daklib.utils.open_file(filename)))
+                    control = apt_pkg.ParseSection(apt_inst.debExtractControl(utils.open_file(filename)))
                     source = control.Find("Source", control.Find("Package"))
                     source = re_strip_source_version.sub('', source)
                     if source_packages.has_key(source):
@@ -392,12 +392,12 @@ def main ():
     # If we don't have a reason; spawn an editor so the user can add one
     # Write the rejection email out as the <foo>.reason file
     if not Options["Reason"] and not Options["No-Action"]:
-        temp_filename = daklib.utils.temp_filename()
+        temp_filename = utils.temp_filename()
         editor = os.environ.get("EDITOR","vi")
         result = os.system("%s %s" % (editor, temp_filename))
         if result != 0:
-            daklib.utils.fubar ("vi invocation failed for `%s'!" % (temp_filename), result)
-        temp_file = daklib.utils.open_file(temp_filename)
+            utils.fubar ("vi invocation failed for `%s'!" % (temp_filename), result)
+        temp_file = utils.open_file(temp_filename)
         for line in temp_file.readlines():
             Options["Reason"] += line
         temp_file.close()
@@ -420,7 +420,7 @@ def main ():
 
     maintainer_list = []
     for maintainer_id in maintainers.keys():
-        maintainer_list.append(daklib.database.get_maintainer(maintainer_id))
+        maintainer_list.append(database.get_maintainer(maintainer_id))
     summary = ""
     removals = d.keys()
     removals.sort()
@@ -428,7 +428,7 @@ def main ():
         versions = d[package].keys()
         versions.sort(apt_pkg.VersionCompare)
         for version in versions:
-            d[package][version].sort(daklib.utils.arch_compare_sw)
+            d[package][version].sort(utils.arch_compare_sw)
             summary += "%10s | %10s | %s\n" % (package, version, ", ".join(d[package][version]))
     print "Will remove the following packages from %s:" % (suites_list)
     print
@@ -454,11 +454,11 @@ def main ():
     print "Going to remove the packages now."
     game_over()
 
-    whoami = daklib.utils.whoami()
+    whoami = utils.whoami()
     date = commands.getoutput('date -R')
 
     # Log first; if it all falls apart I want a record that we at least tried.
-    logfile = daklib.utils.open_file(Cnf["Rm::LogFile"], 'a')
+    logfile = utils.open_file(Cnf["Rm::LogFile"], 'a')
     logfile.write("=========================================================================\n")
     logfile.write("[Date: %s] [ftpmaster: %s]\n" % (date, whoami))
     logfile.write("Removed the following packages from %s:\n\n%s" % (suites_list, summary))
@@ -468,8 +468,8 @@ def main ():
     logfile.write("----------------------------------------------\n")
     logfile.flush()
 
-    dsc_type_id = daklib.database.get_override_type_id('dsc')
-    deb_type_id = daklib.database.get_override_type_id('deb')
+    dsc_type_id = database.get_override_type_id('dsc')
+    deb_type_id = database.get_override_type_id('deb')
 
     # Do the actual deletion
     print "Deleting...",
@@ -518,14 +518,14 @@ def main ():
         Subst["__ADMIN_ADDRESS__"] = Cnf["Dinstall::MyAdminAddress"]
         Subst["__DISTRO__"] = Cnf["Dinstall::MyDistribution"]
         Subst["__WHOAMI__"] = whoami
-        whereami = daklib.utils.where_am_i()
+        whereami = utils.where_am_i()
         Archive = Cnf.SubTree("Archive::%s" % (whereami))
         Subst["__MASTER_ARCHIVE__"] = Archive["OriginServer"]
         Subst["__PRIMARY_MIRROR__"] = Archive["PrimaryMirror"]
-        for bug in daklib.utils.split_args(Options["Done"]):
+        for bug in utils.split_args(Options["Done"]):
             Subst["__BUG_NUMBER__"] = bug
-            mail_message = daklib.utils.TemplateSubst(Subst,Cnf["Dir::Templates"]+"/rm.bug-close")
-            daklib.utils.send_mail(mail_message)
+            mail_message = utils.TemplateSubst(Subst,Cnf["Dir::Templates"]+"/rm.bug-close")
+            utils.send_mail(mail_message)
 
     logfile.write("=========================================================================\n")
     logfile.close()
index bf5491587e9116e2fc0bda8186720e5adb089664..34efeb4c16b2a91d067020e8a53479419a016ee0 100644 (file)
@@ -32,7 +32,7 @@
 
 import commands, os, pwd, re, sys, time
 import apt_pkg
-import daklib.queue
+import daklib.queue as queue
 import daklib.utils
 
 ################################################################################
@@ -85,12 +85,12 @@ def do_upload(changes_files):
             print "Not uploading amd64 part to ftp-master\n"
             continue
         # Build the file list for this .changes file
-        for file in files.keys():
+        for f in files.keys():
             poolname = os.path.join(Cnf["Dir::Root"], Cnf["Dir::PoolRoot"],
-                                    daklib.utils.poolify(changes["source"], files[file]["component"]),
-                                    file)
+                                    daklib.utils.poolify(changes["source"], files[f]["component"]),
+                                    f)
             file_list.append(poolname)
-            orig_component = files[file].get("original component", files[file]["component"])
+            orig_component = files[f].get("original component", files[f]["component"])
             components[orig_component] = ""
         # Determine the upload uri for this .changes file
         for component in components.keys():
@@ -138,11 +138,11 @@ def do_upload(changes_files):
 
     if not Options["No-Action"]:
         filename = "%s/testing-processed" % (Cnf["Dir::Log"])
-        file = daklib.utils.open_file(filename, 'a')
+        f = daklib.utils.open_file(filename, 'a')
         for source in package_list.keys():
             for version in package_list[source].keys():
-                file.write(" ".join([source, version])+'\n')
-        file.close()
+                f.write(" ".join([source, version])+'\n')
+        f.close()
 
 ######################################################################
 # This function was originally written by aj and NIHishly merged into
@@ -168,35 +168,35 @@ def make_advisory(advisory_nr, changes_files):
                 updated_pkgs[suite] = {}
 
         files = Upload.pkg.files
-        for file in files.keys():
-            arch = files[file]["architecture"]
-            md5 = files[file]["md5sum"]
-            size = files[file]["size"]
+        for f in files.keys():
+            arch = files[f]["architecture"]
+            md5 = files[f]["md5sum"]
+            size = files[f]["size"]
             poolname = Cnf["Dir::PoolRoot"] + \
-                daklib.utils.poolify(src, files[file]["component"])
-            if arch == "source" and file.endswith(".dsc"):
+                daklib.utils.poolify(src, files[f]["component"])
+            if arch == "source" and f.endswith(".dsc"):
                 dscpoolname = poolname
             for suite in suites:
                 if not updated_pkgs[suite].has_key(arch):
                     updated_pkgs[suite][arch] = {}
-                updated_pkgs[suite][arch][file] = {
+                updated_pkgs[suite][arch][f] = {
                     "md5": md5, "size": size,
                     "poolname": poolname }
 
         dsc_files = Upload.pkg.dsc_files
-        for file in dsc_files.keys():
+        for f in dsc_files.keys():
             arch = "source"
-            if not dsc_files[file].has_key("files id"):
+            if not dsc_files[f].has_key("files id"):
                 continue
 
             # otherwise, it's already in the pool and needs to be
             # listed specially
-            md5 = dsc_files[file]["md5sum"]
-            size = dsc_files[file]["size"]
+            md5 = dsc_files[f]["md5sum"]
+            size = dsc_files[f]["size"]
             for suite in suites:
                 if not updated_pkgs[suite].has_key(arch):
                     updated_pkgs[suite][arch] = {}
-                updated_pkgs[suite][arch][file] = {
+                updated_pkgs[suite][arch][f] = {
                     "md5": md5, "size": size,
                     "poolname": dscpoolname }
 
@@ -247,12 +247,12 @@ def make_advisory(advisory_nr, changes_files):
                 adv += "  %s architecture (%s)\n\n" % (a,
                         Cnf["Architectures::%s" % a])
 
-            for file in updated_pkgs[suite][a].keys():
+            for f in updated_pkgs[suite][a].keys():
                 adv += "    http://%s/%s%s\n" % (
-                                archive, updated_pkgs[suite][a][file]["poolname"], file)
+                                archive, updated_pkgs[suite][a][f]["poolname"], f)
                 adv += "      Size/MD5 checksum: %8s %s\n" % (
-                        updated_pkgs[suite][a][file]["size"],
-                        updated_pkgs[suite][a][file]["md5"])
+                        updated_pkgs[suite][a][f]["size"],
+                        updated_pkgs[suite][a][f]["md5"])
             adv += "\n"
     adv = adv.rstrip()
 
@@ -280,7 +280,7 @@ def init():
 
     arguments = apt_pkg.ParseCommandLine(Cnf,Arguments,sys.argv)
     Options = Cnf.SubTree("Security-Install::Options")
-    Upload = daklib.queue.Upload(Cnf)
+    Upload = queue.Upload(Cnf)
 
     if Options["Help"]:
         usage(0)
@@ -293,8 +293,8 @@ def init():
     if advisory_number.endswith(".changes"):
         daklib.utils.warn("first argument must be the advisory number.")
         usage(1)
-    for file in changes_files:
-        file = daklib.utils.validate_changes_file_arg(file)
+    for f in changes_files:
+        f = daklib.utils.validate_changes_file_arg(f)
     return (advisory_number, changes_files)
 
 ######################################################################
@@ -332,8 +332,8 @@ def main():
 
     if not Options["No-Action"]:
         print "About to install the following files: "
-        for file in changes_files:
-            print "  %s" % (file)
+        for f in changes_files:
+            print "  %s" % (f)
         answer = yes_no("Continue (Y/n)?")
         if answer == "n":
             sys.exit(0)
old mode 100644 (file)
new mode 100755 (executable)
index 2596f86..87bea79
@@ -28,9 +28,9 @@
 import copy, os, sys, time
 import apt_pkg
 import examine_package
-import daklib.database
-import daklib.queue
-import daklib.utils
+import daklib.database as database
+import daklib.queue as queue
+import daklib.utils as utils
 
 # Globals
 Cnf = None
@@ -149,7 +149,7 @@ def do_pkg(changes_file):
     changes["suite"] = copy.copy(changes["distribution"])
 
     # Find out what's new
-    new = daklib.queue.determine_new(changes, files, projectB, 0)
+    new = queue.determine_new(changes, files, projectB, 0)
 
     stdout_fd = sys.stdout
 
@@ -168,7 +168,7 @@ def do_pkg(changes_file):
 
         html_header(changes["source"], filestoexamine)
 
-        daklib.queue.check_valid(new)
+        queue.check_valid(new)
         examine_package.display_changes(Upload.pkg.changes_file)
 
         for fn in filter(lambda fn: fn.endswith(".dsc"), filestoexamine):
@@ -195,7 +195,7 @@ def usage (exit_code=0):
 def init():
     global Cnf, Options, Upload, projectB
 
-    Cnf = daklib.utils.get_conf()
+    Cnf = utils.get_conf()
 
     Arguments = [('h',"help","Show-New::Options::Help"),
                  ("p","html-path","Show-New::HTMLPath","HasArg")]
@@ -210,7 +210,7 @@ def init():
     if Options["help"]:
         usage()
 
-    Upload = daklib.queue.Upload(Cnf)
+    Upload = queue.Upload(Cnf)
 
     projectB = Upload.projectB
 
@@ -226,15 +226,15 @@ def main():
     examine_package.use_html=1
 
     for changes_file in changes_files:
-        changes_file = daklib.utils.validate_changes_file_arg(changes_file, 0)
+        changes_file = utils.validate_changes_file_arg(changes_file, 0)
         if not changes_file:
             continue
         print "\n" + changes_file
         do_pkg (changes_file)
     files = set(os.listdir(Cnf["Show-New::HTMLPath"]))
     to_delete = filter(lambda x: x.endswith(".html"), files.difference(sources))
-    for file in to_delete:
-        os.remove(os.path.join(Cnf["Show-New::HTMLPath"],file))
+    for f in to_delete:
+        os.remove(os.path.join(Cnf["Show-New::HTMLPath"],f))
 
 ################################################################################
 
old mode 100644 (file)
new mode 100755 (executable)
index 2fc6c90..5502dcc
 ################################################################################
 
 import glob, os, stat, time
-import daklib.utils
+import daklib.utils as utils
 
 ################################################################################
 
 def main():
-    Cnf = daklib.utils.get_conf()
+    Cnf = utils.get_conf()
     count = 0
     move_date = int(time.time())-(30*84600)
     os.chdir(Cnf["Dir::Queue::Done"])
@@ -41,7 +41,7 @@ def main():
                 os.makedirs(dirname)
             dest = dirname + '/' + os.path.basename(filename)
             if os.path.exists(dest):
-                daklib.utils.fubar("%s already exists." % (dest))
+                utils.fubar("%s already exists." % (dest))
             print "Move: %s -> %s" % (filename, dest)
             os.rename(filename, dest)
             count = count + 1
old mode 100644 (file)
new mode 100755 (executable)
index bf84efe..e1786c4
@@ -32,7 +32,7 @@
 
 import pg, sys
 import apt_pkg
-import daklib.utils
+import daklib.utils as utils
 
 ################################################################################
 
@@ -71,8 +71,8 @@ SELECT a.arch_string as Architecture, sum(f.size)
 
 def daily_install_stats():
     stats = {}
-    file = daklib.utils.open_file("2001-11")
-    for line in file.readlines():
+    f = utils.open_file("2001-11")
+    for line in f.readlines():
         split = line.strip().split('|')
         program = split[1]
         if program != "katie" and program != "process-accepted":
@@ -140,15 +140,15 @@ def number_of_packages():
     q = projectB.query("SELECT id, suite_name FROM suite")
     suite_ql = q.getresult()
     for i in suite_ql:
-        (id, name) = i
-        suites[id] = name
-        suite_ids[name] = id
+        (sid, name) = i
+        suites[sid] = name
+        suite_ids[name] = sid
     # Build up architecture mapping
     q = projectB.query("SELECT id, arch_string FROM architecture")
     for i in q.getresult():
-        (id, name) = i
-        arches[id] = name
-        arch_ids[name] = id
+        (aid, name) = i
+        arches[aid] = name
+        arch_ids[name] = aid
     # Pre-create the dictionary
     for suite_id in suites.keys():
         d[suite_id] = {}
@@ -213,7 +213,7 @@ SELECT suite, count(suite) FROM src_associations GROUP BY suite;""")
 def main ():
     global Cnf, projectB
 
-    Cnf = daklib.utils.get_conf()
+    Cnf = utils.get_conf()
     Arguments = [('h',"help","Stats::Options::Help")]
     for i in [ "help" ]:
         if not Cnf.has_key("Stats::Options::%s" % (i)):
@@ -226,10 +226,10 @@ def main ():
         usage()
 
     if len(args) < 1:
-        daklib.utils.warn("dak stats requires a MODE argument")
+        utils.warn("dak stats requires a MODE argument")
         usage(1)
     elif len(args) > 1:
-        daklib.utils.warn("dak stats accepts only one MODE argument")
+        utils.warn("dak stats accepts only one MODE argument")
         usage(1)
     mode = args[0].lower()
 
@@ -242,7 +242,7 @@ def main ():
     elif mode == "daily-install":
         daily_install_stats()
     else:
-        daklib.utils.warn("unknown mode '%s'" % (mode))
+        utils.warn("unknown mode '%s'" % (mode))
         usage(1)
 
 ################################################################################
index 6656ab6d9df692c61e96c22294d3d85ab6796c21..35f5518304023f7dd430ecf97cd4fd308292e4e4 100644 (file)
@@ -68,13 +68,13 @@ def fix_component_section (component, section):
 
 ################################################################################
 
-def find_dislocated_stable(Cnf, projectB):
+def find_dislocated_stable(Conf, DBConn):
     dislocated_files = {}
 
-    codename = Cnf["Suite::Stable::Codename"]
+    codename = Conf["Suite::Stable::Codename"]
 
     # Source
-    q = projectB.query("""
+    q = DBConn.query("""
 SELECT DISTINCT ON (f.id) c.name, sec.section, l.path, f.filename, f.id
     FROM component c, override o, section sec, source s, files f, location l,
          dsc_files df, suite su, src_associations sa, files f2, location l2
@@ -95,20 +95,20 @@ SELECT DISTINCT ON (f.id) c.name, sec.section, l.path, f.filename, f.id
 #        AND NOT EXISTS (SELECT 1 FROM location l WHERE l.component IS NOT NULL AND f.location = l.id)
     for i in q.getresult():
         (component, section) = fix_component_section(i[0], i[1])
-        if Cnf.FindB("Dinstall::LegacyStableHasNoSections"):
+        if Conf.FindB("Dinstall::LegacyStableHasNoSections"):
             section=""
-        dest = "%sdists/%s/%s/source/%s%s" % (Cnf["Dir::Root"], codename, component, section, os.path.basename(i[3]))
+        dest = "%sdists/%s/%s/source/%s%s" % (Conf["Dir::Root"], codename, component, section, os.path.basename(i[3]))
         if not os.path.exists(dest):
             src = i[2]+i[3]
-            src = daklib.utils.clean_symlink(src, dest, Cnf["Dir::Root"])
-            if Cnf.Find("Symlink-Dists::Options::Verbose"):
+            src = daklib.utils.clean_symlink(src, dest, Conf["Dir::Root"])
+            if Conf.Find("Symlink-Dists::Options::Verbose"):
                 print src+' -> '+dest
             os.symlink(src, dest)
         dislocated_files[i[4]] = dest
 
     # Binary
-    architectures = filter(daklib.utils.real_arch, Cnf.ValueList("Suite::Stable::Architectures"))
-    q = projectB.query("""
+    architectures = filter(daklib.utils.real_arch, Conf.ValueList("Suite::Stable::Architectures"))
+    q = DBConn.query("""
 SELECT DISTINCT ON (f.id) c.name, a.arch_string, sec.section, b.package,
                           b.version, l.path, f.filename, f.id
     FROM architecture a, bin_associations ba, binaries b, component c, files f,
@@ -130,26 +130,26 @@ SELECT DISTINCT ON (f.id) c.name, a.arch_string, sec.section, b.package,
 #          (SELECT 1 FROM location l WHERE l.component IS NOT NULL AND f.location = l.id)
     for i in q.getresult():
         (component, section) = fix_component_section(i[0], i[2])
-        if Cnf.FindB("Dinstall::LegacyStableHasNoSections"):
+        if Conf.FindB("Dinstall::LegacyStableHasNoSections"):
             section=""
         architecture = i[1]
         package = i[3]
         version = daklib.utils.re_no_epoch.sub('', i[4])
         src = i[5]+i[6]
 
-        dest = "%sdists/%s/%s/binary-%s/%s%s_%s.deb" % (Cnf["Dir::Root"], codename, component, architecture, section, package, version)
-        src = daklib.utils.clean_symlink(src, dest, Cnf["Dir::Root"])
+        dest = "%sdists/%s/%s/binary-%s/%s%s_%s.deb" % (Conf["Dir::Root"], codename, component, architecture, section, package, version)
+        src = daklib.utils.clean_symlink(src, dest, Conf["Dir::Root"])
         if not os.path.exists(dest):
-            if Cnf.Find("Symlink-Dists::Options::Verbose"):
+            if Conf.Find("Symlink-Dists::Options::Verbose"):
                 print src+' -> '+dest
             os.symlink(src, dest)
         dislocated_files[i[7]] = dest
         # Add per-arch symlinks for arch: all debs
         if architecture == "all":
             for arch in architectures:
-                dest = "%sdists/%s/%s/binary-%s/%s%s_%s.deb" % (Cnf["Dir::Root"], codename, component, arch, section, package, version)
+                dest = "%sdists/%s/%s/binary-%s/%s%s_%s.deb" % (Conf["Dir::Root"], codename, component, arch, section, package, version)
                 if not os.path.exists(dest):
-                    if Cnf.Find("Symlink-Dists::Options::Verbose"):
+                    if Conf.Find("Symlink-Dists::Options::Verbose"):
                         print src+' -> '+dest
                     os.symlink(src, dest)
 
old mode 100644 (file)
new mode 100755 (executable)
index 5636624..7a0da2e
@@ -25,8 +25,8 @@
 
 import os, pg, sys, time, errno, fcntl, tempfile, pwd, re
 import apt_pkg
-import daklib.database
-import daklib.utils
+import daklib.database as database
+import daklib.utils as utils
 import syck
 
 # Globals
@@ -46,7 +46,7 @@ def init():
 
     apt_pkg.init()
 
-    Cnf = daklib.utils.get_conf()
+    Cnf = utils.get_conf()
 
     Arguments = [('h',"help","Edit-Transitions::Options::Help"),
                  ('e',"edit","Edit-Transitions::Options::Edit"),
@@ -74,7 +74,7 @@ def init():
         Options["sudo"] = "y"
 
     projectB = pg.connect(Cnf["DB::Name"], Cnf["DB::Host"], int(Cnf["DB::Port"]))
-    daklib.database.init(Cnf, projectB)
+    database.init(Cnf, projectB)
 
 ################################################################################
 
@@ -183,9 +183,9 @@ def load_transitions(trans_file):
 #####################################
 #### This may run within sudo !! ####
 #####################################
-def lock_file(file):
+def lock_file(f):
     for retry in range(10):
-        lock_fd = os.open(file, os.O_RDWR | os.O_CREAT)
+        lock_fd = os.open(f, os.O_RDWR | os.O_CREAT)
         try:
             fcntl.lockf(lock_fd, fcntl.LOCK_EX | fcntl.LOCK_NB)
             return lock_fd
@@ -197,7 +197,7 @@ def lock_file(file):
             else:
                 raise
 
-    daklib.utils.fubar("Couldn't obtain lock for %s." % (lockfile))
+    utils.fubar("Couldn't obtain lock for %s." % (f))
 
 ################################################################################
 
@@ -276,7 +276,7 @@ def edit_transitions():
         result = os.system("%s %s" % (editor, edit_file))
         if result != 0:
             os.unlink(edit_file)
-            daklib.utils.fubar("%s invocation failed for %s, not removing tempfile." % (editor, edit_file))
+            utils.fubar("%s invocation failed for %s, not removing tempfile." % (editor, edit_file))
 
         # Now try to load the new file
         test = load_transitions(edit_file)
@@ -297,7 +297,7 @@ def edit_transitions():
 
         answer = "XXX"
         while prompt.find(answer) == -1:
-            answer = daklib.utils.our_raw_input(prompt)
+            answer = utils.our_raw_input(prompt)
             if answer == "":
                 answer = default
             answer = answer[:1].upper()
@@ -333,7 +333,7 @@ def check_transitions(transitions):
         expected = t["new"]
 
         # Will be None if nothing is in testing.
-        current = daklib.database.get_suite_version(source, "testing")
+        current = database.get_suite_version(source, "testing")
 
         print_info(trans, source, expected, t["rm"], t["reason"], t["packages"])
 
@@ -365,7 +365,7 @@ def check_transitions(transitions):
         if Options["no-action"]:
             answer="n"
         else:
-            answer = daklib.utils.our_raw_input(prompt).lower()
+            answer = utils.our_raw_input(prompt).lower()
 
         if answer == "":
             answer = "n"
@@ -407,7 +407,7 @@ def transition_info(transitions):
         expected = t["new"]
 
         # Will be None if nothing is in testing.
-        current = daklib.database.get_suite_version(source, "testing")
+        current = database.get_suite_version(source, "testing")
 
         print_info(trans, source, expected, t["rm"], t["reason"], t["packages"])
 
@@ -439,19 +439,19 @@ def main():
     # Check if there is a file defined (and existant)
     transpath = Cnf.get("Dinstall::Reject::ReleaseTransitions", "")
     if transpath == "":
-        daklib.utils.warn("Dinstall::Reject::ReleaseTransitions not defined")
+        utils.warn("Dinstall::Reject::ReleaseTransitions not defined")
         sys.exit(1)
     if not os.path.exists(transpath):
-        daklib.utils.warn("ReleaseTransitions file, %s, not found." %
+        utils.warn("ReleaseTransitions file, %s, not found." %
                           (Cnf["Dinstall::Reject::ReleaseTransitions"]))
         sys.exit(1)
     # Also check if our temp directory is defined and existant
     temppath = Cnf.get("Transitions::TempPath", "")
     if temppath == "":
-        daklib.utils.warn("Transitions::TempPath not defined")
+        utils.warn("Transitions::TempPath not defined")
         sys.exit(1)
     if not os.path.exists(temppath):
-        daklib.utils.warn("Temporary path %s not found." %
+        utils.warn("Temporary path %s not found." %
                           (Cnf["Transitions::TempPath"]))
         sys.exit(1)
 
@@ -470,7 +470,7 @@ def main():
     transitions = load_transitions(transpath)
     if transitions == None:
         # Something very broken with the transitions, exit
-        daklib.utils.warn("Could not parse existing transitions file. Aborting.")
+        utils.warn("Could not parse existing transitions file. Aborting.")
         sys.exit(2)
 
     if Options["edit"]: