From ba14d22954dad64884e0160817cd73e40db8bd17 Mon Sep 17 00:00:00 2001 From: Michael Bienia Date: Fri, 7 Aug 2009 12:53:33 +0200 Subject: [PATCH] requestsync: more refactoring --- requestsync | 11 ----------- ubuntutools/requestsync/mail.py | 14 ++++++++++++++ 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/requestsync b/requestsync index edce8a0..b500514 100755 --- a/requestsync +++ b/requestsync @@ -129,17 +129,6 @@ def cur_version_component(sourcepkg, release): print "%s doesn't appear to exist in %s, specify -n for a package not in Ubuntu." % (sourcepkg, release) sys.exit(1) -def get_email_address(): - '''Get the DEBEMAIL environment variable or give an error.''' - myemailaddr = os.getenv('DEBEMAIL') - if not myemailaddr: - myemailaddr = os.getenv('EMAIL') - if not myemailaddr: - print >> sys.stderr, 'The environment variable DEBEMAIL or ' +\ - 'EMAIL 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.''' diff --git a/ubuntutools/requestsync/mail.py b/ubuntutools/requestsync/mail.py index 46b73e6..1a7a724 100644 --- a/ubuntutools/requestsync/mail.py +++ b/ubuntutools/requestsync/mail.py @@ -19,6 +19,8 @@ # Please see the /usr/share/common-licenses/GPL-2 file for the full text # of the GNU General Public License license. +import os +import sys import subprocess from ..lp.udtexceptions import PackageNotFoundException @@ -79,3 +81,15 @@ def getDebianSrcPkg(name, release): def getUbuntuSrcPkg(name, release): return getSrcPkg('ubuntu', name, release) + +def get_email_address(): + ''' + Get the From email address from the DEBEMAIL or EMAIL environment + variable or give an error. + ''' + myemailaddr = os.getenv('DEBEMAIL') or os.getenv('EMAIL') + if not myemailaddr: + print >> sys.stderr, 'The environment variable DEBEMAIL or ' \ + 'EMAIL needs to be set to let this script mail the ' \ + 'sync request.' + return myemailaddr