Return-Path: Delivered-To: apmail-gump-general-archive@www.apache.org Received: (qmail 61879 invoked from network); 24 Apr 2004 15:25:20 -0000 Received: from daedalus.apache.org (HELO mail.apache.org) (208.185.179.12) by minotaur-2.apache.org with SMTP; 24 Apr 2004 15:25:20 -0000 Received: (qmail 84360 invoked by uid 500); 24 Apr 2004 15:25:13 -0000 Delivered-To: apmail-gump-general-archive@gump.apache.org Received: (qmail 84338 invoked by uid 500); 24 Apr 2004 15:25:13 -0000 Mailing-List: contact general-help@gump.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Gump code and data" Reply-To: "Gump code and data" Delivered-To: mailing list general@gump.apache.org Received: (qmail 84323 invoked by uid 500); 24 Apr 2004 15:25:13 -0000 Received: (qmail 84320 invoked from network); 24 Apr 2004 15:25:13 -0000 Received: from unknown (HELO minotaur.apache.org) (209.237.227.194) by daedalus.apache.org with SMTP; 24 Apr 2004 15:25:13 -0000 Received: (qmail 61866 invoked by uid 1728); 24 Apr 2004 15:25:18 -0000 Date: 24 Apr 2004 15:25:18 -0000 Message-ID: <20040424152518.61865.qmail@minotaur.apache.org> From: ajack@apache.org To: gump-cvs@apache.org Subject: cvs commit: gump/python/gump/output nag.py statsdb.py X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N ajack 2004/04/24 08:25:18 Modified: python/gump/model project.py . gumpy.py minimal-workspace.xml python/gump integrate.py python/gump/test syndicator.py python/gump/core config.py engine.py python gmp.py python/gump/output nag.py statsdb.py Log: E-mail & Result (exit code) cleanup. Revision Changes Path 1.79 +3 -0 gump/python/gump/model/project.py Index: project.py =================================================================== RCS file: /home/cvs/gump/python/gump/model/project.py,v retrieving revision 1.78 retrieving revision 1.79 diff -u -r1.78 -r1.79 --- project.py 23 Apr 2004 18:09:24 -0000 1.78 +++ project.py 24 Apr 2004 15:25:18 -0000 1.79 @@ -303,6 +303,9 @@ if cause and cause == self: if not project in self.affectedProjects: self.affectedProjects.append(project) + + # Sort whatever we got + self.affectedProjects.sort() def propagateErrorStateChange(self,state,reason,cause,message): 1.25 +65 -6 gump/gumpy.py Index: gumpy.py =================================================================== RCS file: /home/cvs/gump/gumpy.py,v retrieving revision 1.24 retrieving revision 1.25 diff -u -r1.24 -r1.25 --- gumpy.py 23 Apr 2004 18:09:24 -0000 1.24 +++ gumpy.py 24 Apr 2004 15:25:18 -0000 1.25 @@ -94,7 +94,8 @@ catFile(log,outputFile) os.remove(outputFile) - log.write('Exit Code : ' + `exit_code` + '\n') + if exit_code: + log.write('Process Exit Code : ' + `exit_code` + '\n') finally: if originalCWD: os.chdir(originalCWD) @@ -181,7 +182,42 @@ except: # Somehow another could delete this, even if locked... pass + + +def tailFile(file,lines,eol=None,marker=None): + """ Return the last N lines of a file as a list """ + taillines=[] + try: + o=None + try: + # Read lines from the file... + o=open(file, 'r') + line=o.readline() + + size=0 + while line: + # Store the lines + taillines.append(line) + + # But dump any before 'lines' + size=len(taillines) + if size > lines: + del taillines[0:(size-lines)] + size=len(taillines) + + # Read next... + line=o.readline() + finally: + if o: o.close() + except Exception, details: + print 'Failed to tail :' + file + ' : ' + str(details) + + return taillines + +def tailFileToString(file,lines,eol=None,marker=None): + return "".join(tailFile(file,lines,eol,marker)) + # Allow a lock lockFile=os.path.abspath('gumpy.lock') lock=establishLock(lockFile) @@ -196,7 +232,8 @@ pass # Enable a log -logFile=os.path.abspath('gumpy_log.txt') +logFileName='gumpy_log.txt' +logFile=os.path.abspath(logFileName) log=open(logFile,'w',0) # Unbuffered... result=0 @@ -359,7 +396,7 @@ releaseLock(lock,lockFile) if result: - logTitle='The Apache Gump log...' + logTitle='Problem running Apache Gump...' # :TODO: Need to check if stdout is a plain terminal? Not sure, see next. # :TODO: On some cron set-ups this will mail the log, on @@ -368,7 +405,7 @@ # Cat log if failed... published=0 if logdir: - publishedLogFile=os.path.abspath(os.path.join(logdir,'gumpy_log.txt')) + publishedLogFile=os.path.abspath(os.path.join(logdir,logFileName)) try: publishedLog=open(publishedLogFile,'w',0) # Unbuffered... catFile(publishedLog, logFile, logTitle) @@ -395,8 +432,30 @@ #logData=tmpStream.read() #tmpStream.close() #tmpStream=None - logData='There is a problem with the run at : ' + logurl - sendEmail(mailto,mailfrom,logTitle,logData,mailserver,mailport) + mailData='There is a problem with the run at : ' + logurl + '\n' + + # + # :TODO: Add link to log + # :TODO: Tail log + # + try: + maxTailLines=50 + tailData=tailFileToString(logFile,maxTailLines) + mailData += '------------------------------------------------------------\n' + mailData += 'The log ought be at:\n' + mailData += ' ' + logFileUrl=logurl + if not logFileUrl.endswith('/'): logFileUrl+='/' + logFileUrl+=logFileName + mailData += logFileUrl + mailData += '\n' + mailData += '------------------------------------------------------------\n' + mailData += 'The last (up to) %s lines of the log are :\n' % maxTailLines + mailData += tailData + except: + pass + + sendEmail(mailto,mailfrom,logTitle,mailData,mailserver,mailport) # bye! sys.exit(result) 1.4 +4 -1 gump/minimal-workspace.xml Index: minimal-workspace.xml =================================================================== RCS file: /home/cvs/gump/minimal-workspace.xml,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- minimal-workspace.xml 16 Mar 2004 19:50:14 -0000 1.3 +++ minimal-workspace.xml 24 Apr 2004 15:25:18 -0000 1.4 @@ -27,7 +27,10 @@ and build stuff. If you use any packages available as binaries only, you need to set pkgdir as well. --> - +