Beispiel #1
0
def get_reject_reason(reason=''):
    """get reason for rejection

    @rtype:  str
    @return: string giving the reason for the rejection or C{None} if the
             rejection should be cancelled
    """
    answer = 'E'
    if Options['Automatic']:
        answer = 'R'

    while answer == 'E':
        reason = utils.call_editor(reason)
        print "Reject message:"
        print utils.prefix_multi_line_string(reason, "  ", include_blank_lines=1)
        prompt = "[R]eject, Edit, Abandon, Quit ?"
        answer = "XXX"
        while prompt.find(answer) == -1:
            answer = utils.our_raw_input(prompt)
            m = re_default_answer.search(prompt)
            if answer == "":
                answer = m.group(1)
            answer = answer[:1].upper()

    if answer == 'Q':
        sys.exit(0)

    if answer == 'R':
        return reason
    return None
Beispiel #2
0
def get_reject_reason(reason=''):
    """get reason for rejection

    @rtype:  str
    @return: string giving the reason for the rejection or C{None} if the
             rejection should be cancelled
    """
    answer = 'E'
    if Options['Automatic']:
        answer = 'R'

    while answer == 'E':
        reason = utils.call_editor(reason)
        print "Reject message:"
        print utils.prefix_multi_line_string(reason,
                                             "  ",
                                             include_blank_lines=1)
        prompt = "[R]eject, Edit, Abandon, Quit ?"
        answer = "XXX"
        while prompt.find(answer) == -1:
            answer = utils.our_raw_input(prompt)
            m = re_default_answer.search(prompt)
            if answer == "":
                answer = m.group(1)
            answer = answer[:1].upper()

    if answer == 'Q':
        sys.exit(0)

    if answer == 'R':
        return reason
    return None
Beispiel #3
0
def do_new(upload, upload_copy, handler, session):
    cnf = Config()

    run_user_inspect_command(upload, upload_copy)

    # The main NEW processing loop
    done = False
    missing = []
    while not done:
        queuedir = upload.policy_queue.path
        byhand = upload.byhand

        missing = handler.missing_overrides(hints=missing)
        broken = not check_valid(missing, session)

        changesname = os.path.basename(upload.changes.changesname)

        print
        print changesname
        print "-" * len(changesname)
        print
        print "   Target:     {0}".format(upload.target_suite.suite_name)
        print "   Changed-By: {0}".format(upload.changes.changedby)
        print

        #if len(byhand) == 0 and len(missing) == 0:
        #    break

        if missing:
            print "NEW\n"

        answer = "XXX"
        if Options["No-Action"] or Options["Automatic"]:
            answer = 'S'

        note = print_new(upload, missing, indexed=0, session=session)
        prompt = ""

        has_unprocessed_byhand = False
        for f in byhand:
            path = os.path.join(queuedir, f.filename)
            if not f.processed and os.path.exists(path):
                print "W: {0} still present; please process byhand components and try again".format(f.filename)
                has_unprocessed_byhand = True

        if not has_unprocessed_byhand and not broken and not note:
            if len(missing) == 0:
                prompt = "Accept, "
                answer = 'A'
            else:
                prompt = "Add overrides, "
        if broken:
            print "W: [!] marked entries must be fixed before package can be processed."
        if note:
            print "W: note must be removed before package can be processed."
            prompt += "RemOve all notes, Remove note, "

        prompt += "Edit overrides, Check, Manual reject, Note edit, Prod, [S]kip, Quit ?"

        while prompt.find(answer) == -1:
            answer = utils.our_raw_input(prompt)
            m = re_default_answer.search(prompt)
            if answer == "":
                answer = m.group(1)
            answer = answer[:1].upper()

        if answer in ( 'A', 'E', 'M', 'O', 'R' ) and Options["Trainee"]:
            utils.warn("Trainees can't do that")
            continue

        if answer == 'A' and not Options["Trainee"]:
            add_overrides(missing, upload.target_suite, session)
            if Config().find_b("Dinstall::BXANotify"):
                do_bxa_notification(missing, upload, session)
            handler.accept()
            done = True
            Logger.log(["NEW ACCEPT", upload.changes.changesname])
        elif answer == 'C':
            check_pkg(upload, upload_copy, session)
        elif answer == 'E' and not Options["Trainee"]:
            missing = edit_overrides (missing, upload, session)
        elif answer == 'M' and not Options["Trainee"]:
            reason = Options.get('Manual-Reject', '') + "\n"
            reason = reason + "\n\n=====\n\n".join([n.comment for n in get_new_comments(upload.policy_queue, upload.changes.source, session=session)])
            reason = get_reject_reason(reason)
            if reason is not None:
                Logger.log(["NEW REJECT", upload.changes.changesname])
                handler.reject(reason)
                done = True
        elif answer == 'N':
            if edit_note(get_new_comments(upload.policy_queue, upload.changes.source, session=session),
                         upload, session, bool(Options["Trainee"])) == 0:
                end()
                sys.exit(0)
        elif answer == 'P' and not Options["Trainee"]:
            if prod_maintainer(get_new_comments(upload.policy_queue, upload.changes.source, session=session),
                               upload) == 0:
                end()
                sys.exit(0)
            Logger.log(["NEW PROD", upload.changes.changesname])
        elif answer == 'R' and not Options["Trainee"]:
            confirm = utils.our_raw_input("Really clear note (y/N)? ").lower()
            if confirm == "y":
                for c in get_new_comments(upload.policy_queue, upload.changes.source, upload.changes.version, session=session):
                    session.delete(c)
                session.commit()
        elif answer == 'O' and not Options["Trainee"]:
            confirm = utils.our_raw_input("Really clear all notes (y/N)? ").lower()
            if confirm == "y":
                for c in get_new_comments(upload.policy_queue, upload.changes.source, session=session):
                    session.delete(c)
                session.commit()

        elif answer == 'S':
            done = True
        elif answer == 'Q':
            end()
            sys.exit(0)

        if handler.get_action():
            print "PENDING %s\n" % handler.get_action()
Beispiel #4
0
def do_new(upload, upload_copy, handler, session):
    cnf = Config()

    run_user_inspect_command(upload, upload_copy)

    # The main NEW processing loop
    done = False
    missing = []
    while not done:
        queuedir = upload.policy_queue.path
        byhand = upload.byhand

        missing = handler.missing_overrides(hints=missing)
        broken = not check_valid(missing, session)

        changesname = os.path.basename(upload.changes.changesname)

        print
        print changesname
        print "-" * len(changesname)
        print
        print "   Target:     {0}".format(upload.target_suite.suite_name)
        print "   Changed-By: {0}".format(upload.changes.changedby)
        print

        #if len(byhand) == 0 and len(missing) == 0:
        #    break

        if missing:
            print "NEW\n"

        for package in missing:
            if package["type"] == "deb" and package["priority"] == "extra":
                package["priority"] = "optional"

        answer = "XXX"
        if Options["No-Action"] or Options["Automatic"]:
            answer = 'S'

        note = print_new(upload, missing, indexed=0, session=session)
        prompt = ""

        has_unprocessed_byhand = False
        for f in byhand:
            path = os.path.join(queuedir, f.filename)
            if not f.processed and os.path.exists(path):
                print "W: {0} still present; please process byhand components and try again".format(
                    f.filename)
                has_unprocessed_byhand = True

        if not has_unprocessed_byhand and not broken and not note:
            if len(missing) == 0:
                prompt = "Accept, "
                answer = 'A'
            else:
                prompt = "Add overrides, "
        if broken:
            print "W: [!] marked entries must be fixed before package can be processed."
        if note:
            print "W: note must be removed before package can be processed."
            prompt += "RemOve all notes, Remove note, "

        prompt += "Edit overrides, Check, Manual reject, Note edit, Prod, [S]kip, Quit ?"

        while prompt.find(answer) == -1:
            answer = utils.our_raw_input(prompt)
            m = re_default_answer.search(prompt)
            if answer == "":
                answer = m.group(1)
            answer = answer[:1].upper()

        if answer in ('A', 'E', 'M', 'O', 'R') and Options["Trainee"]:
            utils.warn("Trainees can't do that")
            continue

        if answer == 'A' and not Options["Trainee"]:
            add_overrides(missing, upload.target_suite, session)
            if Config().find_b("Dinstall::BXANotify"):
                do_bxa_notification(missing, upload, session)
            handler.accept()
            done = True
            Logger.log(["NEW ACCEPT", upload.changes.changesname])
        elif answer == 'C':
            check_pkg(upload, upload_copy, session)
        elif answer == 'E' and not Options["Trainee"]:
            missing = edit_overrides(missing, upload, session)
        elif answer == 'M' and not Options["Trainee"]:
            reason = Options.get('Manual-Reject', '') + "\n"
            reason = reason + "\n\n=====\n\n".join([
                n.comment for n in get_new_comments(upload.policy_queue,
                                                    upload.changes.source,
                                                    session=session)
            ])
            reason = get_reject_reason(reason)
            if reason is not None:
                Logger.log(["NEW REJECT", upload.changes.changesname])
                handler.reject(reason)
                done = True
        elif answer == 'N':
            if edit_note(
                    get_new_comments(upload.policy_queue,
                                     upload.changes.source,
                                     session=session), upload, session,
                    bool(Options["Trainee"])) == 0:
                end()
                sys.exit(0)
        elif answer == 'P' and not Options["Trainee"]:
            if prod_maintainer(
                    get_new_comments(upload.policy_queue,
                                     upload.changes.source,
                                     session=session), upload) == 0:
                end()
                sys.exit(0)
            Logger.log(["NEW PROD", upload.changes.changesname])
        elif answer == 'R' and not Options["Trainee"]:
            confirm = utils.our_raw_input("Really clear note (y/N)? ").lower()
            if confirm == "y":
                for c in get_new_comments(upload.policy_queue,
                                          upload.changes.source,
                                          upload.changes.version,
                                          session=session):
                    session.delete(c)
                session.commit()
        elif answer == 'O' and not Options["Trainee"]:
            confirm = utils.our_raw_input(
                "Really clear all notes (y/N)? ").lower()
            if confirm == "y":
                for c in get_new_comments(upload.policy_queue,
                                          upload.changes.source,
                                          session=session):
                    session.delete(c)
                session.commit()

        elif answer == 'S':
            done = True
        elif answer == 'Q':
            end()
            sys.exit(0)

        if handler.get_action():
            print "PENDING %s\n" % handler.get_action()
Beispiel #5
0
def do_byhand(upload, session):
    done = 0
    while not done:
        files = upload.pkg.files
        will_install = True
        byhand = []

        for f in files.keys():
            if files[f]["section"] == "byhand":
                if os.path.exists(f):
                    print "W: %s still present; please process byhand components and try again." % (f)
                    will_install = False
                else:
                    byhand.append(f)

        answer = "XXXX"
        if Options["No-Action"]:
            answer = "S"
        if will_install:
            if Options["Automatic"] and not Options["No-Action"]:
                answer = 'A'
            prompt = "[A]ccept, Manual reject, Skip, Quit ?"
        else:
            prompt = "Manual reject, [S]kip, Quit ?"

        while prompt.find(answer) == -1:
            answer = utils.our_raw_input(prompt)
            m = re_default_answer.search(prompt)
            if answer == "":
                answer = m.group(1)
            answer = answer[:1].upper()

        if answer == 'A':
            dbchg = get_dbchange(upload.pkg.changes_file, session)
            if dbchg is None:
                print "Warning: cannot find changes file in database; can't process BYHAND"
            else:
                try:
                    check_daily_lock()
                    done = 1
                    for b in byhand:
                        # Find the file entry in the database
                        found = False
                        for f in dbchg.files:
                            if f.filename == b:
                                found = True
                                f.processed = True
                                break

                        if not found:
                            print "Warning: Couldn't find BYHAND item %s in the database to mark it processed" % b

                    session.commit()
                    Logger.log(["BYHAND ACCEPT: %s" % (upload.pkg.changes_file)])
                except CantGetLockError:
                    print "Hello? Operator! Give me the number for 911!"
                    print "Dinstall in the locked area, cant process packages, come back later"
        elif answer == 'M':
            aborted = upload.do_reject(manual=1,
                                       reject_message=Options["Manual-Reject"],
                                       notes=get_new_comments(changes.get("source", ""), session=session))
            if not aborted:
                upload.pkg.remove_known_changes(session=session)
                session.commit()
                Logger.log(["BYHAND REJECT: %s" % (upload.pkg.changes_file)])
                done = 1
        elif answer == 'S':
            done = 1
        elif answer == 'Q':
            end()
            sys.exit(0)
Beispiel #6
0
def do_new(upload, session):
    print "NEW\n"
    files = upload.pkg.files
    upload.check_files(not Options["No-Action"])
    changes = upload.pkg.changes
    cnf = Config()

    # Check for a valid distribution
    upload.check_distributions()

    # Make a copy of distribution we can happily trample on
    changes["suite"] = copy.copy(changes["distribution"])

    # Try to get an included dsc
    dsc = None
    (status, _) = upload.load_dsc()
    if status:
        dsc = upload.pkg.dsc

    # The main NEW processing loop
    done = 0
    new = {}
    while not done:
        # Find out what's new
        new, byhand = determine_new(upload.pkg.changes_file, changes, files, dsc=dsc, session=session, new=new)

        if not new:
            break

        answer = "XXX"
        if Options["No-Action"] or Options["Automatic"]:
            answer = 'S'

        (broken, note) = print_new(new, upload, indexed=0)
        prompt = ""

        if not broken and not note:
            prompt = "Add overrides, "
        if broken:
            print "W: [!] marked entries must be fixed before package can be processed."
        if note:
            print "W: note must be removed before package can be processed."
            prompt += "RemOve all notes, Remove note, "

        prompt += "Edit overrides, Check, Manual reject, Note edit, Prod, [S]kip, Quit ?"

        while prompt.find(answer) == -1:
            answer = utils.our_raw_input(prompt)
            m = re_default_answer.search(prompt)
            if answer == "":
                answer = m.group(1)
            answer = answer[:1].upper()

        if answer in ( 'A', 'E', 'M', 'O', 'R' ) and Options["Trainee"]:
            utils.warn("Trainees can't do that")
            continue

        if answer == 'A' and not Options["Trainee"]:
            try:
                check_daily_lock()
                done = add_overrides (new, upload, session)
                new_accept(upload, Options["No-Action"], session)
                Logger.log(["NEW ACCEPT: %s" % (upload.pkg.changes_file)])
            except CantGetLockError:
                print "Hello? Operator! Give me the number for 911!"
                print "Dinstall in the locked area, cant process packages, come back later"
        elif answer == 'C':
            check_pkg(upload)
        elif answer == 'E' and not Options["Trainee"]:
            new = edit_overrides (new, upload, session)
        elif answer == 'M' and not Options["Trainee"]:
            aborted = upload.do_reject(manual=1,
                                       reject_message=Options["Manual-Reject"],
                                       notes=get_new_comments(changes.get("source", ""), session=session))
            if not aborted:
                upload.pkg.remove_known_changes(session=session)
                session.commit()
                Logger.log(["NEW REJECT: %s" % (upload.pkg.changes_file)])
                done = 1
        elif answer == 'N':
            edit_note(get_new_comments(changes.get("source", ""), session=session),
                      upload, session, bool(Options["Trainee"]))
        elif answer == 'P' and not Options["Trainee"]:
            prod_maintainer(get_new_comments(changes.get("source", ""), session=session),
                            upload)
            Logger.log(["NEW PROD: %s" % (upload.pkg.changes_file)])
        elif answer == 'R' and not Options["Trainee"]:
            confirm = utils.our_raw_input("Really clear note (y/N)? ").lower()
            if confirm == "y":
                for c in get_new_comments(changes.get("source", ""), changes.get("version", ""), session=session):
                    session.delete(c)
                session.commit()
        elif answer == 'O' and not Options["Trainee"]:
            confirm = utils.our_raw_input("Really clear all notes (y/N)? ").lower()
            if confirm == "y":
                for c in get_new_comments(changes.get("source", ""), session=session):
                    session.delete(c)
                session.commit()

        elif answer == 'S':
            done = 1
        elif answer == 'Q':
            end()
            sys.exit(0)