def main(): global Options, Logger cnf = Config() session = DBConn().session() Arguments = [('h', "help", "Process-Policy::Options::Help"), ('n', "no-action", "Process-Policy::Options::No-Action")] for i in ["help", "no-action"]: key = "Process-Policy::Options::%s" % i if key not in cnf: cnf[key] = "" queue_name = apt_pkg.parse_commandline(cnf.Cnf, Arguments, sys.argv) if len(queue_name) != 1: print("E: Specify exactly one policy queue") sys.exit(1) queue_name = queue_name[0] Options = cnf.subtree("Process-Policy::Options") if Options["Help"]: usage() Logger = daklog.Logger("process-policy") if not Options["No-Action"]: urgencylog = UrgencyLog() with ArchiveTransaction() as transaction: session = transaction.session try: pq = session.query(PolicyQueue).filter_by( queue_name=queue_name).one() except NoResultFound: print("E: Cannot find policy queue %s" % queue_name) sys.exit(1) commentsdir = os.path.join(pq.path, 'COMMENTS') # The comments stuff relies on being in the right directory os.chdir(pq.path) do_comments(commentsdir, pq, "REJECT.", "REJECTED.", "NOTOK", comment_reject, transaction) do_comments(commentsdir, pq, "ACCEPT.", "ACCEPTED.", "OK", comment_accept, transaction) do_comments(commentsdir, pq, "ACCEPTED.", "ACCEPTED.", "OK", comment_accept, transaction) remove_unreferenced_binaries(pq, transaction) remove_unreferenced_sources(pq, transaction) if not Options['No-Action']: urgencylog.close()
def main(): global Options, Logger cnf = Config() for i in ["Help", "No-Action", "All"]: if not cnf.has_key("Manage-Build-Queues::Options::%s" % (i)): cnf["Manage-Build-Queues::Options::%s" % (i)] = "" Arguments = [('h', "help", "Manage-Build-Queues::Options::Help"), ('n', "no-action", "Manage-Build-Queues::Options::No-Action"), ('a', "all", "Manage-Build-Queues::Options::All")] queue_names = apt_pkg.parse_commandline(cnf.Cnf, Arguments, sys.argv) Options = cnf.subtree("Manage-Build-Queues::Options") if Options["Help"]: usage() Logger = daklog.Logger('manage-build-queues', Options['No-Action']) starttime = datetime.now() session = DBConn().session() with ArchiveTransaction() as transaction: session = transaction.session if Options['All']: if len(queue_names) != 0: print "E: Cannot use both -a and a queue name" sys.exit(1) queues = session.query(BuildQueue) else: queues = session.query(BuildQueue).filter( BuildQueue.queue_name.in_(queue_names)) for q in queues: Logger.log([ 'cleaning queue %s using datetime %s' % (q.queue_name, starttime) ]) clean(q, transaction, now=starttime) if not Options['No-Action']: transaction.commit() else: transaction.rollback() Logger.close()
def main(): from daklib.config import Config config = Config() import apt_pkg arguments = [ ('h', 'help', 'Update-Suite::Options::Help'), ('n', 'no-act', 'Update-Suite::options::NoAct'), ] argv = apt_pkg.parse_commandline(config.Cnf, arguments, sys.argv) try: options = config.subtree("Update-Suite::Options") except KeyError: options = {} if 'Help' in options or len(argv) != 2: usage() origin_name = argv[0] target_name = argv[1] dry_run = True if 'NoAct' in options else False with ArchiveTransaction() as transaction: session = transaction.session try: origin = session.query(Suite).filter_by( suite_name=origin_name).one() except NoResultFound: daklib.utils.fubar( "Origin suite '{0}' is unknown.".format(origin_name)) try: target = session.query(Suite).filter_by( suite_name=target_name).one() except NoResultFound: daklib.utils.fubar( "Target suite '{0}' is unknown.".format(target_name)) su = SuiteUpdater(transaction, origin, target, dry_run=dry_run) su.update_suite() if dry_run: transaction.rollback() else: transaction.commit()
def main(): global Options, Logger cnf = Config() for i in ["Help", "No-Action", "All"]: key = "Manage-Debug-Suites::Options::%s" % i if key not in cnf: cnf[key] = "" Arguments = [('h', "help", "Manage-Debug-Suites::Options::Help"), ('n', "no-action", "Manage-Debug-Suites::Options::No-Action"), ('a', "all", "Manage-Debug-Suites::Options::All")] debug_suite_names = apt_pkg.parse_commandline(cnf.Cnf, Arguments, sys.argv) Options = cnf.subtree("Manage-Debug-Suites::Options") if Options["Help"]: usage() Logger = daklog.Logger('manage-debug-suites', Options['No-Action']) with ArchiveTransaction() as transaction: session = transaction.session if Options['All']: if len(debug_suite_names) != 0: print("E: Cannot use both -a and a queue name") sys.exit(1) raise Exception("Not yet implemented.") else: debug_suites = session.query(Suite).filter( Suite.suite_name.in_(debug_suite_names)) for debug_suite in debug_suites: Logger.log( ['cleaning debug suite {0}'.format(debug_suite.suite_name)]) clean(debug_suite, transaction) if not Options['No-Action']: transaction.commit() else: transaction.rollback() Logger.close()
def main(): global Logger cnf = Config() Arguments = [('a', "add", "Control-Suite::Options::Add", "HasArg"), ('b', "britney", "Control-Suite::Options::Britney"), ('f', 'force', 'Control-Suite::Options::Force'), ('h', "help", "Control-Suite::Options::Help"), ('l', "list", "Control-Suite::Options::List", "HasArg"), ('r', "remove", "Control-Suite::Options::Remove", "HasArg"), ('s', "set", "Control-Suite::Options::Set", "HasArg")] for i in ["add", "britney", "help", "list", "remove", "set", "version"]: key = "Control-Suite::Options::%s" % i if key not in cnf: cnf[key] = "" try: file_list = apt_pkg.parse_commandline(cnf.Cnf, Arguments, sys.argv) except SystemError as e: print("%s\n" % e) usage(1) Options = cnf.subtree("Control-Suite::Options") if Options["Help"]: usage() force = "Force" in Options and Options["Force"] action = None for i in ("add", "list", "remove", "set"): if cnf["Control-Suite::Options::%s" % (i)] != "": suite_name = cnf["Control-Suite::Options::%s" % (i)] if action: utils.fubar("Can only perform one action at a time.") action = i # Need an action... if action is None: utils.fubar("No action specified.") britney = False if action == "set" and cnf["Control-Suite::Options::Britney"]: britney = True if action == "list": session = DBConn().session() suite = session.query(Suite).filter_by(suite_name=suite_name).one() get_list(suite, session) else: Logger = daklog.Logger("control-suite") with ArchiveTransaction() as transaction: session = transaction.session suite = session.query(Suite).filter_by(suite_name=suite_name).one() if action == "set" and not suite.allowcsset: if force: utils.warn( "Would not normally allow setting suite {0} (allowcsset is FALSE), but --force used" .format(suite_name)) else: utils.fubar( "Will not reset suite {0} due to its database configuration (allowcsset is FALSE)" .format(suite_name)) if file_list: for f in file_list: process_file(utils.open_file(f), suite, action, transaction, britney, force) else: process_file(sys.stdin, suite, action, transaction, britney, force) Logger.close()