Created
September 3, 2009 11:17
-
-
Save baoilleach/180247 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import os, os.path | |
import sys | |
import smtplib | |
import datetime | |
nightly_dir = '/home/oboyle/not-backed-up' | |
output = open(os.path.join(nightly_dir, 'log.txt'),"a") | |
now = datetime.datetime.now() | |
print >>output, now | |
# stdin, stdout, stderr = os.popen3("/home/no228/Tools/OpenBabel/autobuild/nightly.sh > /dev/null") | |
stdin, stdout, stderr = os.popen3('%s > /dev/null' % (os.path.join(nightly_dir, | |
'nightly.sh'))) | |
errormessages = stderr.read() | |
if not errormessages: | |
print >>output, "No error messages" | |
sys.exit(0) | |
errors = errormessages.strip().split("\n") | |
if not errors[-1].find("failed!")>=0: | |
print >>output, "Nothing failed" | |
sys.exit(0) | |
svninfo = "No info on SVN revision" | |
svninfofile = os.path.join(nightly_dir, 'svninfo.txt') | |
if os.path.isfile(svninfofile): | |
input = open(svninfofile,"r") | |
svninfo = input.read() | |
input.close() | |
message = svninfo + "\n\n" + errormessages | |
print >>output, message | |
server = smtplib.SMTP("jeeves",25) | |
server.sendmail("oboyle@ccdc.cam.ac.uk","baoilleach@gmail.com","From: %s\r\nSubject: Automated build failure\r\nTo: %s\r\n\r\n%s" % ("oboyle@ccdc.cam.ac.uk","baoilleach@gmail.com",message)) | |
print >>output, "Email sent" | |
output.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment