Compress to log files in socInstaller.py script (where too big).

This commit is contained in:
Jean-Paul Chaput 2016-11-10 13:46:45 +01:00
parent 3ef5ced601
commit b536421d3a
2 changed files with 21 additions and 0 deletions

View File

@ -0,0 +1,2 @@
# Nightly build of Coriolis.
0 4 * * * ${HOME}/bin/socInstaller.py --nightly --rm-all --benchs > /dev/null 2>&1

View File

@ -34,6 +34,7 @@ try:
import subprocess import subprocess
import socket import socket
import re import re
import bz2
import smtplib import smtplib
from email.mime.text import MIMEText from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart from email.mime.multipart import MIMEMultipart
@ -337,6 +338,21 @@ class Configuration ( object ):
if fd: fd.close() if fd: fd.close()
return return
def compressLogs ( self ):
for log in self._logs.values():
if not log: continue
fd = open( log, 'r' )
bzfd = bz2.BZ2File( log+'.bz2', 'w' )
for line in fd.readlines(): bzfd.write( line )
bzfd.close()
fd.close()
os.unlink( log )
return
class Report ( object ): class Report ( object ):
@ -500,6 +516,7 @@ try:
Command( [ 'ssh', host, command ], fd ).execute() Command( [ 'ssh', host, command ], fd ).execute()
conf.closeLogs() conf.closeLogs()
conf.success = True conf.success = True
except ErrorMessage, e: except ErrorMessage, e:
@ -518,4 +535,6 @@ if conf.doSendReport:
report.attachLog( conf.logs['benchs'] ) report.attachLog( conf.logs['benchs'] )
report.send() report.send()
conf.compressLogs()
sys.exit( conf.rcode ) sys.exit( conf.rcode )