X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=lisa;h=99319f55affff5b703afb17e20161a11ef88c487;hb=cf2534974c1c82dcfb6a12a5df4df6abba890492;hp=1467b0e9a29354bf18145566f426bf132ccfd87e;hpb=e6f9691c67b50f990263c71b71e471b6a00dcb9f;p=dak.git diff --git a/lisa b/lisa index 1467b0e9..99319f55 100755 --- a/lisa +++ b/lisa @@ -1,8 +1,8 @@ #!/usr/bin/env python # Handles NEW and BYHAND packages -# Copyright (C) 2001, 2002, 2003 James Troup -# $Id: lisa,v 1.26 2003-11-17 17:59:26 troup Exp $ +# Copyright (C) 2001, 2002, 2003, 2004 James Troup +# $Id: lisa,v 1.30 2004-04-01 17:13:11 troup Exp $ # 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 @@ -37,12 +37,12 @@ ################################################################################ -import copy, errno, os, readline, stat, sys, tempfile; +import copy, errno, os, readline, stat, sys; import apt_pkg, apt_inst; import db_access, fernanda, katie, logging, utils; # Globals -lisa_version = "$Revision: 1.26 $"; +lisa_version = "$Revision: 1.30 $"; Cnf = None; Options = None; @@ -394,9 +394,7 @@ def index_range (index): def edit_new (new): # Write the current data to a temporary file - temp_filename = tempfile.mktemp(); - fd = os.open(temp_filename, os.O_RDWR|os.O_CREAT|os.O_EXCL, 0700); - os.close(fd); + temp_filename = utils.temp_filename(); temp_file = utils.open_file(temp_filename, 'w'); print_new (new, 0, temp_file); temp_file.close(); @@ -472,7 +470,7 @@ def edit_index (new, index): got_priority = 0; while not got_priority: new_priority = utils.our_raw_input("New priority: ").strip(); - if Priorities.priorities.count(new_priority) == 0: + if new_priority not in Priorities.priorities: print "E: '%s' is not a valid priority, try again." % (new_priority); else: got_priority = 1; @@ -484,7 +482,7 @@ def edit_index (new, index): got_section = 0; while not got_section: new_section = utils.our_raw_input("New section: ").strip(); - if Sections.sections.count(new_section) == 0: + if new_section not in Sections.sections: print "E: '%s' is not a valid section, try again." % (new_section); else: got_section = 1; @@ -542,9 +540,7 @@ def edit_overrides (new): def edit_note(note): # Write the current data to a temporary file - temp_filename = tempfile.mktemp(); - fd = os.open(temp_filename, os.O_RDWR|os.O_CREAT|os.O_EXCL, 0700); - os.close(fd); + temp_filename = utils.temp_filename(); temp_file = utils.open_file(temp_filename, 'w'); temp_file.write(note); temp_file.close(); @@ -646,6 +642,52 @@ def add_overrides (new): ################################################################################ +def prod_maintainer (): + # Here we prepare an editor and get them ready to prod... + temp_filename = utils.temp_filename(); + editor = os.environ.get("EDITOR","vi") + answer = 'E'; + while answer == 'E': + os.system("%s %s" % (editor, temp_filename)) + file = utils.open_file(temp_filename); + prod_message = "".join(file.readlines()); + file.close(); + print "Prod message:"; + print utils.prefix_multi_line_string(prod_message," ",include_blank_lines=1); + prompt = "[P]rod, Edit, Abandon, Quit ?" + answer = "XXX"; + while prompt.find(answer) == -1: + answer = utils.our_raw_input(prompt); + m = katie.re_default_answer.search(prompt); + if answer == "": + answer = m.group(1); + answer = answer[:1].upper(); + os.unlink(temp_filename); + if answer == 'A': + return; + elif answer == 'Q': + sys.exit(0); + # Otherwise, do the proding... + user_email_address = utils.whoami() + " <%s>" % ( + Cnf["Dinstall::MyAdminAddress"]); + + Subst = Katie.Subst; + + Subst["__FROM_ADDRESS__"] = user_email_address; + Subst["__PROD_MESSAGE__"] = prod_message; + Subst["__CC__"] = "Cc: " + Cnf["Dinstall::MyEmailAddress"]; + + prod_mail_message = utils.TemplateSubst( + Subst,Cnf["Dir::Templates"]+"/lisa.prod"); + + # Send the prod mail if appropriate + if not Cnf["Dinstall::Options::No-Mail"]: + utils.send_mail(prod_mail_message); + + print "Sent proding message"; + +################################################################################ + def do_new(): print "NEW\n"; files = Katie.pkg.files; @@ -690,7 +732,7 @@ def do_new(): print "W: note must be removed before package can be processed."; prompt += "Remove note, "; - prompt += "Edit overrides, Check, Manual reject, Note edit, [S]kip, Quit ?"; + prompt += "Edit overrides, Check, Manual reject, Note edit, Prod, [S]kip, Quit ?"; while prompt.find(answer) == -1: answer = utils.our_raw_input(prompt); @@ -712,6 +754,8 @@ def do_new(): done = 1; elif answer == 'N': edit_note(changes.get("lisa note", "")); + elif answer == 'P': + prod_maintainer(); elif answer == 'R': confirm = utils.our_raw_input("Really clear note (y/N)? ").lower(); if confirm == "y":