[sysadmin-bin] py-install-module: make code a bit clearer
- From: Olav Vitters <ovitters src gnome org>
- To: gnome-sysadmin gnome org,commits-list gnome org
- Subject: [sysadmin-bin] py-install-module: make code a bit clearer
- Date: Mon, 7 Mar 2011 09:40:10 +0000 (UTC)
commit 8348002703680b1c356e3b01b2c7b062395a2f68
Author: Olav Vitters <olav vitters nl>
Date: Mon Mar 7 10:40:04 2011 +0100
py-install-module: make code a bit clearer
py-install-module | 38 ++++++++++++++++++++++++--------------
1 files changed, 24 insertions(+), 14 deletions(-)
---
diff --git a/py-install-module b/py-install-module
index 3bf1e9a..54ac510 100755
--- a/py-install-module
+++ b/py-install-module
@@ -760,11 +760,11 @@ script to gnome-sysadmin gnome org Thanks."""
sys.stdout.write(" - Adding new version to GNOME Bugzilla")
cmd = ['/usr/bin/curl', '-L', 'https://bugzilla.gnome.org/add-version.cgi?%s|%s' % (self.module, self.version)]
- self._call_progress(cmd)
+ self._call_cmd(cmd)
sys.stdout.write(" - Triggering ftp.gnome.org update")
syncscript = ['/usr/local/bin/signal-ftp-sync']
- if self._call_progress(cmd):
+ if self._call_cmd(cmd):
print ""
print "Your tarball will appear in the following location on ftp.gnome.org:"
print ""
@@ -780,23 +780,32 @@ script to gnome-sysadmin gnome org Thanks."""
shutil.copyfileobj(f, sys.stdout)
- def _call_progress(self, cmd):
- status = False
- if os.path.isfile(cmd[0]):
- status = True
- if not DEBUG:
- retcode = subprocess.call(cmd)
- print "done (exit code %s)" % retcode
- else:
- print ", ignored (debug mode)"
- else:
+ def _call_cmd(self, cmd):
+ """Calls a certain command and shows progress
+
+ Note: returns True even if exit code is not zero."""
+
+ if not os.path.isfile(cmd[0]):
print ", FAILED (cannot find %s)" % cmd[0]
print "PLEASE INFORM gnome-sysadmin gnome org ASAP!!!"
- return status
+ return False
+
+ if DEBUG:
+ print ", ignored (debug mode)"
+ return True
+
+ retcode = subprocess.call(cmd)
+ if retcode == 0:
+ print ", done"
+ else:
+ print "FAILED (exit code %s)" % retcode
+
+ return True
def _send_email(self, contents, subject, to, smtp_to):
+ """Send an email"""
msg = MIMEText(contents, _charset='utf-8')
msg['Subject'] = subject
msg['From'] = '"%s" <install-module master gnome org>' % self.who
@@ -805,7 +814,8 @@ script to gnome-sysadmin gnome org Thanks."""
if DEBUG:
smtp_to = ['olav vitters nl']
- cmd = ['/usr/sbin/sendmail', '-oi', '-f', 'install-module master gnome org', '--']
+ # Call sendmail program directly so it doesn't matter if the service is running
+ cmd = ['/usr/sbin/sendmail', '-oi', '-f', 'noreply gnome org', '--']
cmd.extend(smtp_to)
p = subprocess.Popen(cmd, stdin=subprocess.PIPE)
p.stdin.write(msg.as_string())
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]