From b536421d3abb358c9bb31141b215f640f364cda9 Mon Sep 17 00:00:00 2001 From: Jean-Paul Chaput Date: Thu, 10 Nov 2016 13:46:45 +0100 Subject: [PATCH] Compress to log files in socInstaller.py script (where too big). --- bootstrap/crontab.nightly | 2 ++ bootstrap/socInstaller.py | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 bootstrap/crontab.nightly diff --git a/bootstrap/crontab.nightly b/bootstrap/crontab.nightly new file mode 100644 index 00000000..20287537 --- /dev/null +++ b/bootstrap/crontab.nightly @@ -0,0 +1,2 @@ +# Nightly build of Coriolis. +0 4 * * * ${HOME}/bin/socInstaller.py --nightly --rm-all --benchs > /dev/null 2>&1 diff --git a/bootstrap/socInstaller.py b/bootstrap/socInstaller.py index 30df34d1..3f3d7b19 100755 --- a/bootstrap/socInstaller.py +++ b/bootstrap/socInstaller.py @@ -34,6 +34,7 @@ try: import subprocess import socket import re + import bz2 import smtplib from email.mime.text import MIMEText from email.mime.multipart import MIMEMultipart @@ -337,6 +338,21 @@ class Configuration ( object ): if fd: fd.close() 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 ): @@ -500,6 +516,7 @@ try: Command( [ 'ssh', host, command ], fd ).execute() conf.closeLogs() + conf.success = True except ErrorMessage, e: @@ -518,4 +535,6 @@ if conf.doSendReport: report.attachLog( conf.logs['benchs'] ) report.send() +conf.compressLogs() + sys.exit( conf.rcode )