Salt = Salt + SaltVals[ord(Rand.read(1)[0]) % len(SaltVals)]
Pass = crypt.crypt(Password,Salt)
if len(Pass) < 14:
- raise "Password Error", "MD5 password hashing failed, not changing the password!"
+ raise RuntimeError("MD5 password hashing failed, not changing the password!")
return Pass
################################################################################
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
# Ensure a directory exists to remove files to
if not Options["No-Action"]:
if not os.path.exists(del_dir):
- os.makedirs(del_dir, 02775)
+ os.makedirs(del_dir, 0o2775)
if not os.path.isdir(del_dir):
utils.fubar("%s must be a directory." % (del_dir))
try:
os.chdir(incoming)
- except OSError, e:
+ except OSError as e:
utils.fubar("Cannot chdir to %s" % incoming)
# Remove a file to the morgue
if os.path.exists(dest_filename):
dest_filename = utils.find_next_free(dest_filename, 10)
Logger.log(["change destination file name", os.path.basename(dest_filename)])
- utils.move(f, dest_filename, 0660)
+ utils.move(f, dest_filename, 0o660)
else:
Logger.log(["skipping file because of permission problem", fname])
utils.warn("skipping '%s', permission denied." % fname)
changes = utils.parse_changes(changes_filename)
files = utils.build_file_list(changes)
except:
- utils.warn("error processing '%s'; skipping it. [Got %s]" % (changes_filename, sys.exc_type))
+ utils.warn("error processing '%s'; skipping it. [Got %s]" % (changes_filename, sys.exc_info()[0]))
continue
dsc_files = {}
dsc = utils.parse_changes(f, dsc_file=1)
dsc_files = utils.build_file_list(dsc, is_a_dsc=1)
except:
- utils.warn("error processing '%s'; skipping it. [Got %s]" % (f, sys.exc_type))
+ utils.warn("error processing '%s'; skipping it. [Got %s]" % (f, sys.exc_info()[0]))
continue
# Ensure all the files we've seen aren't deleted
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))
+ 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))
+ 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))
+ 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))
+ 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))
+ 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))
+ 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))
+ 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))
+ 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))
+ 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))
+ 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))
+ 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))
+ 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))
+ 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))
+ 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))
+ 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))
+ 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))
+ 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))
+ 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))
+ 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))
+ 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))
+ 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))
+ 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))
+ 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))
+ 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))
+ 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))
+ 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))
+ 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))
+ 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))
+ 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))
+ 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))
+ 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))
+ 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))
+ 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))
+ 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))
+ 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))
+ 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))
+ 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))
+ 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))
+ 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))
+ 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))
+ 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))
+ 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))
+ 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))
+ 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))
+ 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))
+ 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))
+ 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))
+ 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))
+ 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))
+ 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))
+ 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))
+ 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))
+ 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))
+ 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))
+ 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))
+ 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))
+ 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))
+ 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))
+ 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))
+ 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))
+ 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))
+ 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))
+ raise DBUpdateError('Unable to apply sick update 66, rollback issued. Error message : %s' % (str(msg)))
--- /dev/null
+#!/usr/bin/env python
+# coding=utf8
+
+"""
+Add audit schema and initial package table and triggers
+
+@contact: Debian FTP Master <ftpmaster@debian.org>
+@copyright: 2011 Mark Hymers <mhy@debian.org>
+@copyright: 2011 Ansgar Burchardt <ansgar@debian.org>
+@license: GNU General Public License version 2 or later
+"""
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+################################################################################
+
+import psycopg2
+from daklib.dak_exceptions import DBUpdateError
+from daklib.config import Config
+
+################################################################################
+def do_update(self):
+ """
+ Add audit schema and initial package table and triggers
+ """
+ print __doc__
+ try:
+ c = self.db.cursor()
+
+ c.execute("CREATE SCHEMA audit");
+ c.execute("GRANT USAGE on SCHEMA audit TO public")
+ c.execute("GRANT USAGE on SCHEMA audit TO ftpteam")
+ c.execute("GRANT USAGE on SCHEMA audit TO ftpmaster")
+
+ c.execute("""CREATE TABLE audit.package_changes (
+ changedate TIMESTAMP NOT NULL DEFAULT now(),
+ package TEXT NOT NULL,
+ version DEBVERSION NOT NULL,
+ architecture TEXT NOT NULL,
+ suite TEXT NOT NULL,
+ event TEXT NOT NULL,
+ priority TEXT,
+ component TEXT,
+ section TEXT
+)""")
+
+ c.execute("GRANT INSERT ON audit.package_changes TO dak")
+ c.execute("GRANT SELECT ON audit.package_changes TO PUBLIC")
+
+ c.execute("""CREATE OR REPLACE FUNCTION trigger_binsrc_assoc_update() RETURNS TRIGGER AS $$
+DECLARE
+ v_data RECORD;
+
+ v_package audit.package_changes.package%TYPE;
+ v_version audit.package_changes.version%TYPE;
+ v_architecture audit.package_changes.architecture%TYPE;
+ v_suite audit.package_changes.suite%TYPE;
+ v_event audit.package_changes.event%TYPE;
+ v_priority audit.package_changes.priority%TYPE;
+ v_component audit.package_changes.component%TYPE;
+ v_section audit.package_changes.section%TYPE;
+BEGIN
+ CASE TG_OP
+ WHEN 'INSERT' THEN v_event := 'I'; v_data := NEW;
+ WHEN 'DELETE' THEN v_event := 'D'; v_data := OLD;
+ ELSE RAISE EXCEPTION 'trigger called for invalid operation (%)', TG_OP;
+ END CASE;
+
+ SELECT suite_name INTO STRICT v_suite FROM suite WHERE id = v_data.suite;
+
+ CASE TG_TABLE_NAME
+ WHEN 'bin_associations' THEN
+ SELECT package, version, arch_string
+ INTO STRICT v_package, v_version, v_architecture
+ FROM binaries LEFT JOIN architecture ON (architecture.id = binaries.architecture)
+ WHERE binaries.id = v_data.bin;
+
+ SELECT component.name, priority.priority, section.section
+ INTO v_component, v_priority, v_section
+ FROM override
+ JOIN override_type ON (override.type = override_type.id)
+ JOIN priority ON (priority.id = override.priority)
+ JOIN section ON (section.id = override.section)
+ JOIN component ON (override.component = component.id)
+ JOIN suite ON (suite.id = override.suite)
+ WHERE override_type.type != 'dsc'
+ AND override.package = v_package AND suite.id = v_data.suite;
+
+ WHEN 'src_associations' THEN
+ SELECT source, version
+ INTO STRICT v_package, v_version
+ FROM source WHERE source.id = v_data.source;
+ v_architecture := 'source';
+
+ SELECT component.name, priority.priority, section.section
+ INTO v_component, v_priority, v_section
+ FROM override
+ JOIN override_type ON (override.type = override_type.id)
+ JOIN priority ON (priority.id = override.priority)
+ JOIN section ON (section.id = override.section)
+ JOIN component ON (override.component = component.id)
+ JOIN suite ON (suite.id = override.suite)
+ WHERE override_type.type = 'dsc'
+ AND override.package = v_package AND suite.id = v_data.suite;
+
+ ELSE RAISE EXCEPTION 'trigger called for invalid table (%)', TG_TABLE_NAME;
+ END CASE;
+
+ INSERT INTO audit.package_changes
+ (package, version, architecture, suite, event, priority, component, section)
+ VALUES (v_package, v_version, v_architecture, v_suite, v_event, v_priority, v_component, v_section);
+
+ RETURN NEW;
+END;
+$$ LANGUAGE plpgsql VOLATILE SECURITY DEFINER
+SET search_path = public, pg_temp""");
+
+ c.execute("""CREATE OR REPLACE FUNCTION trigger_override_update() RETURNS TRIGGER AS $$
+DECLARE
+ v_src_override_id override_type.id%TYPE;
+
+ v_priority audit.package_changes.priority%TYPE := NULL;
+ v_component audit.package_changes.component%TYPE := NULL;
+ v_section audit.package_changes.section%TYPE := NULL;
+BEGIN
+
+ IF TG_TABLE_NAME != 'override' THEN
+ RAISE EXCEPTION 'trigger called for invalid table (%)', TG_TABLE_NAME;
+ END IF;
+ IF TG_OP != 'UPDATE' THEN
+ RAISE EXCEPTION 'trigger called for invalid event (%)', TG_OP;
+ END IF;
+
+ IF OLD.package != NEW.package OR OLD.type != NEW.type OR OLD.suite != NEW.suite THEN
+ RETURN NEW;
+ END IF;
+
+ IF OLD.priority != NEW.priority THEN
+ SELECT priority INTO STRICT v_priority FROM priority WHERE id = NEW.priority;
+ END IF;
+
+ IF OLD.component != NEW.component THEN
+ SELECT name INTO STRICT v_component FROM component WHERE id = NEW.component;
+ END IF;
+
+ IF OLD.section != NEW.section THEN
+ SELECT section INTO STRICT v_section FROM section WHERE id = NEW.section;
+ END IF;
+
+ -- Find out if we're doing src or binary overrides
+ SELECT id INTO STRICT v_src_override_id FROM override_type WHERE type = 'dsc';
+ IF OLD.type = v_src_override_id THEN
+ -- Doing a src_association link
+ INSERT INTO audit.package_changes
+ (package, version, architecture, suite, event, priority, component, section)
+ SELECT NEW.package, source.version, 'source', suite.suite_name, 'U', v_priority, v_component, v_section
+ FROM source
+ JOIN src_associations ON (source.id = src_associations.source)
+ JOIN suite ON (suite.id = src_associations.suite)
+ WHERE source.source = NEW.package AND src_associations.suite = NEW.suite;
+ ELSE
+ -- Doing a bin_association link
+ INSERT INTO audit.package_changes
+ (package, version, architecture, suite, event, priority, component, section)
+ SELECT NEW.package, binaries.version, architecture.arch_string, suite.suite_name, 'U', v_priority, v_component, v_section
+ FROM binaries
+ JOIN bin_associations ON (binaries.id = bin_associations.bin)
+ JOIN architecture ON (architecture.id = binaries.architecture)
+ JOIN suite ON (suite.id = bin_associations.suite)
+ WHERE binaries.package = NEW.package AND bin_associations.suite = NEW.suite;
+ END IF;
+
+ RETURN NEW;
+END;
+$$ LANGUAGE plpgsql VOLATILE SECURITY DEFINER
+SET search_path = public, pg_temp""");
+
+ c.execute("CREATE TRIGGER trigger_bin_associations_audit AFTER INSERT OR DELETE ON bin_associations FOR EACH ROW EXECUTE PROCEDURE trigger_binsrc_assoc_update()")
+ c.execute("CREATE TRIGGER trigger_src_associations_audit AFTER INSERT OR DELETE ON src_associations FOR EACH ROW EXECUTE PROCEDURE trigger_binsrc_assoc_update()")
+ c.execute("CREATE TRIGGER trigger_override_audit AFTER UPDATE ON override FOR EACH ROW EXECUTE PROCEDURE trigger_override_update()")
+
+ c.execute("UPDATE config SET value = '66' WHERE name = 'db_revision'")
+ self.db.commit()
+
+ except psycopg2.ProgrammingError, 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))
+ 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))
+ 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))
+ 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
os.system("bzip2 -d < %s.bz2 > %s" % (f, t))
else:
print "missing: %s" % (f)
- raise IOError, f
+ raise IOError(f)
def smartopen(file):
if os.path.isfile(file):
def main():
global Cnf, Options, Logger
- os.umask(0002)
+ os.umask(0o002)
Cnf = utils.get_conf()
Arguments = [ ('h', "help", "Generate-Index-Diffs::Options::Help"),
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.makedirs(keydir)
if secret:
# Make sure secret keyring directories are 0700
- os.chmod(keydir, 0700)
+ os.chmod(keydir, 0o700)
# Touch the file
print "Creating %s ..." % (fullpath)
file(fullpath, 'w')
if secret:
- os.chmod(fullpath, 0600)
+ os.chmod(fullpath, 0o600)
else:
- os.chmod(fullpath, 0644)
+ os.chmod(fullpath, 0o644)
######################################################################
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
################################################################################
-from __future__ import with_statement
-
import copy
import errno
import os
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
+ raise AlreadyLockedError(user)
try:
yield fd
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"]) = \
("", "", "", "")
from daklib.dbconn import *
from daklib import utils
from daklib.dak_exceptions import *
-from daklib.regexes import re_strip_source_version, re_build_dep_arch
+from daklib.regexes import re_strip_source_version, re_build_dep_arch, re_bin_only_nmu
import debianbts as bts
################################################################################
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
Subst_close_other = Subst_common
bcc = []
wnpp = utils.parse_wnpp_bug_file()
+ versions = list(set([re_bin_only_nmu.sub('', v) for v in versions]))
if len(versions) == 1:
Subst_close_other["__VERSION__"] = versions[0]
else:
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
os.unlink(lfn)
if os.path.exists(qfn):
os.symlink(qfn,lfn)
- os.chmod(qfn, 0644)
+ os.chmod(qfn, 0o644)
return (max(delaydays-1,0)*24*60*60+remainingtime, changesname, delay, uploader, achanges.get('closes','').split(),achanges, delaydays)
def list_uploads(filelist, rrd_dir):
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)
else:
trans = load_transitions(from_file)
if trans is None:
- raise TransitionsError, "Unparsable transitions file %s" % (file)
+ raise TransitionsError("Unparsable transitions file %s" % (file))
write_transitions(trans)
################################################################################
"""
(fd, path) = tempfile.mkstemp("", "transitions", Cnf["Dir::TempPath"])
- os.chmod(path, 0644)
+ os.chmod(path, 0o644)
f = open(path, "w")
yaml.dump(transitions, f, default_flow_style=False)
return path
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)
################################################################################
Cnf = None
-required_database_schema = 66
+required_database_schema = 67
################################################################################
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
logdir = Config()["Dir::Log"]
if not os.path.exists(logdir):
umask = os.umask(00000)
- os.makedirs(logdir, 02775)
+ os.makedirs(logdir, 0o2775)
os.umask(umask)
# Open the logfile
if debug:
logfile = sys.stderr
else:
- umask = os.umask(00002)
+ umask = os.umask(0o0002)
logfile = utils.open_file(logfilename, 'a')
os.umask(umask)
# 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
key = None
signingkey = False
- for line in k.xreadlines():
+ for line in k:
field = line.split(":")
if field[0] == "pub":
key = field[4]
# Find source id
bin_sources = get_sources_from_name(entry["source package"], entry["source version"], session=session)
if len(bin_sources) != 1:
- raise NoSourceFieldError, "Unable to find a unique source id for %s (%s), %s, file %s, type %s, signed by %s" % \
+ raise NoSourceFieldError("Unable to find a unique source id for %s (%s), %s, file %s, type %s, signed by %s" % \
(bin.package, bin.version, entry["architecture"],
- filename, bin.binarytype, u.pkg.changes["fingerprint"])
+ filename, bin.binarytype, u.pkg.changes["fingerprint"]))
bin.source_id = bin_sources[0].source_id
for srcname, version in entry["built-using"]:
exsources = get_sources_from_name(srcname, version, session=session)
if len(exsources) != 1:
- raise NoSourceFieldError, "Unable to find source package (%s = %s) in Built-Using for %s (%s), %s, file %s, type %s, signed by %s" % \
+ raise NoSourceFieldError("Unable to find source package (%s = %s) in Built-Using for %s (%s), %s, file %s, type %s, signed by %s" % \
(srcname, version, bin.package, bin.version, entry["architecture"],
- filename, bin.binarytype, u.pkg.changes["fingerprint"])
+ filename, bin.binarytype, u.pkg.changes["fingerprint"]))
bin.extra_sources.append(exsources[0])
self.__setuptables()
self.__setupmappers()
- except OperationalError, e:
+ except OperationalError as e:
import utils
utils.fubar("Cannot connect to database (%s)" % str(e))
# internal helper function
def rename(self, filename):
tempfilename = filename + '.new'
- os.chmod(tempfilename, 0664)
+ os.chmod(tempfilename, 0o664)
os.rename(tempfilename, filename)
def close(self):
format = re_verwithext.search(txt)
if format is None:
- raise UnknownFormatError, txt
+ raise UnknownFormatError(txt)
format = format.groups()
"""
if (format < (1, 5) or format > (1, 8)):
- raise UnknownFormatError, repr(format)
+ raise UnknownFormatError(repr(format))
if field != 'files' and format < (1, 8):
- raise UnknownFormatError, repr(format)
+ raise UnknownFormatError(repr(format))
dest = os.path.join(self.holding_dir, base_filename)
try:
- fd = os.open(dest, os.O_RDWR | os.O_CREAT | os.O_EXCL, 0640)
+ fd = os.open(dest, os.O_RDWR | os.O_CREAT | os.O_EXCL, 0o640)
os.close(fd)
- except OSError, e:
+ except OSError as e:
# Shouldn't happen, but will if, for example, someone lists a
# file twice in the .changes.
if e.errno == EEXIST:
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"] = ""
try:
control = apt_pkg.ParseSection(apt_inst.debExtractControl(deb_file))
except:
- self.rejects.append("%s: debExtractControl() raised %s." % (f, sys.exc_type))
+ self.rejects.append("%s: debExtractControl() raised %s." % (f, sys.exc_info()[0]))
deb_file.close()
# Can't continue, none of the checks on control would work.
return
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
self.rejects.append("%s: has %s file(s) with a time stamp too ancient (e.g. %s [%s])."
% (filename, num_ancient_files, ancient_file, time.ctime(ancient_date)))
except:
- self.rejects.append("%s: deb contents timestamp check failed [%s: %s]" % (filename, sys.exc_type, sys.exc_value))
+ self.rejects.append("%s: deb contents timestamp check failed [%s: %s]" % (filename, sys.exc_info()[0], sys.exc_info()[1]))
def check_if_upload_is_sponsored(self, uid_email, uid_name):
uid_email = '@'.join(uid_email.split('@')[:2])
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.
filename = "%s/%s" % (cnf["Dir::BTSVersionTrack"],
self.pkg.changes_file[:-8]+".versions")
os.rename(temp_filename, filename)
- os.chmod(filename, 0644)
+ os.chmod(filename, 0o644)
# Write out the binary -> source mapping.
(fd, temp_filename) = utils.temp_filename(cnf["Dir::BTSVersionTrack"], prefix=".")
filename = "%s/%s" % (cnf["Dir::BTSVersionTrack"],
self.pkg.changes_file[:-8]+".debinfo")
os.rename(temp_filename, filename)
- os.chmod(filename, 0644)
+ os.chmod(filename, 0o644)
session.commit()
dest_file = os.path.join(cnf["Dir::Reject"], file_entry)
try:
- dest_fd = os.open(dest_file, os.O_RDWR | os.O_CREAT | os.O_EXCL, 0644)
- except OSError, e:
+ dest_fd = os.open(dest_file, os.O_RDWR | os.O_CREAT | os.O_EXCL, 0o644)
+ except OSError as e:
# File exists? Let's find a new name by adding a number
if e.errno == errno.EEXIST:
try:
# Make sure we really got it
try:
- dest_fd = os.open(dest_file, os.O_RDWR|os.O_CREAT|os.O_EXCL, 0644)
- except OSError, e:
+ dest_fd = os.open(dest_file, os.O_RDWR|os.O_CREAT|os.O_EXCL, 0o644)
+ except OSError as e:
# Likewise
utils.warn("**WARNING** failed to claim %s in the reject directory." % (file_entry))
return
raise
# If we got here, we own the destination file, so we can
# safely overwrite it.
- utils.move(file_entry, dest_file, 1, perms=0660)
+ utils.move(file_entry, dest_file, 1, perms=0o660)
os.close(dest_fd)
###########################################################################
# so let's just raise an exception ...
if os.path.exists(reason_filename):
os.unlink(reason_filename)
- reason_fd = os.open(reason_filename, os.O_RDWR|os.O_CREAT|os.O_EXCL, 0644)
+ reason_fd = os.open(reason_filename, os.O_RDWR|os.O_CREAT|os.O_EXCL, 0o644)
rej_template = os.path.join(cnf["Dir::Templates"], "queue.rejected")
if format.re_format.match(txt):
return format
- raise UnknownFormatError, "Unknown format %r" % txt
+ raise UnknownFormatError("Unknown format %r" % txt)
class SourceFormat(type):
def __new__(cls, name, bases, attrs):
else:
m = re_parse_maintainer.match(maintainer)
if not m:
- raise ParseMaintError, "Doesn't parse as a valid Maintainer field."
+ raise ParseMaintError("Doesn't parse as a valid Maintainer field.")
name = m.group(1)
email = m.group(2)
rfc2047_maint = "%s <%s>" % (rfc2047_name, email)
if email.find("@") == -1 and email.find("buildd_") != 0:
- raise ParseMaintError, "No @ found in email address part."
+ raise ParseMaintError("No @ found in email address part.")
return (rfc822_maint, rfc2047_maint, name, email)
try:
f = open(filename, mode)
except IOError:
- raise CantOpenError, filename
+ raise CantOpenError(filename)
return f
################################################################################
lines = contents.splitlines(True)
if len(lines) == 0:
- raise ParseChangesError, "[Empty changes file]"
+ raise ParseChangesError("[Empty changes file]")
# Reindex by line number so we can easily verify the format of
# .dsc files...
line = indexed_lines[index]
if line == "" and signing_rules == 1:
if index != num_of_lines:
- raise InvalidDscError, index
+ raise InvalidDscError(index)
break
slf = re_single_line_field.match(line)
if slf:
mlf = re_multi_line_field.match(line)
if mlf:
if first == -1:
- raise ParseChangesError, "'%s'\n [Multi-line field continuing on from nothing?]" % (line)
+ raise ParseChangesError("'%s'\n [Multi-line field continuing on from nothing?]" % (line))
if first == 1 and changes[field] != "":
changes[field] += '\n'
first = 0
changes["source-version"] = srcver.group(2)
if error:
- raise ParseChangesError, error
+ raise ParseChangesError(error)
return changes
try:
unicode(content, 'utf-8')
except UnicodeError:
- raise ChangesUnicodeError, "Changes file not proper utf-8"
+ raise ChangesUnicodeError("Changes file not proper utf-8")
changes = parse_deb822(content, signing_rules, keyrings=keyrings)
missingfields.append(keyword)
if len(missingfields):
- raise ParseChangesError, "Missing mandantory field(s) in changes file (policy 5.5): %s" % (missingfields)
+ raise ParseChangesError("Missing mandantory field(s) in changes file (policy 5.5): %s" % (missingfields))
return changes
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
else:
(md5, size, name) = s
except ValueError:
- raise ParseChangesError, i
+ raise ParseChangesError(i)
if section == "":
section = "-"
os.unlink (filename);
return;
- fd = os.open(filename, os.O_RDWR|os.O_EXCL, 0700);
+ fd = os.open(filename, os.O_RDWR|os.O_EXCL, 0o700);
os.write (fd, message_raw.as_string(True));
os.close (fd);
# Invoke sendmail
(result, output) = commands.getstatusoutput("%s < %s" % (Cnf["Dinstall::SendmailCommand"], filename))
if (result != 0):
- raise SendmailFailedError, output
+ raise SendmailFailedError(output)
# Clean up any temporary files
if message:
################################################################################
-def move (src, dest, overwrite = 0, perms = 0664):
+def move (src, dest, overwrite = 0, perms = 0o664):
if os.path.exists(dest) and os.path.isdir(dest):
dest_dir = dest
else:
dest_dir = os.path.dirname(dest)
if not os.path.exists(dest_dir):
umask = os.umask(00000)
- os.makedirs(dest_dir, 02775)
+ os.makedirs(dest_dir, 0o2775)
os.umask(umask)
#print "Moving %s to %s..." % (src, dest)
if os.path.exists(dest) and os.path.isdir(dest):
os.chmod(dest, perms)
os.unlink(src)
-def copy (src, dest, overwrite = 0, perms = 0664):
+def copy (src, dest, overwrite = 0, perms = 0o664):
if os.path.exists(dest) and os.path.isdir(dest):
dest_dir = dest
else:
dest_dir = os.path.dirname(dest)
if not os.path.exists(dest_dir):
umask = os.umask(00000)
- os.makedirs(dest_dir, 02775)
+ os.makedirs(dest_dir, 0o2775)
os.umask(umask)
#print "Copying %s to %s..." % (src, dest)
if os.path.exists(dest) and os.path.isdir(dest):
# 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)