X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;ds=sidebyside;f=dak%2Fprocess_new.py;h=8f3ad0cfe022f2862a9a7f31a52676bc4b080370;hb=f7b6c67d2c9dedbf7b2dabbc83afd2e8730cca83;hp=a4cb01713f6ee7dabd5bd2fe31809186206a2128;hpb=a59ca3145f204083ffcf5edf322d5b6ee2c4e0f8;p=dak.git diff --git a/dak/process_new.py b/dak/process_new.py index a4cb0171..8f3ad0cf 100755 --- a/dak/process_new.py +++ b/dak/process_new.py @@ -55,6 +55,7 @@ from daklib import logging from daklib import queue from daklib import utils from daklib.regexes import re_no_epoch, re_default_answer, re_isanum +from daklib.dak_exceptions import CantOpenError # Globals Cnf = None #: Configuration, apt_pkg.Configuration @@ -113,7 +114,7 @@ def recheck(): if reject_message.find("Rejected") != -1: answer = "XXX" - if Options["No-Action"] or Options["Automatic"]: + if Options["No-Action"] or Options["Automatic"] or Options["Trainee"]: answer = 'S' print "REJECT\n" + reject_message, @@ -220,7 +221,7 @@ def sort_changes(changes_files): mtime = os.stat(d["filename"])[stat.ST_MTIME] if mtime < oldest: oldest = mtime - have_note += (database.has_new_comment(d["source"], d["version"]) + have_note += (database.has_new_comment(d["source"], d["version"])) per_source[source]["oldest"] = oldest if not have_note: per_source[source]["note_state"] = 0; # none @@ -469,7 +470,9 @@ def edit_note(note): # Write the current data to a temporary file (fd, temp_filename) = utils.temp_filename() temp_file = os.fdopen(fd, 'w') - temp_file.write(note) + if len(note) > 0: + for line in note: + temp_file.write(line) temp_file.close() editor = os.environ.get("EDITOR","vi") answer = 'E' @@ -679,20 +682,20 @@ def do_new(): answer = m.group(1) answer = answer[:1].upper() - if answer == 'A': + if answer == 'A' and not Options["Trainee"]: done = add_overrides (new) elif answer == 'C': check_pkg() - elif answer == 'E': + elif answer == 'E' and not Options["Trainee"]: new = edit_overrides (new) - elif answer == 'M': + elif answer == 'M' and not Options["Trainee"]: aborted = Upload.do_reject(1, Options["Manual-Reject"]) if not aborted: os.unlink(Upload.pkg.changes_file[:-8]+".dak") done = 1 elif answer == 'N': edit_note(database.get_new_comments(changes.get("source", ""))) - elif answer == 'P': + elif answer == 'P' and not Options["Trainee"]: prod_maintainer() elif answer == 'R': confirm = utils.our_raw_input("Really clear note (y/N)? ").lower() @@ -715,6 +718,7 @@ def usage (exit_code=0): -C, --comments-dir=DIR use DIR as comments-dir, for [o-]p-u-new -m, --manual-reject=MSG manual reject with `msg' -n, --no-action don't do anything + -t, --trainee FTP Trainee mode -V, --version display the version number and exit""" sys.exit(exit_code) @@ -729,9 +733,10 @@ def init(): ('h',"help","Process-New::Options::Help"), ('C',"comments-dir","Process-New::Options::Comments-Dir", "HasArg"), ('m',"manual-reject","Process-New::Options::Manual-Reject", "HasArg"), + ('t',"trainee","Process-New::Options::Trainee"), ('n',"no-action","Process-New::Options::No-Action")] - for i in ["automatic", "help", "manual-reject", "no-action", "version", "comments-dir"]: + for i in ["automatic", "help", "manual-reject", "no-action", "version", "comments-dir", "trainee"]: if not Cnf.has_key("Process-New::Options::%s" % (i)): Cnf["Process-New::Options::%s" % (i)] = "" @@ -747,7 +752,10 @@ def init(): Upload = queue.Upload(Cnf) if not Options["No-Action"]: - Logger = Upload.Logger = logging.Logger(Cnf, "process-new") + try: + Logger = Upload.Logger = logging.Logger(Cnf, "process-new") + except CantOpenError, e: + Options["Trainee"] = "Oh yes" projectB = Upload.projectB @@ -975,7 +983,7 @@ def end(): sys.stderr.write("Accepted %d package %s, %s.\n" % (accept_count, sets, utils.size_type(int(accept_bytes)))) Logger.log(["total",accept_count,accept_bytes]) - if not Options["No-Action"]: + if not Options["No-Action"] and not Options["Trainee"]:: Logger.close() ################################################################################