That works in Python >= 2.6.
Signed-off-by: Torsten Werner <twerner@debian.org>
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])
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]
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)
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())
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())
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
try:
os.chdir(incoming)
- except OSError, e:
+ except OSError as e:
utils.fubar("Cannot chdir to %s" % incoming)
# Remove a file to the morgue
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
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")
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))
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))
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))
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))
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))
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))
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))
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))
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))
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))
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))
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))
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))
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"
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))
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))
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))
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))
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))
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))
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))
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))
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))
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))
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))
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))
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))
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))
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))
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))
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))
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))
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))
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))
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))
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))
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))
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))
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))
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))
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))
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))
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))
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))
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))
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))
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))
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))
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))
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))
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))
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))
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))
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))
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))
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))
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))
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))
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))
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))
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))
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))
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))
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))
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))
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))
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))
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)
# 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
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):
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))
################################################################################
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:
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:
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
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:
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
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
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):
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)
if not Options["No-Action"]:
try:
Logger = daklog.Logger("process-policy")
- except CantOpenError, e:
+ except CantOpenError as e:
Logger = None
# Find policy queue
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:
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:
try:
(login, domain) = sponsor.split("@", 1)
print "<span class=\"sponsor\">Sponsor: <a href=\"http://qa.debian.org/developer.php?login=%s\">%s</a></span>@debian.org<br/>" % (utils.html_escape(login), utils.html_escape(login))
- except Exception, e:
+ except Exception as e:
pass
print "<span class=\"signature\">Fingerprint: %s</span>" % (fingerprint)
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
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
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
(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"
(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"]) = \
("", "", "", "")
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
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
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
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
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)
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)
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)
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)
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.")
try:
scanner = SourceContentsScanner(source_id)
scanner.scan()
- except Exception, e:
+ except Exception as e:
print e
# 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.
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
self.__setuptables()
self.__setupmappers()
- except OperationalError, e:
+ except OperationalError as e:
import utils
utils.fubar("Cannot connect to database (%s)" % str(e))
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:
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.
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()
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:
# 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
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))
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"] = ""
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)))
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
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)
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
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))
# 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
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"]))
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"]))
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
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.
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:
# 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
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
# 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
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 = {}
pass
except GpgException:
pass
- except InvalidDscError, actual_line:
+ except InvalidDscError as actual_line:
if line is not None:
assertEqual(actual_line, line)
try:
f = open(fname)
- except IOError, e:
+ except IOError as e:
sys.stderr.write("Can't open %s: %s\n" % (fname, e))
return {}
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)
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)