From 7d89c91b82d5db6d7562e17bd68f6a6b3979e10b Mon Sep 17 00:00:00 2001 From: Siegfried-Angel Gevatter Pujals Date: Mon, 4 Aug 2008 15:16:07 +0200 Subject: [PATCH] requestsync: If the email interface is used, check if DEBEMAIL is set before anything else (LP: #254632). --- debian/changelog | 3 +++ requestsync | 16 +++++++++++++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/debian/changelog b/debian/changelog index 8eacd13..66988a7 100644 --- a/debian/changelog +++ b/debian/changelog @@ -2,6 +2,9 @@ ubuntu-dev-tools (0.35) intrepid; urgency=low * doc/update-maintainer.1: - Remove the reference to the --no-changelog option from the manpage. + * requestsync: + - If the email interface is used, check if DEBEMAIL is set before anything + else (LP: #254632). -- Siegfried-Angel Gevatter Pujals Mon, 04 Aug 2008 14:50:15 +0200 diff --git a/requestsync b/requestsync index 41f8ff4..4cfde41 100755 --- a/requestsync +++ b/requestsync @@ -123,6 +123,14 @@ Options: ''' sys.exit(1) +def get_email_address(): + '''Get the DEBEMAIL environment variable or give an error.''' + myemailaddr = os.getenv('DEBEMAIL') + if not myemailaddr: + print >> sys.stderr, 'The environment variable DEBEMAIL needs to be ' +\ + ' set to make use of this script, unless you use option --lp.' + return myemailaddr + def mail_bug(source_package, subscribe, status, bugtitle, bugtext, keyid = None): '''Submit the sync request per email. Return True if email successfully send, otherwise False.''' @@ -132,9 +140,8 @@ def mail_bug(source_package, subscribe, status, bugtitle, bugtext, keyid = None) to = 'new@bugs.launchpad.net' - myemailaddr = os.getenv('DEBEMAIL') + myemailaddr = get_email_address() if not myemailaddr: - print >> sys.stderr, 'The environment variable DEBEMAIL needs to be set to make use of this script.' return False # generate initial mailbody @@ -362,10 +369,13 @@ if __name__ == '__main__': if o == '-s': sponsorship = True if o == '-k': keyid = a if o == '--lp': use_lp_bugs = True - + if len(args) not in (2, 3): usage() + if not use_lp_bugs and not get_email_address(): + sys.exit(1) + (srcpkg, release) = args[:2] force_base_ver = None if len(args) == 3: