Cnf = utils.get_conf()
- Arguments = [('h',"help","Edit-Transitions::Options::Help"),
+ Arguments = [('a',"automatic","Edit-Transitions::Options::Automatic"),
+ ('h',"help","Edit-Transitions::Options::Help"),
('e',"edit","Edit-Transitions::Options::Edit"),
('i',"import","Edit-Transitions::Options::Import", "HasArg"),
('c',"check","Edit-Transitions::Options::Check"),
('s',"sudo","Edit-Transitions::Options::Sudo"),
('n',"no-action","Edit-Transitions::Options::No-Action")]
- for i in ["help", "no-action", "edit", "import", "check", "sudo"]:
+ for i in ["automatic", "help", "no-action", "edit", "import", "check", "sudo"]:
if not Cnf.has_key("Edit-Transitions::Options::%s" % (i)):
Cnf["Edit-Transitions::Options::%s" % (i)] = ""
-i, --import <file> check and import transitions from file
-c, --check check the transitions file, remove outdated entries
-S, --sudo use sudo to update transitions file
+ -a, --automatic don't prompt (only affects check).
-n, --no-action don't do anything (only affects check)"""
sys.exit(exit_code)
def check_transitions(transitions):
"""
Check if the defined transitions still apply and remove those that no longer do.
- @note: Asks the user for confirmation first.
+ @note: Asks the user for confirmation first unless -a has been set.
"""
+ global Cnf
+
to_dump = 0
to_remove = []
+ info = {}
# Now look through all defined transitions
for trans in transitions:
t = transitions[trans]
# Will be None if nothing is in testing.
current = database.get_suite_version(source, "testing")
- print get_info(trans, source, expected, t["rm"], t["reason"], t["packages"])
+ info[trans] = get_info(trans, source, expected, t["rm"], t["reason"], t["packages"])
+ print info[trans]
if current == None:
# No package in testing
if Options["no-action"]:
answer="n"
+ elif Options["automatic"]:
+ answer="y"
else:
answer = utils.our_raw_input(prompt).lower()
sys.exit(0)
elif answer == 'y':
print "Committing"
+ subst = {}
+ subst['__TRANSITION_MESSAGE__'] = "The following transitions were removed:\n"
for remove in to_remove:
+ subst['__TRANSITION_MESSAGE__'] += info[remove] + '\n'
del transitions[remove]
edit_file = temp_transitions_file(transitions)
write_transitions_from_file(edit_file)
+ # If we have a mail address configured for transitions,
+ # send a notification
+ subst['__TRANSITION_EMAIL__'] = Cnf.get("Transitions::Notifications", "")
+ if subst['__TRANSITION_EMAIL__'] != "":
+ print "Sending notification to %s" % subst['__TRANSITION__EMAIL__']
+ subst['__DAK_ADDRESS__'] = Cnf["Dinstall::MyEmailAddress"]
+ subst['__BCC__'] = 'X-DAK: dak transitions'
+ if Cnf.has_key("Dinstall::Bcc"):
+ subst["__BCC__"] += '\nBcc: %s' % Cnf["Dinstall:Bcc"]
+ message = utils.TemplateSubst(subst,
+ os.path.join(Cnf["Dir::Templates"], 'transition.removed'))
+ utils.send_mail(message)
+
print "Done"
else:
print "WTF are you typing?"