From: Torsten Werner Date: Wed, 24 Aug 2011 17:12:09 +0000 (+0200) Subject: Convert exception handling to Python3 syntax. X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=27e00376e81d1c37ff327ee0d39670b266418869;p=dak Convert exception handling to Python3 syntax. That works in Python >= 2.6. Signed-off-by: Torsten Werner --- 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..6ade86c6 100755 --- a/dak/clean_queues.py +++ b/dak/clean_queues.py @@ -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 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..ede12e56 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)) diff --git a/dak/dakdb/update10.py b/dak/dakdb/update10.py index 5cd4f30d..52a5d0be 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)) diff --git a/dak/dakdb/update11.py b/dak/dakdb/update11.py index a4797cb4..6569f8eb 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)) diff --git a/dak/dakdb/update12.py b/dak/dakdb/update12.py index 890f51cb..1141c599 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)) diff --git a/dak/dakdb/update13.py b/dak/dakdb/update13.py index d5dbedce..ddb79780 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)) diff --git a/dak/dakdb/update14.py b/dak/dakdb/update14.py index 4f1b1dac..44b061b1 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)) diff --git a/dak/dakdb/update15.py b/dak/dakdb/update15.py index 535f9e67..3074ff09 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)) diff --git a/dak/dakdb/update16.py b/dak/dakdb/update16.py index eca9b48e..d64c2220 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)) diff --git a/dak/dakdb/update17.py b/dak/dakdb/update17.py index beca9425..8fc3bd05 100755 --- a/dak/dakdb/update17.py +++ b/dak/dakdb/update17.py @@ -58,7 +58,7 @@ 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)) diff --git a/dak/dakdb/update18.py b/dak/dakdb/update18.py index ce0086f6..eb8efa4a 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)) diff --git a/dak/dakdb/update19.py b/dak/dakdb/update19.py index 49a4dbc7..5186ded6 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)) diff --git a/dak/dakdb/update2.py b/dak/dakdb/update2.py index 2e3cb446..9ad0da5d 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)) diff --git a/dak/dakdb/update20.py b/dak/dakdb/update20.py index f4e34cb9..70572fcb 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)) diff --git a/dak/dakdb/update21.py b/dak/dakdb/update21.py index 8e36883f..2555e4c7 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)) diff --git a/dak/dakdb/update22.py b/dak/dakdb/update22.py index dbd7ced6..81f20037 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)) diff --git a/dak/dakdb/update23.py b/dak/dakdb/update23.py index 48abf016..922322b3 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)) diff --git a/dak/dakdb/update24.py b/dak/dakdb/update24.py index 4e8c505d..83047668 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)) diff --git a/dak/dakdb/update25.py b/dak/dakdb/update25.py index b2813d91..3fc8c558 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)) diff --git a/dak/dakdb/update26.py b/dak/dakdb/update26.py index 1b9a7fc1..4329bc3a 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)) diff --git a/dak/dakdb/update27.py b/dak/dakdb/update27.py index b06932b5..7a492a3f 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)) diff --git a/dak/dakdb/update28.py b/dak/dakdb/update28.py index 79b0e8db..c899831c 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)) diff --git a/dak/dakdb/update29.py b/dak/dakdb/update29.py index d25c1011..66600b63 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)) diff --git a/dak/dakdb/update3.py b/dak/dakdb/update3.py index 5a5562fb..1eab89f6 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)) diff --git a/dak/dakdb/update30.py b/dak/dakdb/update30.py index 2d962749..fe591614 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)) diff --git a/dak/dakdb/update31.py b/dak/dakdb/update31.py index 8ebfe342..dc4245cc 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)) diff --git a/dak/dakdb/update32.py b/dak/dakdb/update32.py index 98eaa4e6..c0882fb1 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)) diff --git a/dak/dakdb/update33.py b/dak/dakdb/update33.py index 9624ba62..d3867af3 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)) diff --git a/dak/dakdb/update34.py b/dak/dakdb/update34.py index ea0535db..35351c24 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)) diff --git a/dak/dakdb/update35.py b/dak/dakdb/update35.py index 335d70e5..cc289e41 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)) diff --git a/dak/dakdb/update36.py b/dak/dakdb/update36.py index d5810f68..c672d8d7 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)) diff --git a/dak/dakdb/update37.py b/dak/dakdb/update37.py index 5a6714bb..136f4649 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)) diff --git a/dak/dakdb/update38.py b/dak/dakdb/update38.py index 583aa3ad..28a411ba 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)) diff --git a/dak/dakdb/update39.py b/dak/dakdb/update39.py index 8086b515..c97b4f06 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)) diff --git a/dak/dakdb/update4.py b/dak/dakdb/update4.py index 477944c8..169653fa 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)) diff --git a/dak/dakdb/update40.py b/dak/dakdb/update40.py index 062b0dd8..a13ec10b 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)) diff --git a/dak/dakdb/update41.py b/dak/dakdb/update41.py index 813a3b70..5243cd67 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)) diff --git a/dak/dakdb/update42.py b/dak/dakdb/update42.py index 48bc9d61..bfd4b1fc 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)) diff --git a/dak/dakdb/update43.py b/dak/dakdb/update43.py index 07154105..38bc29a1 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)) diff --git a/dak/dakdb/update44.py b/dak/dakdb/update44.py index 465f2fce..1b4a5714 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)) diff --git a/dak/dakdb/update45.py b/dak/dakdb/update45.py index 32ed04f0..8de1e670 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)) diff --git a/dak/dakdb/update46.py b/dak/dakdb/update46.py index d1b2d3ac..55a382fa 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)) diff --git a/dak/dakdb/update47.py b/dak/dakdb/update47.py index 81d9cd78..c93ffb84 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)) diff --git a/dak/dakdb/update48.py b/dak/dakdb/update48.py index 67ea8c5b..3bc0f893 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)) diff --git a/dak/dakdb/update49.py b/dak/dakdb/update49.py index 5ff1545c..44e1f9fc 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)) diff --git a/dak/dakdb/update5.py b/dak/dakdb/update5.py index 49e33891..7c892a7a 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)) diff --git a/dak/dakdb/update50.py b/dak/dakdb/update50.py index ae7ea4d0..568c33bc 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)) diff --git a/dak/dakdb/update51.py b/dak/dakdb/update51.py index 2aea858e..02a8fc23 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)) diff --git a/dak/dakdb/update52.py b/dak/dakdb/update52.py index d38ee26f..938b3cea 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)) diff --git a/dak/dakdb/update53.py b/dak/dakdb/update53.py index 36a076f6..a2c8a0a3 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)) diff --git a/dak/dakdb/update54.py b/dak/dakdb/update54.py index e7676ef0..3922f69b 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)) diff --git a/dak/dakdb/update55.py b/dak/dakdb/update55.py index 3328e85c..8dfc4a58 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)) diff --git a/dak/dakdb/update56.py b/dak/dakdb/update56.py index f04ebc87..58ecc9f2 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)) diff --git a/dak/dakdb/update57.py b/dak/dakdb/update57.py index 45a37dc6..1b6ddc8a 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)) diff --git a/dak/dakdb/update58.py b/dak/dakdb/update58.py index 8680fc25..802a5167 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)) diff --git a/dak/dakdb/update59.py b/dak/dakdb/update59.py index 6417a370..ec3f07f8 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)) diff --git a/dak/dakdb/update6.py b/dak/dakdb/update6.py index 13d60966..78a04f5f 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)) diff --git a/dak/dakdb/update60.py b/dak/dakdb/update60.py index 4cf6ee8f..dc61eaca 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)) diff --git a/dak/dakdb/update61.py b/dak/dakdb/update61.py index 570bb6bd..d8b47ec8 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)) diff --git a/dak/dakdb/update62.py b/dak/dakdb/update62.py index f320bbf0..597a19cb 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)) diff --git a/dak/dakdb/update63.py b/dak/dakdb/update63.py index 9b1187c6..9d2cce68 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)) diff --git a/dak/dakdb/update64.py b/dak/dakdb/update64.py index bce9e94a..b34a8787 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)) diff --git a/dak/dakdb/update65.py b/dak/dakdb/update65.py index 8dd83a1b..76bfe61a 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)) diff --git a/dak/dakdb/update66.py b/dak/dakdb/update66.py index af61c04a..2a59c713 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)) diff --git a/dak/dakdb/update7.py b/dak/dakdb/update7.py index 6f91eb37..7e5c2091 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)) diff --git a/dak/dakdb/update8.py b/dak/dakdb/update8.py index 2f92c4d8..1c86c866 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)) diff --git a/dak/dakdb/update9.py b/dak/dakdb/update9.py index 2ca3c51e..20af71fd 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)) 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/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/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..92dde2d3 100755 --- a/dak/process_new.py +++ b/dak/process_new.py @@ -351,7 +351,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 +616,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,7 +638,7 @@ 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 @@ -720,7 +720,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 +791,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..2b6cd71e 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 diff --git a/dak/transitions.py b/dak/transitions.py index e2461ad2..9d21a562 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) @@ -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 0f1e7a37..b7579121 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/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..4e01b610 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 @@ -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/holding.py b/daklib/holding.py index 2f36a696..221a2577 100644 --- a/daklib/holding.py +++ b/daklib/holding.py @@ -60,7 +60,7 @@ class Holding(object): try: fd = os.open(dest, os.O_RDWR | os.O_CREAT | os.O_EXCL, 0640) 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..12e02719 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"] = "" @@ -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 @@ -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. @@ -2343,7 +2343,7 @@ distribution.""" try: dest_fd = os.open(dest_file, os.O_RDWR | os.O_CREAT | os.O_EXCL, 0644) - except OSError, e: + except OSError as e: # File exists? Let's find a new name by adding a number if e.errno == errno.EEXIST: try: @@ -2357,7 +2357,7 @@ 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: + except OSError as e: # Likewise utils.warn("**WARNING** failed to claim %s in the reject directory." % (file_entry)) return diff --git a/daklib/utils.py b/daklib/utils.py index 8bc1b2c7..46387ff2 100755 --- a/daklib/utils.py +++ b/daklib/utils.py @@ -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 @@ -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)