From: Mark Hymers Date: Sun, 28 Aug 2011 19:23:24 +0000 (+0100) Subject: Merge remote branch 'ansgar/auditpackages' X-Git-Url: https://git.decadent.org.uk/gitweb/?a=commitdiff_plain;h=1c2f5f4048b36efb345a3aa96b20d60dc7af1990;hp=4c6d9d52eddb26028e5328e30c2d312bc45f3906;p=dak.git Merge remote branch 'ansgar/auditpackages' Signed-off-by: Mark Hymers --- diff --git a/dak/add_user.py b/dak/add_user.py index f2391bd6..8ab4d230 100755 --- a/dak/add_user.py +++ b/dak/add_user.py @@ -66,7 +66,7 @@ def HashPass(Password): Salt = Salt + SaltVals[ord(Rand.read(1)[0]) % len(SaltVals)] Pass = crypt.crypt(Password,Salt) if len(Pass) < 14: - raise "Password Error", "MD5 password hashing failed, not changing the password!" + raise RuntimeError("MD5 password hashing failed, not changing the password!") return Pass ################################################################################ diff --git a/dak/admin.py b/dak/admin.py index fe369b51..e109877f 100755 --- a/dak/admin.py +++ b/dak/admin.py @@ -137,9 +137,9 @@ def __architecture_add(d, args): else: warn("W: Cannot find suite %s" % su) s.commit() - except IntegrityError, e: + except IntegrityError as e: die("E: Integrity error adding architecture %s (it probably already exists)" % args[2]) - except SQLAlchemyError, e: + except SQLAlchemyError as e: die("E: Error adding architecture %s (%s)" % (args[2], e)) print "Architecture %s added" % (args[2]) @@ -154,9 +154,9 @@ def __architecture_rm(d, args): die("E: Cannot find architecture %s" % args[2]) s.delete(a) s.commit() - except IntegrityError, e: + except IntegrityError as e: die("E: Integrity error removing architecture %s (suite-arch entries probably still exist)" % args[2]) - except SQLAlchemyError, e: + except SQLAlchemyError as e: die("E: Error removing architecture %s (%s)" % (args[2], e)) print "Architecture %s removed" % args[2] @@ -228,9 +228,9 @@ def __suite_add(d, args, addallarches=False): suite.srcformats = s.query(SrcFormat).all() s.add(suite) s.flush() - except IntegrityError, e: + except IntegrityError as e: die("E: Integrity error adding suite %s (it probably already exists)" % suite_name) - except SQLAlchemyError, e: + except SQLAlchemyError as e: die("E: Error adding suite %s (%s)" % (suite_name, e)) print "Suite %s added" % (suite_name) @@ -313,9 +313,9 @@ def __suite_architecture_add(d, args): try: suite.architectures.append(arch) s.commit() - except IntegrityError, e: + except IntegrityError as e: die("E: Can't add suite-architecture entry (%s, %s) - probably already exists" % (args[2].lower(), args[3].lower())) - except SQLAlchemyError, e: + except SQLAlchemyError as e: die("E: Can't add suite-architecture entry (%s, %s) - %s" % (args[2].lower(), args[3].lower(), e)) print "Added suite-architecture entry for %s, %s" % (args[2].lower(), args[3].lower()) @@ -338,9 +338,9 @@ def __suite_architecture_rm(d, args): die("E: architecture %s not found in suite %s" % (arch_string, suite_name)) suite.architectures.remove(architecture) s.commit() - except IntegrityError, e: + except IntegrityError as e: die("E: Can't remove suite-architecture entry (%s, %s) - it's probably referenced" % (args[2].lower(), args[3].lower())) - except SQLAlchemyError, e: + except SQLAlchemyError as e: die("E: Can't remove suite-architecture entry (%s, %s) - %s" % (args[2].lower(), args[3].lower(), e)) print "Removed suite-architecture entry for %s, %s" % (args[2].lower(), args[3].lower()) diff --git a/dak/check_archive.py b/dak/check_archive.py index 1fb8560b..89c3dcbd 100755 --- a/dak/check_archive.py +++ b/dak/check_archive.py @@ -164,7 +164,7 @@ def check_dscs(): except CantOpenError: utils.warn("missing dsc file (%s)" % f) count += 1 - except Exception, e: + except Exception as e: utils.warn("miscellaneous error parsing dsc file (%s): %s" % (f, str(e))) count += 1 diff --git a/dak/clean_queues.py b/dak/clean_queues.py index 390c2551..e6e4f76c 100755 --- a/dak/clean_queues.py +++ b/dak/clean_queues.py @@ -86,7 +86,7 @@ def init (cnf): # Ensure a directory exists to remove files to if not Options["No-Action"]: if not os.path.exists(del_dir): - os.makedirs(del_dir, 02775) + os.makedirs(del_dir, 0o2775) if not os.path.isdir(del_dir): utils.fubar("%s must be a directory." % (del_dir)) @@ -100,7 +100,7 @@ def init (cnf): try: os.chdir(incoming) - except OSError, e: + except OSError as e: utils.fubar("Cannot chdir to %s" % incoming) # Remove a file to the morgue @@ -118,7 +118,7 @@ def remove (from_dir, f): if os.path.exists(dest_filename): dest_filename = utils.find_next_free(dest_filename, 10) Logger.log(["change destination file name", os.path.basename(dest_filename)]) - utils.move(f, dest_filename, 0660) + utils.move(f, dest_filename, 0o660) else: Logger.log(["skipping file because of permission problem", fname]) utils.warn("skipping '%s', permission denied." % fname) @@ -157,7 +157,7 @@ def flush_orphans (): changes = utils.parse_changes(changes_filename) files = utils.build_file_list(changes) except: - 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_info()[0])) continue dsc_files = {} @@ -167,7 +167,7 @@ def flush_orphans (): dsc = utils.parse_changes(f, dsc_file=1) dsc_files = utils.build_file_list(dsc, is_a_dsc=1) except: - utils.warn("error processing '%s'; skipping it. [Got %s]" % (f, sys.exc_type)) + utils.warn("error processing '%s'; skipping it. [Got %s]" % (f, sys.exc_info()[0])) continue # Ensure all the files we've seen aren't deleted diff --git a/dak/clean_suites.py b/dak/clean_suites.py index 9713de34..806549e3 100755 --- a/dak/clean_suites.py +++ b/dak/clean_suites.py @@ -424,7 +424,7 @@ def main(): max_delete = int(cnf["Clean-Suites::Options::Maximum"]) if max_delete < 1: utils.fubar("If given, Maximum must be at least 1") - except ValueError, e: + except ValueError as e: utils.fubar("If given, Maximum must be an integer") else: max_delete = None diff --git a/dak/control_suite.py b/dak/control_suite.py index 6dd79b8f..57e43da6 100755 --- a/dak/control_suite.py +++ b/dak/control_suite.py @@ -396,7 +396,7 @@ def main (): try: file_list = apt_pkg.ParseCommandLine(cnf.Cnf, Arguments, sys.argv); - except SystemError, e: + except SystemError as e: print "%s\n" % e usage(1) Options = cnf.SubTree("Control-Suite::Options") diff --git a/dak/dakdb/update1.py b/dak/dakdb/update1.py index 0c833773..21942765 100755 --- a/dak/dakdb/update1.py +++ b/dak/dakdb/update1.py @@ -64,6 +64,6 @@ def do_update(self): print "Pausing for five seconds ..." time.sleep (5) - except psycopg2.ProgrammingError, msg: + except psycopg2.ProgrammingError as msg: self.db.rollback() - raise DBUpdateError, "Unable to appy DM table updates, rollback issued. Error message : %s" % (str(msg)) + raise DBUpdateError("Unable to appy DM table updates, rollback issued. Error message : %s" % (str(msg))) diff --git a/dak/dakdb/update10.py b/dak/dakdb/update10.py index 5cd4f30d..31c70d37 100755 --- a/dak/dakdb/update10.py +++ b/dak/dakdb/update10.py @@ -51,6 +51,6 @@ def do_update(self): c.execute("UPDATE config SET value = '10' WHERE name = 'db_revision'") self.db.commit() - except psycopg2.ProgrammingError, msg: + except psycopg2.ProgrammingError as msg: self.db.rollback() - raise DBUpdateError, "Unable to apply suite config updates, rollback issued. Error message : %s" % (str(msg)) + raise DBUpdateError("Unable to apply suite config updates, rollback issued. Error message : %s" % (str(msg))) diff --git a/dak/dakdb/update11.py b/dak/dakdb/update11.py index a4797cb4..17001d39 100755 --- a/dak/dakdb/update11.py +++ b/dak/dakdb/update11.py @@ -58,6 +58,6 @@ def do_update(self): c.execute("UPDATE config SET value = '11' WHERE name = 'db_revision'") self.db.commit() - except psycopg2.ProgrammingError, msg: + except psycopg2.ProgrammingError as msg: self.db.rollback() - raise DBUpdateError, "Unable to apply process-new comments update, rollback issued. Error message : %s" % (str(msg)) + raise DBUpdateError("Unable to apply process-new comments update, rollback issued. Error message : %s" % (str(msg))) diff --git a/dak/dakdb/update12.py b/dak/dakdb/update12.py index 890f51cb..21d44a45 100755 --- a/dak/dakdb/update12.py +++ b/dak/dakdb/update12.py @@ -44,6 +44,6 @@ def do_update(self): c.execute("UPDATE config SET value = '12' WHERE name = 'db_revision'") self.db.commit() - except psycopg2.ProgrammingError, msg: + except psycopg2.ProgrammingError as msg: self.db.rollback() - raise DBUpdateError, "Unable to apply process-new update 12, rollback issued. Error message : %s" % (str(msg)) + raise DBUpdateError("Unable to apply process-new update 12, rollback issued. Error message : %s" % (str(msg))) diff --git a/dak/dakdb/update13.py b/dak/dakdb/update13.py index d5dbedce..1696e759 100755 --- a/dak/dakdb/update13.py +++ b/dak/dakdb/update13.py @@ -44,6 +44,6 @@ def do_update(self): c.execute("UPDATE config SET value = '13' WHERE name = 'db_revision'") self.db.commit() - except psycopg2.ProgrammingError, msg: + except psycopg2.ProgrammingError as msg: self.db.rollback() - raise DBUpdateError, "Unable to apply process-new update 13, rollback issued. Error message : %s" % (str(msg)) + raise DBUpdateError("Unable to apply process-new update 13, rollback issued. Error message : %s" % (str(msg))) diff --git a/dak/dakdb/update14.py b/dak/dakdb/update14.py index 4f1b1dac..575e5d23 100755 --- a/dak/dakdb/update14.py +++ b/dak/dakdb/update14.py @@ -48,6 +48,6 @@ def do_update(self): c.execute("UPDATE config SET value = '14' WHERE name = 'db_revision'") self.db.commit() - except psycopg2.ProgrammingError, msg: + except psycopg2.ProgrammingError as msg: self.db.rollback() - raise DBUpdateError, "Unable to apply process-new update 14, rollback issued. Error message : %s" % (str(msg)) + raise DBUpdateError("Unable to apply process-new update 14, rollback issued. Error message : %s" % (str(msg))) diff --git a/dak/dakdb/update15.py b/dak/dakdb/update15.py index 535f9e67..7d6b52e7 100755 --- a/dak/dakdb/update15.py +++ b/dak/dakdb/update15.py @@ -79,6 +79,6 @@ def do_update(self): c.execute("UPDATE config SET value = '15' WHERE name = 'db_revision'") self.db.commit() - except psycopg2.ProgrammingError, msg: + except psycopg2.ProgrammingError as msg: self.db.rollback() - raise DBUpdateError, "Unable to apply source format update 15, rollback issued. Error message : %s" % (str(msg)) + raise DBUpdateError("Unable to apply source format update 15, rollback issued. Error message : %s" % (str(msg))) diff --git a/dak/dakdb/update16.py b/dak/dakdb/update16.py index eca9b48e..6cd6dc4b 100755 --- a/dak/dakdb/update16.py +++ b/dak/dakdb/update16.py @@ -173,6 +173,6 @@ def do_update(self): c.execute("UPDATE config SET value = '16' WHERE name = 'db_revision'") self.db.commit() - except psycopg2.ProgrammingError, msg: + except psycopg2.ProgrammingError as msg: self.db.rollback() - raise DBUpdateError, "Unable to apply ACLs update (16), rollback issued. Error message : %s" % (str(msg)) + raise DBUpdateError("Unable to apply ACLs update (16), rollback issued. Error message : %s" % (str(msg))) diff --git a/dak/dakdb/update17.py b/dak/dakdb/update17.py index beca9425..493640eb 100755 --- a/dak/dakdb/update17.py +++ b/dak/dakdb/update17.py @@ -58,9 +58,9 @@ def do_update(self): self.db.commit() - except psycopg2.ProgrammingError, msg: + except psycopg2.ProgrammingError as msg: self.db.rollback() - raise DBUpdateError, "Unable to apply process-new update 17, rollback issued. Error message : %s" % (str(msg)) + raise DBUpdateError("Unable to apply process-new update 17, rollback issued. Error message : %s" % (str(msg))) diff --git a/dak/dakdb/update18.py b/dak/dakdb/update18.py index ce0086f6..bdf24108 100755 --- a/dak/dakdb/update18.py +++ b/dak/dakdb/update18.py @@ -144,13 +144,13 @@ def do_update(self): changes.changes = parse_changes(changesfile, signing_rules=-1) changes.changes["fingerprint"] = check_signature(changesfile) changes.add_known_changes(directory) - except InvalidDscError, line: + except InvalidDscError as line: warn("syntax error in .dsc file '%s', line %s." % (f, line)) failure += 1 except ChangesUnicodeError: warn("found invalid changes file, not properly utf-8 encoded") failure += 1 - except psycopg2.ProgrammingError, msg: + except psycopg2.ProgrammingError as msg: self.db.rollback() - raise DBUpdateError, "Unable to apply knownchanges update 18, rollback issued. Error message : %s" % (str(msg)) + raise DBUpdateError("Unable to apply knownchanges update 18, rollback issued. Error message : %s" % (str(msg))) diff --git a/dak/dakdb/update19.py b/dak/dakdb/update19.py index 49a4dbc7..61e60703 100755 --- a/dak/dakdb/update19.py +++ b/dak/dakdb/update19.py @@ -102,6 +102,6 @@ def do_update(self): c.execute("UPDATE config SET value = '19' WHERE name = 'db_revision'") self.db.commit() - except psycopg2.InternalError, msg: + except psycopg2.InternalError as msg: self.db.rollback() - raise DBUpdateError, "Unable to apply debversion update 19, rollback issued. Error message : %s" % (str(msg)) + raise DBUpdateError("Unable to apply debversion update 19, rollback issued. Error message : %s" % (str(msg))) diff --git a/dak/dakdb/update2.py b/dak/dakdb/update2.py index 2e3cb446..0d9d3871 100755 --- a/dak/dakdb/update2.py +++ b/dak/dakdb/update2.py @@ -396,6 +396,6 @@ $$ self.db.commit() - except psycopg2.ProgrammingError, msg: + except psycopg2.ProgrammingError as msg: self.db.rollback() - raise DBUpdateError, "Unable to appy debversion updates, rollback issued. Error message : %s" % (str(msg)) + raise DBUpdateError("Unable to appy debversion updates, rollback issued. Error message : %s" % (str(msg))) diff --git a/dak/dakdb/update20.py b/dak/dakdb/update20.py index f4e34cb9..c1424ab2 100755 --- a/dak/dakdb/update20.py +++ b/dak/dakdb/update20.py @@ -95,6 +95,6 @@ def do_update(self): c.execute("UPDATE config SET value = '20' WHERE name = 'db_revision'") self.db.commit() - except psycopg2.InternalError, msg: + except psycopg2.InternalError as msg: self.db.rollback() - raise DBUpdateError, "Unable to apply debversion update 20, rollback issued. Error message : %s" % (str(msg)) + raise DBUpdateError("Unable to apply debversion update 20, rollback issued. Error message : %s" % (str(msg))) diff --git a/dak/dakdb/update21.py b/dak/dakdb/update21.py index 8e36883f..c91b6f14 100755 --- a/dak/dakdb/update21.py +++ b/dak/dakdb/update21.py @@ -74,7 +74,7 @@ def do_update(self): f = c.fetchone() c.execute("""INSERT INTO queue_files (queueid, lastused, filename, fileid) VALUES (%s, now(), %s, %s)""", (queue, filename[filename.rindex('/')+1:], f[0])) - except OSError, e: + except OSError as e: print "Can't find file %s (%s)" % (filename, e) print "Dropping old queue_build table" @@ -124,6 +124,6 @@ def do_update(self): c.execute("UPDATE config SET value = '21' WHERE name = 'db_revision'") self.db.commit() - except psycopg2.InternalError, msg: + except psycopg2.InternalError as msg: self.db.rollback() - raise DBUpdateError, "Unable to apply queue_build 21, rollback issued. Error message : %s" % (str(msg)) + raise DBUpdateError("Unable to apply queue_build 21, rollback issued. Error message : %s" % (str(msg))) diff --git a/dak/dakdb/update22.py b/dak/dakdb/update22.py index dbd7ced6..5c852c67 100755 --- a/dak/dakdb/update22.py +++ b/dak/dakdb/update22.py @@ -235,6 +235,6 @@ def do_update(self): c.execute("UPDATE config SET value = '22' WHERE name = 'db_revision'") self.db.commit() - except psycopg2.InternalError, msg: + except psycopg2.InternalError as msg: self.db.rollback() - raise DBUpdateError, "Unable to apply queue_build 21, rollback issued. Error message : %s" % (str(msg)) + raise DBUpdateError("Unable to apply queue_build 21, rollback issued. Error message : %s" % (str(msg))) diff --git a/dak/dakdb/update23.py b/dak/dakdb/update23.py index 48abf016..4750c153 100755 --- a/dak/dakdb/update23.py +++ b/dak/dakdb/update23.py @@ -58,7 +58,7 @@ CREATE VIEW srcfiles_suite_component AS c.execute("UPDATE config SET value = '23' WHERE name = 'db_revision'") self.db.commit() - except psycopg2.InternalError, msg: + except psycopg2.InternalError as msg: self.db.rollback() - raise DBUpdateError, "Database error, rollback issued. Error message : %s" % (str(msg)) + raise DBUpdateError("Database error, rollback issued. Error message : %s" % (str(msg))) diff --git a/dak/dakdb/update24.py b/dak/dakdb/update24.py index 4e8c505d..64deb96e 100755 --- a/dak/dakdb/update24.py +++ b/dak/dakdb/update24.py @@ -56,7 +56,7 @@ def do_update(self): c.execute("UPDATE config SET value = '24' WHERE name = 'db_revision'") self.db.commit() - except psycopg2.InternalError, msg: + except psycopg2.InternalError as msg: self.db.rollback() - raise DBUpdateError, "Database error, rollback issued. Error message : %s" % (str(msg)) + raise DBUpdateError("Database error, rollback issued. Error message : %s" % (str(msg))) diff --git a/dak/dakdb/update25.py b/dak/dakdb/update25.py index b2813d91..0ce8ab6e 100755 --- a/dak/dakdb/update25.py +++ b/dak/dakdb/update25.py @@ -183,7 +183,7 @@ CREATE VIEW obsolete_all_associations AS c.execute("UPDATE config SET value = '25' WHERE name = 'db_revision'") self.db.commit() - except psycopg2.InternalError, msg: + except psycopg2.InternalError as msg: self.db.rollback() - raise DBUpdateError, "Database error, rollback issued. Error message : %s" % (str(msg)) + raise DBUpdateError("Database error, rollback issued. Error message : %s" % (str(msg))) diff --git a/dak/dakdb/update26.py b/dak/dakdb/update26.py index 1b9a7fc1..358f2ae4 100755 --- a/dak/dakdb/update26.py +++ b/dak/dakdb/update26.py @@ -61,7 +61,7 @@ def do_update(self): c.execute("UPDATE config SET value = '26' WHERE name = 'db_revision'") self.db.commit() - except psycopg2.InternalError, msg: + except psycopg2.InternalError as msg: self.db.rollback() - raise DBUpdateError, "Database error, rollback issued. Error message : %s" % (str(msg)) + raise DBUpdateError("Database error, rollback issued. Error message : %s" % (str(msg))) diff --git a/dak/dakdb/update27.py b/dak/dakdb/update27.py index b06932b5..814e6015 100755 --- a/dak/dakdb/update27.py +++ b/dak/dakdb/update27.py @@ -74,7 +74,7 @@ CREATE OR REPLACE VIEW bin_associations_binaries AS c.execute("UPDATE config SET value = '27' WHERE name = 'db_revision'") self.db.commit() - except psycopg2.InternalError, msg: + except psycopg2.InternalError as msg: self.db.rollback() - raise DBUpdateError, "Database error, rollback issued. Error message : %s" % (str(msg)) + raise DBUpdateError("Database error, rollback issued. Error message : %s" % (str(msg))) diff --git a/dak/dakdb/update28.py b/dak/dakdb/update28.py index 79b0e8db..1455ee31 100755 --- a/dak/dakdb/update28.py +++ b/dak/dakdb/update28.py @@ -265,7 +265,7 @@ $$ LANGUAGE plpythonu VOLATILE;""") self.db.commit() - except psycopg2.ProgrammingError, msg: + except psycopg2.ProgrammingError as msg: self.db.rollback() - raise DBUpdateError, "Unable to apply process-new update 28, rollback issued. Error message : %s" % (str(msg)) + raise DBUpdateError("Unable to apply process-new update 28, rollback issued. Error message : %s" % (str(msg))) diff --git a/dak/dakdb/update29.py b/dak/dakdb/update29.py index d25c1011..c77d99da 100644 --- a/dak/dakdb/update29.py +++ b/dak/dakdb/update29.py @@ -47,6 +47,6 @@ def do_update(self): c.execute("UPDATE config SET value = '29' WHERE name = 'db_revision'") self.db.commit() - except psycopg2.ProgrammingError, msg: + except psycopg2.ProgrammingError as msg: self.db.rollback() - raise DBUpdateError, "Unable to appy debversion updates, rollback issued. Error message : %s" % (str(msg)) + raise DBUpdateError("Unable to appy debversion updates, rollback issued. Error message : %s" % (str(msg))) diff --git a/dak/dakdb/update3.py b/dak/dakdb/update3.py index 5a5562fb..f7a4e502 100755 --- a/dak/dakdb/update3.py +++ b/dak/dakdb/update3.py @@ -49,6 +49,6 @@ def do_update(self): self.db.commit() - except psycopg2.ProgrammingError, msg: + except psycopg2.ProgrammingError as msg: self.db.rollback() - raise DBUpdateError, "Unable to appy versioncmp removal, rollback issued. Error message : %s" % (str(msg)) + raise DBUpdateError("Unable to appy versioncmp removal, rollback issued. Error message : %s" % (str(msg))) diff --git a/dak/dakdb/update30.py b/dak/dakdb/update30.py index 2d962749..f68c74a3 100644 --- a/dak/dakdb/update30.py +++ b/dak/dakdb/update30.py @@ -95,6 +95,6 @@ $$ LANGUAGE plpythonu VOLATILE SECURITY DEFINER; c.execute("UPDATE config SET value = '30' WHERE name = 'db_revision'") self.db.commit() - except psycopg2.ProgrammingError, msg: + except psycopg2.ProgrammingError as msg: self.db.rollback() - raise DBUpdateError, "Unable to appy debversion updates, rollback issued. Error message : %s" % (str(msg)) + raise DBUpdateError("Unable to appy debversion updates, rollback issued. Error message : %s" % (str(msg))) diff --git a/dak/dakdb/update31.py b/dak/dakdb/update31.py index 8ebfe342..7209178b 100644 --- a/dak/dakdb/update31.py +++ b/dak/dakdb/update31.py @@ -94,7 +94,7 @@ $$ LANGUAGE plpythonu VOLATILE SECURITY DEFINER; c.execute("UPDATE config SET value = '31' WHERE name = 'db_revision'") self.db.commit() - except psycopg2.ProgrammingError, msg: + except psycopg2.ProgrammingError as msg: self.db.rollback() - raise DBUpdateError, "Unable to apply process-new update 31, rollback issued. Error message : %s" % (str(msg)) + raise DBUpdateError("Unable to apply process-new update 31, rollback issued. Error message : %s" % (str(msg))) diff --git a/dak/dakdb/update32.py b/dak/dakdb/update32.py index 98eaa4e6..59355c91 100755 --- a/dak/dakdb/update32.py +++ b/dak/dakdb/update32.py @@ -44,7 +44,7 @@ def do_update(self): c.execute("UPDATE config SET value = '32' WHERE name = 'db_revision'") self.db.commit() - except psycopg2.ProgrammingError, msg: + except psycopg2.ProgrammingError as msg: self.db.rollback() - raise DBUpdateError, "Unable to apply build_queue update 32, rollback issued. Error message : %s" % (str(msg)) + raise DBUpdateError("Unable to apply build_queue update 32, rollback issued. Error message : %s" % (str(msg))) diff --git a/dak/dakdb/update33.py b/dak/dakdb/update33.py index 9624ba62..5b0fe110 100644 --- a/dak/dakdb/update33.py +++ b/dak/dakdb/update33.py @@ -50,6 +50,6 @@ def do_update(self): c.execute("UPDATE config SET value = '33' WHERE name = 'db_revision'") self.db.commit() - except psycopg2.ProgrammingError, msg: + except psycopg2.ProgrammingError as msg: self.db.rollback() - raise DBUpdateError, 'Unable to apply build_queue update 33, rollback issued. Error message : %s' % (str(msg)) + raise DBUpdateError('Unable to apply build_queue update 33, rollback issued. Error message : %s' % (str(msg))) diff --git a/dak/dakdb/update34.py b/dak/dakdb/update34.py index ea0535db..03f15739 100644 --- a/dak/dakdb/update34.py +++ b/dak/dakdb/update34.py @@ -43,6 +43,6 @@ def do_update(self): c.execute("UPDATE config SET value = '34' WHERE name = 'db_revision'") self.db.commit() - except psycopg2.ProgrammingError, msg: + except psycopg2.ProgrammingError as msg: self.db.rollback() - raise DBUpdateError, 'Unable to apply build_queue update 34, rollback issued. Error message : %s' % (str(msg)) + raise DBUpdateError('Unable to apply build_queue update 34, rollback issued. Error message : %s' % (str(msg))) diff --git a/dak/dakdb/update35.py b/dak/dakdb/update35.py index 335d70e5..41d56674 100644 --- a/dak/dakdb/update35.py +++ b/dak/dakdb/update35.py @@ -45,6 +45,6 @@ def do_update(self): c.execute("UPDATE config SET value = '35' WHERE name = 'db_revision'") self.db.commit() - except psycopg2.ProgrammingError, msg: + except psycopg2.ProgrammingError as msg: self.db.rollback() - raise DBUpdateError, 'Unable to apply build_queue update 35, rollback issued. Error message : %s' % (str(msg)) + raise DBUpdateError('Unable to apply build_queue update 35, rollback issued. Error message : %s' % (str(msg))) diff --git a/dak/dakdb/update36.py b/dak/dakdb/update36.py index d5810f68..432e09f3 100644 --- a/dak/dakdb/update36.py +++ b/dak/dakdb/update36.py @@ -43,6 +43,6 @@ def do_update(self): c.execute("UPDATE config SET value = '36' WHERE name = 'db_revision'") self.db.commit() - except psycopg2.ProgrammingError, msg: + except psycopg2.ProgrammingError as msg: self.db.rollback() - raise DBUpdateError, 'Unable to apply build_queue update 36, rollback issued. Error message : %s' % (str(msg)) + raise DBUpdateError('Unable to apply build_queue update 36, rollback issued. Error message : %s' % (str(msg))) diff --git a/dak/dakdb/update37.py b/dak/dakdb/update37.py index 5a6714bb..7ab52e04 100755 --- a/dak/dakdb/update37.py +++ b/dak/dakdb/update37.py @@ -52,6 +52,6 @@ def do_update(self): c.execute("UPDATE config SET value = '37' WHERE name = 'db_revision'") self.db.commit() - except psycopg2.ProgrammingError, msg: + except psycopg2.ProgrammingError as msg: self.db.rollback() - raise DBUpdateError, 'Unable to apply table-colum update 37, rollback issued. Error message : %s' % (str(msg)) + raise DBUpdateError('Unable to apply table-colum update 37, rollback issued. Error message : %s' % (str(msg))) diff --git a/dak/dakdb/update38.py b/dak/dakdb/update38.py index 583aa3ad..da3a1d65 100755 --- a/dak/dakdb/update38.py +++ b/dak/dakdb/update38.py @@ -51,6 +51,6 @@ def do_update(self): c.execute("UPDATE config SET value = '38' WHERE name = 'db_revision'") self.db.commit() - except psycopg2.ProgrammingError, msg: + except psycopg2.ProgrammingError as msg: self.db.rollback() - raise DBUpdateError, 'Unable to apply table-column update 38, rollback issued. Error message : %s' % (str(msg)) + raise DBUpdateError('Unable to apply table-column update 38, rollback issued. Error message : %s' % (str(msg))) diff --git a/dak/dakdb/update39.py b/dak/dakdb/update39.py index 8086b515..c02b9629 100644 --- a/dak/dakdb/update39.py +++ b/dak/dakdb/update39.py @@ -42,6 +42,6 @@ def do_update(self): c.execute("UPDATE config SET value = '39' WHERE name = 'db_revision'") self.db.commit() - except psycopg2.ProgrammingError, msg: + except psycopg2.ProgrammingError as msg: self.db.rollback() - raise DBUpdateError, 'Unable to apply table-column update 39, rollback issued. Error message : %s' % (str(msg)) + raise DBUpdateError('Unable to apply table-column update 39, rollback issued. Error message : %s' % (str(msg))) diff --git a/dak/dakdb/update4.py b/dak/dakdb/update4.py index 477944c8..938522cc 100755 --- a/dak/dakdb/update4.py +++ b/dak/dakdb/update4.py @@ -64,6 +64,6 @@ def do_update(self): self.db.commit() - except psycopg2.ProgrammingError, msg: + except psycopg2.ProgrammingError as msg: self.db.rollback() - raise DBUpdateError, "Unable to apply sanity to suite_architecture table, rollback issued. Error message : %s" % (str(msg)) + raise DBUpdateError("Unable to apply sanity to suite_architecture table, rollback issued. Error message : %s" % (str(msg))) diff --git a/dak/dakdb/update40.py b/dak/dakdb/update40.py index 062b0dd8..e3bb89e0 100755 --- a/dak/dakdb/update40.py +++ b/dak/dakdb/update40.py @@ -44,6 +44,6 @@ def do_update(self): c.execute("UPDATE config SET value = '40' WHERE name = 'db_revision'") self.db.commit() - except psycopg2.ProgrammingError, msg: + except psycopg2.ProgrammingError as msg: self.db.rollback() - raise DBUpdateError, 'Unable to apply sick update 40, rollback issued. Error message : %s' % (str(msg)) + raise DBUpdateError('Unable to apply sick update 40, rollback issued. Error message : %s' % (str(msg))) diff --git a/dak/dakdb/update41.py b/dak/dakdb/update41.py index 813a3b70..65661d3c 100755 --- a/dak/dakdb/update41.py +++ b/dak/dakdb/update41.py @@ -61,6 +61,6 @@ def do_update(self): c.execute("UPDATE config SET value = '41' WHERE name = 'db_revision'") self.db.commit() - except psycopg2.ProgrammingError, msg: + except psycopg2.ProgrammingError as msg: self.db.rollback() - raise DBUpdateError, 'Unable to apply sick update 41, rollback issued. Error message : %s' % (str(msg)) + raise DBUpdateError('Unable to apply sick update 41, rollback issued. Error message : %s' % (str(msg))) diff --git a/dak/dakdb/update42.py b/dak/dakdb/update42.py index 48bc9d61..3c51232c 100755 --- a/dak/dakdb/update42.py +++ b/dak/dakdb/update42.py @@ -44,6 +44,6 @@ def do_update(self): c.execute("UPDATE config SET value = '42' WHERE name = 'db_revision'") self.db.commit() - except psycopg2.ProgrammingError, msg: + except psycopg2.ProgrammingError as msg: self.db.rollback() - raise DBUpdateError, 'Unable to apply update 42, rollback issued. Error message : %s' % (str(msg)) + raise DBUpdateError('Unable to apply update 42, rollback issued. Error message : %s' % (str(msg))) diff --git a/dak/dakdb/update43.py b/dak/dakdb/update43.py index 07154105..430cc358 100755 --- a/dak/dakdb/update43.py +++ b/dak/dakdb/update43.py @@ -46,6 +46,6 @@ def do_update(self): c.execute("UPDATE config SET value = '43' WHERE name = 'db_revision'") self.db.commit() - except psycopg2.ProgrammingError, msg: + except psycopg2.ProgrammingError as msg: self.db.rollback() - raise DBUpdateError, 'Unable to apply update 43, rollback issued. Error message : %s' % (str(msg)) + raise DBUpdateError('Unable to apply update 43, rollback issued. Error message : %s' % (str(msg))) diff --git a/dak/dakdb/update44.py b/dak/dakdb/update44.py index 465f2fce..bce1fe7d 100755 --- a/dak/dakdb/update44.py +++ b/dak/dakdb/update44.py @@ -47,6 +47,6 @@ def do_update(self): c.execute("UPDATE config SET value = '44' WHERE name = 'db_revision'") self.db.commit() - except psycopg2.ProgrammingError, msg: + except psycopg2.ProgrammingError as msg: self.db.rollback() - raise DBUpdateError, 'Unable to apply sick update 44, rollback issued. Error message : %s' % (str(msg)) + raise DBUpdateError('Unable to apply sick update 44, rollback issued. Error message : %s' % (str(msg))) diff --git a/dak/dakdb/update45.py b/dak/dakdb/update45.py index 32ed04f0..fe84c9be 100755 --- a/dak/dakdb/update45.py +++ b/dak/dakdb/update45.py @@ -48,6 +48,6 @@ CREATE TABLE extra_src_references ( c.execute("UPDATE config SET value = '45' WHERE name = 'db_revision'") self.db.commit() - except psycopg2.ProgrammingError, msg: + except psycopg2.ProgrammingError as msg: self.db.rollback() - raise DBUpdateError, 'Unable to apply update 45, rollback issued. Error message : %s' % (str(msg)) + raise DBUpdateError('Unable to apply update 45, rollback issued. Error message : %s' % (str(msg))) diff --git a/dak/dakdb/update46.py b/dak/dakdb/update46.py index d1b2d3ac..109a887a 100755 --- a/dak/dakdb/update46.py +++ b/dak/dakdb/update46.py @@ -72,6 +72,6 @@ CREATE TABLE source_metadata ( c.execute("UPDATE config SET value = '46' WHERE name = 'db_revision'") self.db.commit() - except psycopg2.ProgrammingError, msg: + except psycopg2.ProgrammingError as msg: self.db.rollback() - raise DBUpdateError, 'Unable to apply update 46, rollback issued. Error message : %s' % (str(msg)) + raise DBUpdateError('Unable to apply update 46, rollback issued. Error message : %s' % (str(msg))) diff --git a/dak/dakdb/update47.py b/dak/dakdb/update47.py index 81d9cd78..a6626594 100755 --- a/dak/dakdb/update47.py +++ b/dak/dakdb/update47.py @@ -47,6 +47,6 @@ def do_update(self): c.execute("UPDATE config SET value = '47' WHERE name = 'db_revision'") self.db.commit() - except psycopg2.ProgrammingError, msg: + except psycopg2.ProgrammingError as msg: self.db.rollback() - raise DBUpdateError, 'Unable to apply sick update 47, rollback issued. Error message : %s' % (str(msg)) + raise DBUpdateError('Unable to apply sick update 47, rollback issued. Error message : %s' % (str(msg))) diff --git a/dak/dakdb/update48.py b/dak/dakdb/update48.py index 67ea8c5b..63a8a0e6 100755 --- a/dak/dakdb/update48.py +++ b/dak/dakdb/update48.py @@ -44,6 +44,6 @@ def do_update(self): c.execute("UPDATE config SET value = '48' WHERE name = 'db_revision'") self.db.commit() - except psycopg2.ProgrammingError, msg: + except psycopg2.ProgrammingError as msg: self.db.rollback() - raise DBUpdateError, 'Unable to apply sick update 48, rollback issued. Error message : %s' % (str(msg)) + raise DBUpdateError('Unable to apply sick update 48, rollback issued. Error message : %s' % (str(msg))) diff --git a/dak/dakdb/update49.py b/dak/dakdb/update49.py index 5ff1545c..720f8cf3 100755 --- a/dak/dakdb/update49.py +++ b/dak/dakdb/update49.py @@ -56,6 +56,6 @@ def do_update(self): c.execute("UPDATE config SET value = '49' WHERE name = 'db_revision'") self.db.commit() - except psycopg2.ProgrammingError, msg: + except psycopg2.ProgrammingError as msg: self.db.rollback() - raise DBUpdateError, 'Unable to apply sick update 49, rollback issued. Error message : %s' % (str(msg)) + raise DBUpdateError('Unable to apply sick update 49, rollback issued. Error message : %s' % (str(msg))) diff --git a/dak/dakdb/update5.py b/dak/dakdb/update5.py index 49e33891..a42e540c 100755 --- a/dak/dakdb/update5.py +++ b/dak/dakdb/update5.py @@ -46,6 +46,6 @@ def do_update(self): self.db.commit() - except psycopg2.ProgrammingError, msg: + except psycopg2.ProgrammingError as msg: self.db.rollback() - raise DBUpdateError, "Unable to recreate bin_assoc_by_arch view, rollback issued. Error message : %s" % (str(msg)) + raise DBUpdateError("Unable to recreate bin_assoc_by_arch view, rollback issued. Error message : %s" % (str(msg))) diff --git a/dak/dakdb/update50.py b/dak/dakdb/update50.py index ae7ea4d0..09499877 100755 --- a/dak/dakdb/update50.py +++ b/dak/dakdb/update50.py @@ -42,6 +42,6 @@ def do_update(self): c.execute("UPDATE config SET value = '50' WHERE name = 'db_revision'") self.db.commit() - except psycopg2.ProgrammingError, msg: + except psycopg2.ProgrammingError as msg: self.db.rollback() - raise DBUpdateError, 'Unable to apply sick update 50, rollback issued. Error message : %s' % (str(msg)) + raise DBUpdateError('Unable to apply sick update 50, rollback issued. Error message : %s' % (str(msg))) diff --git a/dak/dakdb/update51.py b/dak/dakdb/update51.py index 2aea858e..2d4c1a2c 100755 --- a/dak/dakdb/update51.py +++ b/dak/dakdb/update51.py @@ -53,6 +53,6 @@ def do_update(self): c.execute("UPDATE config SET value = '51' WHERE name = 'db_revision'") self.db.commit() - except psycopg2.ProgrammingError, msg: + except psycopg2.ProgrammingError as msg: self.db.rollback() - raise DBUpdateError, 'Unable to apply sick update 51, rollback issued. Error message : %s' % (str(msg)) + raise DBUpdateError('Unable to apply sick update 51, rollback issued. Error message : %s' % (str(msg))) diff --git a/dak/dakdb/update52.py b/dak/dakdb/update52.py index d38ee26f..aa7a10d1 100755 --- a/dak/dakdb/update52.py +++ b/dak/dakdb/update52.py @@ -61,6 +61,6 @@ def do_update(self): c.execute("UPDATE config SET value = '52' WHERE name = 'db_revision'") self.db.commit() - except psycopg2.ProgrammingError, msg: + except psycopg2.ProgrammingError as msg: self.db.rollback() - raise DBUpdateError, 'Unable to apply sick update 52, rollback issued. Error message : %s' % (str(msg)) + raise DBUpdateError('Unable to apply sick update 52, rollback issued. Error message : %s' % (str(msg))) diff --git a/dak/dakdb/update53.py b/dak/dakdb/update53.py index 36a076f6..92508257 100755 --- a/dak/dakdb/update53.py +++ b/dak/dakdb/update53.py @@ -50,6 +50,6 @@ def do_update(self): c.execute("UPDATE config SET value = '53' WHERE name = 'db_revision'") self.db.commit() - except psycopg2.ProgrammingError, msg: + except psycopg2.ProgrammingError as msg: self.db.rollback() - raise DBUpdateError, 'Unable to apply sick update 53, rollback issued. Error message : %s' % (str(msg)) + raise DBUpdateError('Unable to apply sick update 53, rollback issued. Error message : %s' % (str(msg))) diff --git a/dak/dakdb/update54.py b/dak/dakdb/update54.py index e7676ef0..c218cc67 100755 --- a/dak/dakdb/update54.py +++ b/dak/dakdb/update54.py @@ -47,6 +47,6 @@ def do_update(self): c.execute("UPDATE config SET value = '54' WHERE name = 'db_revision'") self.db.commit() - except psycopg2.ProgrammingError, msg: + except psycopg2.ProgrammingError as msg: self.db.rollback() - raise DBUpdateError, 'Unable to apply sick update 54, rollback issued. Error message : %s' % (str(msg)) + raise DBUpdateError('Unable to apply sick update 54, rollback issued. Error message : %s' % (str(msg))) diff --git a/dak/dakdb/update55.py b/dak/dakdb/update55.py index 3328e85c..9e152227 100755 --- a/dak/dakdb/update55.py +++ b/dak/dakdb/update55.py @@ -44,6 +44,6 @@ def do_update(self): c.execute("UPDATE config SET value = '55' WHERE name = 'db_revision'") self.db.commit() - except psycopg2.ProgrammingError, msg: + except psycopg2.ProgrammingError as msg: self.db.rollback() - raise DBUpdateError, 'Unable to apply sick update 55, rollback issued. Error message : %s' % (str(msg)) + raise DBUpdateError('Unable to apply sick update 55, rollback issued. Error message : %s' % (str(msg))) diff --git a/dak/dakdb/update56.py b/dak/dakdb/update56.py index f04ebc87..647f8c79 100755 --- a/dak/dakdb/update56.py +++ b/dak/dakdb/update56.py @@ -85,6 +85,6 @@ def do_update(self): c.execute("UPDATE config SET value = '56' WHERE name = 'db_revision'") self.db.commit() - except psycopg2.ProgrammingError, msg: + except psycopg2.ProgrammingError as msg: self.db.rollback() - raise DBUpdateError, 'Unable to apply sick update 56, rollback issued. Error message : %s' % (str(msg)) + raise DBUpdateError('Unable to apply sick update 56, rollback issued. Error message : %s' % (str(msg))) diff --git a/dak/dakdb/update57.py b/dak/dakdb/update57.py index 45a37dc6..db49db43 100755 --- a/dak/dakdb/update57.py +++ b/dak/dakdb/update57.py @@ -44,6 +44,6 @@ def do_update(self): c.execute("UPDATE config SET value = '57' WHERE name = 'db_revision'") self.db.commit() - except psycopg2.ProgrammingError, msg: + except psycopg2.ProgrammingError as msg: self.db.rollback() - raise DBUpdateError, 'Unable to apply sick update 57, rollback issued. Error message : %s' % (str(msg)) + raise DBUpdateError('Unable to apply sick update 57, rollback issued. Error message : %s' % (str(msg))) diff --git a/dak/dakdb/update58.py b/dak/dakdb/update58.py index 8680fc25..9f10d31b 100755 --- a/dak/dakdb/update58.py +++ b/dak/dakdb/update58.py @@ -85,6 +85,6 @@ def do_update(self): c.execute("UPDATE config SET value = '58' WHERE name = 'db_revision'") self.db.commit() - except psycopg2.ProgrammingError, msg: + except psycopg2.ProgrammingError as msg: self.db.rollback() - raise DBUpdateError, 'Unable to apply sick update 58, rollback issued. Error message : %s' % (str(msg)) + raise DBUpdateError('Unable to apply sick update 58, rollback issued. Error message : %s' % (str(msg))) diff --git a/dak/dakdb/update59.py b/dak/dakdb/update59.py index 6417a370..fd6fea55 100755 --- a/dak/dakdb/update59.py +++ b/dak/dakdb/update59.py @@ -51,6 +51,6 @@ def do_update(self): c.execute("UPDATE config SET value = '59' WHERE name = 'db_revision'") self.db.commit() - except psycopg2.ProgrammingError, msg: + except psycopg2.ProgrammingError as msg: self.db.rollback() - raise DBUpdateError, 'Unable to apply sick update 59, rollback issued. Error message : %s' % (str(msg)) + raise DBUpdateError('Unable to apply sick update 59, rollback issued. Error message : %s' % (str(msg))) diff --git a/dak/dakdb/update6.py b/dak/dakdb/update6.py index 13d60966..f3d11bbc 100755 --- a/dak/dakdb/update6.py +++ b/dak/dakdb/update6.py @@ -87,6 +87,6 @@ def do_update(self): c.execute("UPDATE config SET value = '6' WHERE name = 'db_revision'") self.db.commit() - except psycopg2.ProgrammingError, msg: + except psycopg2.ProgrammingError as msg: self.db.rollback() - raise DBUpdateError, "Unable to appy debversion updates, rollback issued. Error message : %s" % (str(msg)) + raise DBUpdateError("Unable to appy debversion updates, rollback issued. Error message : %s" % (str(msg))) diff --git a/dak/dakdb/update60.py b/dak/dakdb/update60.py index 4cf6ee8f..01735296 100755 --- a/dak/dakdb/update60.py +++ b/dak/dakdb/update60.py @@ -51,6 +51,6 @@ def do_update(self): c.execute("UPDATE config SET value = '60' WHERE name = 'db_revision'") self.db.commit() - except psycopg2.ProgrammingError, msg: + except psycopg2.ProgrammingError as msg: self.db.rollback() - raise DBUpdateError, 'Unable to apply sick update 60, rollback issued. Error message : %s' % (str(msg)) + raise DBUpdateError('Unable to apply sick update 60, rollback issued. Error message : %s' % (str(msg))) diff --git a/dak/dakdb/update61.py b/dak/dakdb/update61.py index 570bb6bd..3b18e0b3 100755 --- a/dak/dakdb/update61.py +++ b/dak/dakdb/update61.py @@ -50,6 +50,6 @@ def do_update(self): c.execute("UPDATE config SET value = '61' WHERE name = 'db_revision'") self.db.commit() - except psycopg2.ProgrammingError, msg: + except psycopg2.ProgrammingError as msg: self.db.rollback() - raise DBUpdateError, 'Unable to apply sick update 61, rollback issued. Error message : %s' % (str(msg)) + raise DBUpdateError('Unable to apply sick update 61, rollback issued. Error message : %s' % (str(msg))) diff --git a/dak/dakdb/update62.py b/dak/dakdb/update62.py index f320bbf0..7a47dca8 100755 --- a/dak/dakdb/update62.py +++ b/dak/dakdb/update62.py @@ -42,6 +42,6 @@ def do_update(self): c.execute("UPDATE config SET value = '62' WHERE name = 'db_revision'") self.db.commit() - except psycopg2.ProgrammingError, msg: + except psycopg2.ProgrammingError as msg: self.db.rollback() - raise DBUpdateError, 'Unable to apply sick update 62, rollback issued. Error message : %s' % (str(msg)) + raise DBUpdateError('Unable to apply sick update 62, rollback issued. Error message : %s' % (str(msg))) diff --git a/dak/dakdb/update63.py b/dak/dakdb/update63.py index 9b1187c6..e9e5c0f1 100755 --- a/dak/dakdb/update63.py +++ b/dak/dakdb/update63.py @@ -54,6 +54,6 @@ def do_update(self): c.execute("UPDATE config SET value = '63' WHERE name = 'db_revision'") self.db.commit() - except psycopg2.ProgrammingError, msg: + except psycopg2.ProgrammingError as msg: self.db.rollback() - raise DBUpdateError, 'Unable to apply sick update 63, rollback issued. Error message : %s' % (str(msg)) + raise DBUpdateError('Unable to apply sick update 63, rollback issued. Error message : %s' % (str(msg))) diff --git a/dak/dakdb/update64.py b/dak/dakdb/update64.py index bce9e94a..49ca75a8 100755 --- a/dak/dakdb/update64.py +++ b/dak/dakdb/update64.py @@ -44,6 +44,6 @@ def do_update(self): c.execute("UPDATE config SET value = '64' WHERE name = 'db_revision'") self.db.commit() - except psycopg2.ProgrammingError, msg: + except psycopg2.ProgrammingError as msg: self.db.rollback() - raise DBUpdateError, 'Unable to apply sick update 64, rollback issued. Error message : %s' % (str(msg)) + raise DBUpdateError('Unable to apply sick update 64, rollback issued. Error message : %s' % (str(msg))) diff --git a/dak/dakdb/update65.py b/dak/dakdb/update65.py index 8dd83a1b..46730b5f 100755 --- a/dak/dakdb/update65.py +++ b/dak/dakdb/update65.py @@ -46,6 +46,6 @@ def do_update(self): c.execute("UPDATE config SET value = '65' WHERE name = 'db_revision'") self.db.commit() - except psycopg2.ProgrammingError, msg: + except psycopg2.ProgrammingError as msg: self.db.rollback() - raise DBUpdateError, 'Unable to apply sick update 65, rollback issued. Error message : %s' % (str(msg)) + raise DBUpdateError('Unable to apply sick update 65, rollback issued. Error message : %s' % (str(msg))) diff --git a/dak/dakdb/update66.py b/dak/dakdb/update66.py index af61c04a..d59306fa 100755 --- a/dak/dakdb/update66.py +++ b/dak/dakdb/update66.py @@ -55,6 +55,6 @@ def do_update(self): c.execute("UPDATE config SET value = '66' WHERE name = 'db_revision'") self.db.commit() - except psycopg2.ProgrammingError, msg: + except psycopg2.ProgrammingError as msg: self.db.rollback() - raise DBUpdateError, 'Unable to apply sick update 66, rollback issued. Error message : %s' % (str(msg)) + raise DBUpdateError('Unable to apply sick update 66, rollback issued. Error message : %s' % (str(msg))) diff --git a/dak/dakdb/update67.py b/dak/dakdb/update67.py index c9ec9b2b..0255907e 100755 --- a/dak/dakdb/update67.py +++ b/dak/dakdb/update67.py @@ -6,6 +6,7 @@ Add audit schema and initial package table and triggers @contact: Debian FTP Master @copyright: 2011 Mark Hymers +@copyright: 2011 Ansgar Burchardt @license: GNU General Public License version 2 or later """ diff --git a/dak/dakdb/update7.py b/dak/dakdb/update7.py index 6f91eb37..9c3dd1ed 100755 --- a/dak/dakdb/update7.py +++ b/dak/dakdb/update7.py @@ -116,6 +116,6 @@ def do_update(self): c.execute("UPDATE config SET value = '7' WHERE name = 'db_revision'") self.db.commit() - except psycopg2.ProgrammingError, msg: + except psycopg2.ProgrammingError as msg: self.db.rollback() - raise DBUpdateError, "Unable to appy suite config updates, rollback issued. Error message : %s" % (str(msg)) + raise DBUpdateError("Unable to appy suite config updates, rollback issued. Error message : %s" % (str(msg))) diff --git a/dak/dakdb/update8.py b/dak/dakdb/update8.py index 2f92c4d8..98e0f088 100755 --- a/dak/dakdb/update8.py +++ b/dak/dakdb/update8.py @@ -99,6 +99,6 @@ def do_update(self): c.execute("UPDATE config SET value = '8' WHERE name = 'db_revision'") self.db.commit() - except psycopg2.ProgrammingError, msg: + except psycopg2.ProgrammingError as msg: self.db.rollback() - raise DBUpdateError, "Unable to apply suite config updates, rollback issued. Error message : %s" % (str(msg)) + raise DBUpdateError("Unable to apply suite config updates, rollback issued. Error message : %s" % (str(msg))) diff --git a/dak/dakdb/update9.py b/dak/dakdb/update9.py index 2ca3c51e..bbdd2122 100755 --- a/dak/dakdb/update9.py +++ b/dak/dakdb/update9.py @@ -57,6 +57,6 @@ def do_update(self): c.execute("UPDATE config SET value = '9' WHERE name = 'db_revision'") self.db.commit() - except psycopg2.ProgrammingError, msg: + except psycopg2.ProgrammingError as msg: self.db.rollback() - raise DBUpdateError, "Unable to apply suite config updates, rollback issued. Error message : %s" % (str(msg)) + raise DBUpdateError("Unable to apply suite config updates, rollback issued. Error message : %s" % (str(msg))) diff --git a/dak/examine_package.py b/dak/examine_package.py index 8e2ce20b..edb9384b 100755 --- a/dak/examine_package.py +++ b/dak/examine_package.py @@ -507,7 +507,7 @@ def get_readme_source (dsc_filename): try: shutil.rmtree(tempdir) - except OSError, e: + except OSError as e: if errno.errorcode[e.errno] != 'EACCES': res += "%s: couldn't remove tmp dir %s for source tree." % (dsc_filename, tempdir) @@ -634,7 +634,7 @@ def main (): # Reset stdout here so future less invocations aren't FUBAR less_fd.close() sys.stdout = stdout_fd - except IOError, e: + except IOError as e: if errno.errorcode[e.errno] == 'EPIPE': utils.warn("[examine-package] Caught EPIPE; skipping.") pass diff --git a/dak/generate_index_diffs.py b/dak/generate_index_diffs.py index 83d51824..3297c42c 100755 --- a/dak/generate_index_diffs.py +++ b/dak/generate_index_diffs.py @@ -81,7 +81,7 @@ def smartlink(f, t): os.system("bzip2 -d < %s.bz2 > %s" % (f, t)) else: print "missing: %s" % (f) - raise IOError, f + raise IOError(f) def smartopen(file): if os.path.isfile(file): @@ -280,7 +280,7 @@ def genchanges(Options, outdir, oldfile, origfile, maxdiffs = 14): def main(): global Cnf, Options, Logger - os.umask(0002) + os.umask(0o002) Cnf = utils.get_conf() Arguments = [ ('h', "help", "Generate-Index-Diffs::Options::Help"), diff --git a/dak/graph.py b/dak/graph.py index aa28aa6e..8d94b6b2 100755 --- a/dak/graph.py +++ b/dak/graph.py @@ -105,7 +105,7 @@ GPRINT:avgd%i:avg\\: %%.0lf\\j rrd_args += extra_args try: ret = rrdtool.graph(*rrd_args) - except rrdtool.error, e: + except rrdtool.error as e: print('warning: graph: rrdtool error, skipping %s-%s.png: %s' % (name, graph, e)) def graph_normal(rrd_dir, image_dir, name, extra_args, graph, title, start, year_lines=False): @@ -157,7 +157,7 @@ GPRINT:avgds0:avg\\: %%.0lf\\j rrd_args += extra_args try: ret = rrdtool.graph(*rrd_args) - except rrdtool.error, e: + except rrdtool.error as e: print('warning: graph: rrdtool error, skipping %s-%s.png: %s' % (name, graph, e)) ################################################################################ diff --git a/dak/import_known_changes.py b/dak/import_known_changes.py index 125dbb8c..7b182d6f 100755 --- a/dak/import_known_changes.py +++ b/dak/import_known_changes.py @@ -269,7 +269,7 @@ class ImportThread(threading.Thread): changes.add_known_changes(to_import.dirpath, session=self.session) self.session.commit() - except InvalidDscError, line: + except InvalidDscError as line: warn("syntax error in .dsc file '%s', line %s." % (f, line)) except ChangesUnicodeError: diff --git a/dak/import_users_from_passwd.py b/dak/import_users_from_passwd.py index b959e37f..a9dacd34 100755 --- a/dak/import_users_from_passwd.py +++ b/dak/import_users_from_passwd.py @@ -118,7 +118,7 @@ def main (): try: q = session.execute('CREATE USER "%s"' % (uname)) session.commit() - except Exception, e: + except Exception as e: utils.warn("Could not create user %s (%s)" % (uname, str(e))) session.rollback() else: diff --git a/dak/init_dirs.py b/dak/init_dirs.py index a4703bb8..fc5efd32 100755 --- a/dak/init_dirs.py +++ b/dak/init_dirs.py @@ -90,15 +90,15 @@ def process_keyring(fullpath, secret=False): os.makedirs(keydir) if secret: # Make sure secret keyring directories are 0700 - os.chmod(keydir, 0700) + os.chmod(keydir, 0o700) # Touch the file print "Creating %s ..." % (fullpath) file(fullpath, 'w') if secret: - os.chmod(fullpath, 0600) + os.chmod(fullpath, 0o600) else: - os.chmod(fullpath, 0644) + os.chmod(fullpath, 0o644) ###################################################################### diff --git a/dak/make_changelog.py b/dak/make_changelog.py index ac5581d0..ad6dbab1 100755 --- a/dak/make_changelog.py +++ b/dak/make_changelog.py @@ -225,7 +225,7 @@ def export_files(session, pool, clpool): os.link(version, suite) stats['created'] += 1 unpacked.cleanup() - except Exception, e: + except Exception as e: print 'make-changelog: unable to unpack %s\n%s' % (p, e) stats['errors'] += 1 diff --git a/dak/process_new.py b/dak/process_new.py index 1a253697..1c2231a3 100755 --- a/dak/process_new.py +++ b/dak/process_new.py @@ -42,8 +42,6 @@ ################################################################################ -from __future__ import with_statement - import copy import errno import os @@ -351,7 +349,7 @@ def check_pkg (upload): elif ftype == "dsc": print examine_package.check_dsc(changes['distribution'], f) print examine_package.output_package_relations() - except IOError, e: + except IOError as e: if e.errno == errno.EPIPE: utils.warn("[examine_package] Caught EPIPE; skipping.") else: @@ -616,7 +614,7 @@ def check_daily_lock(): os.open(lockfile, os.O_RDONLY | os.O_CREAT | os.O_EXCL) - except OSError, e: + except OSError as e: if e.errno == errno.EEXIST or e.errno == errno.EACCES: raise CantGetLockError @@ -638,10 +636,10 @@ def lock_package(package): try: fd = os.open(path, os.O_CREAT | os.O_EXCL | os.O_RDONLY) - except OSError, e: + except OSError as e: if e.errno == errno.EEXIST or e.errno == errno.EACCES: user = pwd.getpwuid(os.stat(path)[stat.ST_UID])[4].split(',')[0].replace('.', '') - raise AlreadyLockedError, user + raise AlreadyLockedError(user) try: yield fd @@ -720,7 +718,7 @@ def do_pkg(changes_full_path, session): print "Hello? Operator! Give me the number for 911!" print "Dinstall in the locked area, cant process packages, come back later" - except AlreadyLockedError, e: + except AlreadyLockedError as e: print "Seems to be locked by %s already, skipping..." % (e) def show_new_comments(changes_files, session): @@ -791,7 +789,7 @@ def main(): if not Options["No-Action"]: try: Logger = daklog.Logger("process-new") - except CantOpenError, e: + except CantOpenError as e: Options["Trainee"] = "True" Sections = Section_Completer(session) diff --git a/dak/process_policy.py b/dak/process_policy.py index 94e27468..3f237f62 100755 --- a/dak/process_policy.py +++ b/dak/process_policy.py @@ -142,7 +142,7 @@ def main(): if not Options["No-Action"]: try: Logger = daklog.Logger("process-policy") - except CantOpenError, e: + except CantOpenError as e: Logger = None # Find policy queue diff --git a/dak/process_upload.py b/dak/process_upload.py index bf74baa6..4d9f3b00 100755 --- a/dak/process_upload.py +++ b/dak/process_upload.py @@ -229,7 +229,7 @@ def action(u, session): try: chg = session.query(DBChange).filter_by(changesname=os.path.basename(u.pkg.changes_file)).one() - except NoResultFound, e: + except NoResultFound as e: chg = None if len(u.rejects) > 0: @@ -458,7 +458,7 @@ def main(): lock_fd = os.open(os.path.join(cnf["Dir::Lock"], 'dinstall.lock'), os.O_RDWR | os.O_CREAT) try: fcntl.lockf(lock_fd, fcntl.LOCK_EX | fcntl.LOCK_NB) - except IOError, e: + except IOError as e: if errno.errorcode[e.errno] == 'EACCES' or errno.errorcode[e.errno] == 'EAGAIN': utils.fubar("Couldn't obtain lock; assuming another 'dak process-upload' is already running.") else: diff --git a/dak/queue_report.py b/dak/queue_report.py index ec7b3a7d..5fd9288a 100755 --- a/dak/queue_report.py +++ b/dak/queue_report.py @@ -312,7 +312,7 @@ def table_row(source, version, arch, last_mod, maint, distribution, closes, fing try: (login, domain) = sponsor.split("@", 1) print "Sponsor: %s@debian.org
" % (utils.html_escape(login), utils.html_escape(login)) - except Exception, e: + except Exception as e: pass print "Fingerprint: %s" % (fingerprint) @@ -355,7 +355,7 @@ RRA:MAX:0.5:288:795 try: rc = rrdtool.create(*create) ru = rrdtool.update(*update) - except rrdtool.error, e: + except rrdtool.error as e: print('warning: queue_report: rrdtool error, skipping %s.rrd: %s' % (type, e)) except NameError: pass @@ -372,7 +372,7 @@ def process_changes_files(changes_files, type, log, rrd_dir): u.load_changes(filename) cache[filename] = copy(u.pkg.changes) cache[filename]["filename"] = filename - except Exception, e: + except Exception as e: print "WARNING: Exception %s" % e continue # Divide the .changes into per-source groups @@ -438,7 +438,7 @@ def process_changes_files(changes_files, type, log, rrd_dir): session = DBConn().session() dbc = session.query(DBChange).filter_by(changesname=changesbase).one() session.close() - except Exception, e: + except Exception as e: print "Can't find changes file in NEW for %s (%s)" % (changesbase, e) dbc = None @@ -447,7 +447,7 @@ def process_changes_files(changes_files, type, log, rrd_dir): (maintainer["maintainer822"], maintainer["maintainer2047"], maintainer["maintainername"], maintainer["maintaineremail"]) = \ fix_maintainer (j["maintainer"]) - except ParseMaintError, msg: + except ParseMaintError as msg: print "Problems while parsing maintainer address\n" maintainer["maintainername"] = "Unknown" maintainer["maintaineremail"] = "Unknown" @@ -457,7 +457,7 @@ def process_changes_files(changes_files, type, log, rrd_dir): (changeby["changedby822"], changeby["changedby2047"], changeby["changedbyname"], changeby["changedbyemail"]) = \ fix_maintainer (j["changed-by"]) - except ParseMaintError, msg: + except ParseMaintError as msg: (changeby["changedby822"], changeby["changedby2047"], changeby["changedbyname"], changeby["changedbyemail"]) = \ ("", "", "", "") diff --git a/dak/rm.py b/dak/rm.py index d0b46f62..3edeac3d 100755 --- a/dak/rm.py +++ b/dak/rm.py @@ -177,7 +177,7 @@ def reverse_depends_check(removals, suite, arches=None, session=None): parsed_dep = [] try: parsed_dep += apt_pkg.ParseDepends(deps[package]) - except ValueError, e: + except ValueError as e: print "Error for package %s: %s" % (package, e) for dep in parsed_dep: # Check for partial breakage. If a package has a ORed @@ -236,7 +236,7 @@ def reverse_depends_check(removals, suite, arches=None, session=None): build_dep = re_build_dep_arch.sub("", build_dep) try: parsed_dep += apt_pkg.ParseDepends(build_dep) - except ValueError, e: + except ValueError as e: print "Error for source %s: %s" % (source, e) for dep in parsed_dep: unsat = 0 diff --git a/dak/show_deferred.py b/dak/show_deferred.py index 4dd603e4..7352f71e 100755 --- a/dak/show_deferred.py +++ b/dak/show_deferred.py @@ -173,7 +173,7 @@ RRA:MAX:0.5:288:795 try: rc = rrdtool.create(*create) ru = rrdtool.update(*update) - except rrdtool.error, e: + except rrdtool.error as e: print('warning: queue_report: rrdtool error, skipping %s.rrd: %s' % (type, e)) except NameError: pass @@ -214,7 +214,7 @@ def get_upload_data(changesfn): os.unlink(lfn) if os.path.exists(qfn): os.symlink(qfn,lfn) - os.chmod(qfn, 0644) + os.chmod(qfn, 0o644) return (max(delaydays-1,0)*24*60*60+remainingtime, changesname, delay, uploader, achanges.get('closes','').split(),achanges, delaydays) def list_uploads(filelist, rrd_dir): diff --git a/dak/transitions.py b/dak/transitions.py index e2461ad2..a5eb6b6c 100755 --- a/dak/transitions.py +++ b/dak/transitions.py @@ -135,7 +135,7 @@ def load_transitions(trans_file): failure = False try: trans = yaml.load(sourcecontent) - except yaml.YAMLError, exc: + except yaml.YAMLError as exc: # Someone fucked it up print "ERROR: %s" % (exc) return None @@ -225,7 +225,7 @@ def lock_file(f): try: fcntl.lockf(lock_fd, fcntl.LOCK_EX | fcntl.LOCK_NB) return lock_fd - except OSError, e: + except OSError as e: if errno.errorcode[e.errno] == 'EACCES' or errno.errorcode[e.errno] == 'EEXIST': print "Unable to get lock for %s (try %d of 10)" % \ (file, retry+1) @@ -297,7 +297,7 @@ def write_transitions_from_file(from_file): else: trans = load_transitions(from_file) if trans is None: - raise TransitionsError, "Unparsable transitions file %s" % (file) + raise TransitionsError("Unparsable transitions file %s" % (file)) write_transitions(trans) ################################################################################ @@ -319,7 +319,7 @@ def temp_transitions_file(transitions): """ (fd, path) = tempfile.mkstemp("", "transitions", Cnf["Dir::TempPath"]) - os.chmod(path, 0644) + os.chmod(path, 0o644) f = open(path, "w") yaml.dump(transitions, f, default_flow_style=False) return path @@ -589,7 +589,7 @@ def main(): if Options["import"]: try: write_transitions_from_file(Options["import"]) - except TransitionsError, m: + except TransitionsError as m: print m sys.exit(2) sys.exit(0) diff --git a/dak/update_db.py b/dak/update_db.py index 89fc174e..dfa7ef78 100755 --- a/dak/update_db.py +++ b/dak/update_db.py @@ -134,7 +134,7 @@ Updates dak's database schema to the lastest version. You should disable crontab self.db = psycopg2.connect(connect_str) - except Exception, e: + except Exception as e: print "FATAL: Failed connect to database (%s)" % str(e) sys.exit(1) @@ -171,7 +171,7 @@ Updates dak's database schema to the lastest version. You should disable crontab message = "updated database schema from %d to %d" % (database_revision, i+1) print message logger.log([message]) - except DBUpdateError, e: + except DBUpdateError as e: # Seems the update did not work. print "Was unable to update database schema from %d to %d." % (database_revision, i+1) print "The error message received was %s" % (e) @@ -205,7 +205,7 @@ Updates dak's database schema to the lastest version. You should disable crontab fcntl.lockf(lock_fd, fcntl.LOCK_EX | fcntl.LOCK_NB) else: utils.warn("Lock directory doesn't exist yet - not locking") - except IOError, e: + except IOError as e: if errno.errorcode[e.errno] == 'EACCES' or errno.errorcode[e.errno] == 'EAGAIN': utils.fubar("Couldn't obtain lock; assuming another 'dak process-unchecked' is already running.") diff --git a/daklib/contents.py b/daklib/contents.py index bebab6dd..6db19a71 100755 --- a/daklib/contents.py +++ b/daklib/contents.py @@ -494,6 +494,6 @@ def source_scan_helper(source_id): try: scanner = SourceContentsScanner(source_id) scanner.scan() - except Exception, e: + except Exception as e: print e diff --git a/daklib/daklog.py b/daklib/daklog.py index 7ececa56..05ca9b1a 100644 --- a/daklib/daklog.py +++ b/daklib/daklog.py @@ -55,7 +55,7 @@ class Logger(object): logdir = Config()["Dir::Log"] if not os.path.exists(logdir): umask = os.umask(00000) - os.makedirs(logdir, 02775) + os.makedirs(logdir, 0o2775) os.umask(umask) # Open the logfile @@ -65,7 +65,7 @@ class Logger(object): if debug: logfile = sys.stderr else: - umask = os.umask(00002) + umask = os.umask(0o0002) logfile = utils.open_file(logfilename, 'a') os.umask(umask) diff --git a/daklib/dakmultiprocessing.py b/daklib/dakmultiprocessing.py index 86fa74d5..b709ecf5 100644 --- a/daklib/dakmultiprocessing.py +++ b/daklib/dakmultiprocessing.py @@ -66,9 +66,9 @@ def _func_wrapper(func, *args, **kwds): # messages is a string used for logging try: return (func(*args, **kwds)) - except SignalException, e: + except SignalException as e: return (PROC_STATUS_SIGNALRAISED, e.signum) - except Exception, e: + except Exception as e: return (PROC_STATUS_EXCEPTION, str(e)) finally: # Make sure connections are closed. We might die otherwise. diff --git a/daklib/dbconn.py b/daklib/dbconn.py index 63730187..11993119 100755 --- a/daklib/dbconn.py +++ b/daklib/dbconn.py @@ -818,7 +818,7 @@ class BuildQueue(object): Logger.log(["I: Removing %s from the queue" % o.fullpath]) os.unlink(o.fullpath) killdb = True - except OSError, e: + except OSError as e: # If it wasn't there, don't worry if e.errno == ENOENT: killdb = True @@ -1686,7 +1686,7 @@ class Keyring(object): key = None signingkey = False - for line in k.xreadlines(): + for line in k: field = line.split(":") if field[0] == "pub": key = field[4] @@ -2824,9 +2824,9 @@ def add_deb_to_db(u, filename, session=None): # Find source id bin_sources = get_sources_from_name(entry["source package"], entry["source version"], session=session) if len(bin_sources) != 1: - raise NoSourceFieldError, "Unable to find a unique source id for %s (%s), %s, file %s, type %s, signed by %s" % \ + raise NoSourceFieldError("Unable to find a unique source id for %s (%s), %s, file %s, type %s, signed by %s" % \ (bin.package, bin.version, entry["architecture"], - filename, bin.binarytype, u.pkg.changes["fingerprint"]) + filename, bin.binarytype, u.pkg.changes["fingerprint"])) bin.source_id = bin_sources[0].source_id @@ -2834,9 +2834,9 @@ def add_deb_to_db(u, filename, session=None): for srcname, version in entry["built-using"]: exsources = get_sources_from_name(srcname, version, session=session) if len(exsources) != 1: - raise NoSourceFieldError, "Unable to find source package (%s = %s) in Built-Using for %s (%s), %s, file %s, type %s, signed by %s" % \ + raise NoSourceFieldError("Unable to find source package (%s = %s) in Built-Using for %s (%s), %s, file %s, type %s, signed by %s" % \ (srcname, version, bin.package, bin.version, entry["architecture"], - filename, bin.binarytype, u.pkg.changes["fingerprint"]) + filename, bin.binarytype, u.pkg.changes["fingerprint"])) bin.extra_sources.append(exsources[0]) @@ -3684,7 +3684,7 @@ class DBConn(object): self.__setuptables() self.__setupmappers() - except OperationalError, e: + except OperationalError as e: import utils utils.fubar("Cannot connect to database (%s)" % str(e)) diff --git a/daklib/filewriter.py b/daklib/filewriter.py index b44fc2a5..274ef5c1 100755 --- a/daklib/filewriter.py +++ b/daklib/filewriter.py @@ -65,7 +65,7 @@ class BaseFileWriter(object): # internal helper function def rename(self, filename): tempfilename = filename + '.new' - os.chmod(tempfilename, 0664) + os.chmod(tempfilename, 0o664) os.rename(tempfilename, filename) def close(self): diff --git a/daklib/formats.py b/daklib/formats.py index edc80533..bcd42f61 100755 --- a/daklib/formats.py +++ b/daklib/formats.py @@ -58,7 +58,7 @@ def parse_format(txt): format = re_verwithext.search(txt) if format is None: - raise UnknownFormatError, txt + raise UnknownFormatError(txt) format = format.groups() @@ -80,7 +80,7 @@ def validate_changes_format(format, field): """ if (format < (1, 5) or format > (1, 8)): - raise UnknownFormatError, repr(format) + raise UnknownFormatError(repr(format)) if field != 'files' and format < (1, 8): - raise UnknownFormatError, repr(format) + raise UnknownFormatError(repr(format)) diff --git a/daklib/holding.py b/daklib/holding.py index 2f36a696..6c9ce570 100644 --- a/daklib/holding.py +++ b/daklib/holding.py @@ -58,9 +58,9 @@ class Holding(object): dest = os.path.join(self.holding_dir, base_filename) try: - fd = os.open(dest, os.O_RDWR | os.O_CREAT | os.O_EXCL, 0640) + fd = os.open(dest, os.O_RDWR | os.O_CREAT | os.O_EXCL, 0o640) os.close(fd) - except OSError, e: + except OSError as e: # Shouldn't happen, but will if, for example, someone lists a # file twice in the .changes. if e.errno == EEXIST: @@ -68,7 +68,7 @@ class Holding(object): try: shutil.copy(filename, dest) - except IOError, e: + except IOError as e: # In either case (ENOENT or EACCES) we want to remove the # O_CREAT | O_EXCLed ghost file, so add the file to the list # of 'in holding' even if it's not the real file. diff --git a/daklib/metadata.py b/daklib/metadata.py index d88cf4fa..793b073c 100755 --- a/daklib/metadata.py +++ b/daklib/metadata.py @@ -66,7 +66,7 @@ class MetadataScanner(object): if self.verbose: print "Imported %s (%s)" % (self.pkid, fullpath) session.commit() - except Exception, e: + except Exception as e: print "Failed to import %s [id=%s; fullpath=%s]" % (self.dbclass.__name__, self.pkid, fullpath) print "Exception: ", e session.rollback() diff --git a/daklib/queue.py b/daklib/queue.py index 82f3d9b9..f6593394 100755 --- a/daklib/queue.py +++ b/daklib/queue.py @@ -557,7 +557,7 @@ class Upload(object): except CantOpenError: self.rejects.append("%s: can't read file." % (filename)) return False - except ParseChangesError, line: + except ParseChangesError as line: self.rejects.append("%s: parse error, can't grok: %s." % (filename, line)) return False except ChangesUnicodeError: @@ -567,10 +567,10 @@ class Upload(object): # Parse the Files field from the .changes into another dictionary try: self.pkg.files.update(utils.build_file_list(self.pkg.changes)) - except ParseChangesError, line: + except ParseChangesError as line: self.rejects.append("%s: parse error, can't grok: %s." % (filename, line)) return False - except UnknownFormatError, format: + except UnknownFormatError as format: self.rejects.append("%s: unknown format '%s'." % (filename, format)) return False @@ -608,7 +608,7 @@ class Upload(object): self.pkg.changes["maintainername"], self.pkg.changes["maintaineremail"]) = \ fix_maintainer (self.pkg.changes["maintainer"]) - except ParseMaintError, msg: + except ParseMaintError as msg: self.rejects.append("%s: Maintainer field ('%s') failed to parse: %s" \ % (filename, self.pkg.changes["maintainer"], msg)) @@ -619,7 +619,7 @@ class Upload(object): self.pkg.changes["changedbyname"], self.pkg.changes["changedbyemail"]) = \ fix_maintainer (self.pkg.changes.get("changed-by", "")) - except ParseMaintError, msg: + except ParseMaintError as msg: self.pkg.changes["changedby822"] = "" self.pkg.changes["changedby2047"] = "" self.pkg.changes["changedbyname"] = "" @@ -714,7 +714,7 @@ class Upload(object): try: control = apt_pkg.ParseSection(apt_inst.debExtractControl(deb_file)) except: - self.rejects.append("%s: debExtractControl() raised %s." % (f, sys.exc_type)) + self.rejects.append("%s: debExtractControl() raised %s." % (f, sys.exc_info()[0])) deb_file.close() # Can't continue, none of the checks on control would work. return @@ -800,7 +800,7 @@ class Upload(object): else: entry["built-using"].append( (bu_so[0].source, bu_so[0].version, ) ) - except ValueError, e: + except ValueError as e: self.rejects.append("%s: Cannot parse Built-Using field: %s" % (f, str(e))) @@ -1046,7 +1046,7 @@ class Upload(object): or (dbc.in_queue is not None and dbc.in_queue.queue_name not in ["unchecked", "newstage"]): self.rejects.append("%s file already known to dak" % base_filename) - except NoResultFound, e: + except NoResultFound as e: # not known, good pass @@ -1163,9 +1163,9 @@ class Upload(object): except CantOpenError: if not action: return False, "%s: can't read file." % (dsc_filename) - except ParseChangesError, line: + except ParseChangesError as line: return False, "%s: parse error, can't grok: %s." % (dsc_filename, line) - except InvalidDscError, line: + except InvalidDscError as line: return False, "%s: syntax error on line %s." % (dsc_filename, line) except ChangesUnicodeError: return False, "%s: dsc file not proper utf-8." % (dsc_filename) @@ -1199,10 +1199,10 @@ class Upload(object): except NoFilesFieldError: self.rejects.append("%s: no Files: field." % (dsc_filename)) return False - except UnknownFormatError, format: + except UnknownFormatError as format: self.rejects.append("%s: unknown format '%s'." % (dsc_filename, format)) return False - except ParseChangesError, line: + except ParseChangesError as line: self.rejects.append("%s: parse error, can't grok: %s." % (dsc_filename, line)) return False @@ -1232,7 +1232,7 @@ class Upload(object): try: # We ignore the return value fix_maintainer(self.pkg.dsc["maintainer"]) - except ParseMaintError, msg: + except ParseMaintError as msg: self.rejects.append("%s: Maintainer field ('%s') failed to parse: %s" \ % (dsc_filename, self.pkg.dsc["maintainer"], msg)) @@ -1325,7 +1325,7 @@ class Upload(object): # Extract the source try: unpacked = UnpackedSource(dsc_filename) - except Exception, e: + except Exception as e: self.rejects.append("'dpkg-source -x' failed for %s. (%s)" % (dsc_filename, str(e))) return @@ -1376,7 +1376,7 @@ class Upload(object): try: shutil.rmtree(tmpdir) - except OSError, e: + except OSError as e: if e.errno != errno.EACCES: print "foobar" utils.fubar("%s: couldn't remove tmp dir for source tree." % (self.pkg.dsc["source"])) @@ -1389,7 +1389,7 @@ class Upload(object): if result != 0: utils.fubar("'%s' failed with result %s." % (cmd, result)) shutil.rmtree(tmpdir) - except Exception, e: + except Exception as e: print "foobar2 (%s)" % e utils.fubar("%s: couldn't remove tmp dir for source tree." % (self.pkg.dsc["source"])) @@ -1562,7 +1562,7 @@ class Upload(object): try: lintiantags = yaml.load(sourcecontent)['lintian'] - except yaml.YAMLError, msg: + except yaml.YAMLError as msg: utils.fubar("Can not read the lintian tags file %s, YAML error: %s." % (tagfile, msg)) return @@ -1654,7 +1654,7 @@ class Upload(object): self.rejects.append("%s: has %s file(s) with a time stamp too ancient (e.g. %s [%s])." % (filename, num_ancient_files, ancient_file, time.ctime(ancient_date))) except: - self.rejects.append("%s: deb contents timestamp check failed [%s: %s]" % (filename, sys.exc_type, sys.exc_value)) + self.rejects.append("%s: deb contents timestamp check failed [%s: %s]" % (filename, sys.exc_info()[0], sys.exc_info()[1])) def check_if_upload_is_sponsored(self, uid_email, uid_name): uid_email = '@'.join(uid_email.split('@')[:2]) @@ -1868,7 +1868,7 @@ class Upload(object): sourcecontent = sourcefile.read() try: transitions = yaml.load(sourcecontent) - except yaml.YAMLError, msg: + except yaml.YAMLError as msg: # This shouldn't happen, there is a wrapper to edit the file which # checks it, but we prefer to be safe than ending up rejecting # everything. @@ -2225,7 +2225,7 @@ distribution.""" filename = "%s/%s" % (cnf["Dir::BTSVersionTrack"], self.pkg.changes_file[:-8]+".versions") os.rename(temp_filename, filename) - os.chmod(filename, 0644) + os.chmod(filename, 0o644) # Write out the binary -> source mapping. (fd, temp_filename) = utils.temp_filename(cnf["Dir::BTSVersionTrack"], prefix=".") @@ -2240,7 +2240,7 @@ distribution.""" filename = "%s/%s" % (cnf["Dir::BTSVersionTrack"], self.pkg.changes_file[:-8]+".debinfo") os.rename(temp_filename, filename) - os.chmod(filename, 0644) + os.chmod(filename, 0o644) session.commit() @@ -2342,8 +2342,8 @@ distribution.""" dest_file = os.path.join(cnf["Dir::Reject"], file_entry) try: - dest_fd = os.open(dest_file, os.O_RDWR | os.O_CREAT | os.O_EXCL, 0644) - except OSError, e: + dest_fd = os.open(dest_file, os.O_RDWR | os.O_CREAT | os.O_EXCL, 0o644) + except OSError as e: # File exists? Let's find a new name by adding a number if e.errno == errno.EEXIST: try: @@ -2356,8 +2356,8 @@ distribution.""" # Make sure we really got it try: - dest_fd = os.open(dest_file, os.O_RDWR|os.O_CREAT|os.O_EXCL, 0644) - except OSError, e: + dest_fd = os.open(dest_file, os.O_RDWR|os.O_CREAT|os.O_EXCL, 0o644) + except OSError as e: # Likewise utils.warn("**WARNING** failed to claim %s in the reject directory." % (file_entry)) return @@ -2365,7 +2365,7 @@ distribution.""" raise # If we got here, we own the destination file, so we can # safely overwrite it. - utils.move(file_entry, dest_file, 1, perms=0660) + utils.move(file_entry, dest_file, 1, perms=0o660) os.close(dest_fd) ########################################################################### @@ -2431,7 +2431,7 @@ distribution.""" # so let's just raise an exception ... if os.path.exists(reason_filename): os.unlink(reason_filename) - reason_fd = os.open(reason_filename, os.O_RDWR|os.O_CREAT|os.O_EXCL, 0644) + reason_fd = os.open(reason_filename, os.O_RDWR|os.O_CREAT|os.O_EXCL, 0o644) rej_template = os.path.join(cnf["Dir::Templates"], "queue.rejected") diff --git a/daklib/srcformats.py b/daklib/srcformats.py index 85ac701f..050691fe 100755 --- a/daklib/srcformats.py +++ b/daklib/srcformats.py @@ -48,7 +48,7 @@ def get_format_from_string(txt): if format.re_format.match(txt): return format - raise UnknownFormatError, "Unknown format %r" % txt + raise UnknownFormatError("Unknown format %r" % txt) class SourceFormat(type): def __new__(cls, name, bases, attrs): diff --git a/daklib/textutils.py b/daklib/textutils.py index 3cbcec73..03df5d85 100644 --- a/daklib/textutils.py +++ b/daklib/textutils.py @@ -88,7 +88,7 @@ def fix_maintainer(maintainer): else: m = re_parse_maintainer.match(maintainer) if not m: - raise ParseMaintError, "Doesn't parse as a valid Maintainer field." + raise ParseMaintError("Doesn't parse as a valid Maintainer field.") name = m.group(1) email = m.group(2) @@ -106,7 +106,7 @@ def fix_maintainer(maintainer): rfc2047_maint = "%s <%s>" % (rfc2047_name, email) if email.find("@") == -1 and email.find("buildd_") != 0: - raise ParseMaintError, "No @ found in email address part." + raise ParseMaintError("No @ found in email address part.") return (rfc822_maint, rfc2047_maint, name, email) diff --git a/daklib/utils.py b/daklib/utils.py index 8bc1b2c7..40e47c63 100755 --- a/daklib/utils.py +++ b/daklib/utils.py @@ -115,7 +115,7 @@ def open_file(filename, mode='r'): try: f = open(filename, mode) except IOError: - raise CantOpenError, filename + raise CantOpenError(filename) return f ################################################################################ @@ -172,7 +172,7 @@ def parse_deb822(armored_contents, signing_rules=0, keyrings=None, session=None) lines = contents.splitlines(True) if len(lines) == 0: - raise ParseChangesError, "[Empty changes file]" + raise ParseChangesError("[Empty changes file]") # Reindex by line number so we can easily verify the format of # .dsc files... @@ -190,7 +190,7 @@ def parse_deb822(armored_contents, signing_rules=0, keyrings=None, session=None) line = indexed_lines[index] if line == "" and signing_rules == 1: if index != num_of_lines: - raise InvalidDscError, index + raise InvalidDscError(index) break slf = re_single_line_field.match(line) if slf: @@ -204,7 +204,7 @@ def parse_deb822(armored_contents, signing_rules=0, keyrings=None, session=None) mlf = re_multi_line_field.match(line) if mlf: if first == -1: - raise ParseChangesError, "'%s'\n [Multi-line field continuing on from nothing?]" % (line) + raise ParseChangesError("'%s'\n [Multi-line field continuing on from nothing?]" % (line)) if first == 1 and changes[field] != "": changes[field] += '\n' first = 0 @@ -223,7 +223,7 @@ def parse_deb822(armored_contents, signing_rules=0, keyrings=None, session=None) changes["source-version"] = srcver.group(2) if error: - raise ParseChangesError, error + raise ParseChangesError(error) return changes @@ -257,7 +257,7 @@ def parse_changes(filename, signing_rules=0, dsc_file=0, keyrings=None): try: unicode(content, 'utf-8') except UnicodeError: - raise ChangesUnicodeError, "Changes file not proper utf-8" + raise ChangesUnicodeError("Changes file not proper utf-8") changes = parse_deb822(content, signing_rules, keyrings=keyrings) @@ -272,7 +272,7 @@ def parse_changes(filename, signing_rules=0, dsc_file=0, keyrings=None): missingfields.append(keyword) if len(missingfields): - raise ParseChangesError, "Missing mandantory field(s) in changes file (policy 5.5): %s" % (missingfields) + raise ParseChangesError("Missing mandantory field(s) in changes file (policy 5.5): %s" % (missingfields)) return changes @@ -350,7 +350,7 @@ def check_size(where, files): for f in files.keys(): try: entry = os.stat(f) - except OSError, exc: + except OSError as exc: if exc.errno == 2: # TODO: This happens when the file is in the pool. continue @@ -559,7 +559,7 @@ def build_file_list(changes, is_a_dsc=0, field="files", hashname="md5sum"): else: (md5, size, name) = s except ValueError: - raise ParseChangesError, i + raise ParseChangesError(i) if section == "": section = "-" @@ -687,14 +687,14 @@ def send_mail (message, filename=""): os.unlink (filename); return; - fd = os.open(filename, os.O_RDWR|os.O_EXCL, 0700); + fd = os.open(filename, os.O_RDWR|os.O_EXCL, 0o700); os.write (fd, message_raw.as_string(True)); os.close (fd); # Invoke sendmail (result, output) = commands.getstatusoutput("%s < %s" % (Cnf["Dinstall::SendmailCommand"], filename)) if (result != 0): - raise SendmailFailedError, output + raise SendmailFailedError(output) # Clean up any temporary files if message: @@ -712,14 +712,14 @@ def poolify (source, component): ################################################################################ -def move (src, dest, overwrite = 0, perms = 0664): +def move (src, dest, overwrite = 0, perms = 0o664): if os.path.exists(dest) and os.path.isdir(dest): dest_dir = dest else: dest_dir = os.path.dirname(dest) if not os.path.exists(dest_dir): umask = os.umask(00000) - os.makedirs(dest_dir, 02775) + os.makedirs(dest_dir, 0o2775) os.umask(umask) #print "Moving %s to %s..." % (src, dest) if os.path.exists(dest) and os.path.isdir(dest): @@ -735,14 +735,14 @@ def move (src, dest, overwrite = 0, perms = 0664): os.chmod(dest, perms) os.unlink(src) -def copy (src, dest, overwrite = 0, perms = 0664): +def copy (src, dest, overwrite = 0, perms = 0o664): if os.path.exists(dest) and os.path.isdir(dest): dest_dir = dest else: dest_dir = os.path.dirname(dest) if not os.path.exists(dest_dir): umask = os.umask(00000) - os.makedirs(dest_dir, 02775) + os.makedirs(dest_dir, 0o2775) os.umask(umask) #print "Copying %s to %s..." % (src, dest) if os.path.exists(dest) and os.path.isdir(dest): @@ -1549,7 +1549,7 @@ def get_changes_files(from_dir): # Much of the rest of p-u/p-a depends on being in the right place os.chdir(from_dir) changes_files = [x for x in os.listdir(from_dir) if x.endswith('.changes')] - except OSError, e: + except OSError as e: fubar("Failed to read list from directory %s (%s)" % (from_dir, e)) return changes_files @@ -1581,7 +1581,7 @@ def parse_wnpp_bug_file(file = "/srv/ftp-master.debian.org/scripts/masterfiles/w try: f = open(file) lines = f.readlines() - except IOError, e: + except IOError as e: print "Warning: Couldn't open %s; don't know about WNPP bugs, so won't close any." % file lines = [] wnpp = {} diff --git a/tests/test_parse_changes.py b/tests/test_parse_changes.py index 85a76948..20dab4b9 100755 --- a/tests/test_parse_changes.py +++ b/tests/test_parse_changes.py @@ -20,7 +20,7 @@ class ParseChangesTestCase(DakTestCase): pass except GpgException: pass - except InvalidDscError, actual_line: + except InvalidDscError as actual_line: if line is not None: assertEqual(actual_line, line) diff --git a/tools/queue_rss.py b/tools/queue_rss.py index 4e8c7ca2..fc1ad3de 100755 --- a/tools/queue_rss.py +++ b/tools/queue_rss.py @@ -103,7 +103,7 @@ def parse_leave_reason(fname): try: f = open(fname) - except IOError, e: + except IOError as e: sys.stderr.write("Can't open %s: %s\n" % (fname, e)) return {} @@ -210,7 +210,7 @@ if __name__ == "__main__": try: status.feed_in.write_xml(file(feed_in_file, "w+"), "utf-8") status.feed_out.write_xml(file(feed_out_file, "w+"), "utf-8") - except IOError, why: + except IOError as why: sys.stderr.write("Unable to write feeds: %s\n", why) sys.exit(1) @@ -218,7 +218,7 @@ if __name__ == "__main__": try: cPickle.dump(status, open(status_db, "w+")) - except IOError, why: + except IOError as why: sys.stderr.write("Unable to save status: %s\n", why) sys.exit(1)