From: Tony Mack Date: Tue, 8 Apr 2008 18:15:08 +0000 (+0000) Subject: modify header() to make logging output optional. X-Git-Tag: tests-4.2-4~67 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=6ac92caedc7c2ada996bac6c96f958033632268b;p=tests.git modify header() to make logging output optional. --- diff --git a/qaapi/qa/utils.py b/qaapi/qa/utils.py index 89854e1..40eb086 100644 --- a/qaapi/qa/utils.py +++ b/qaapi/qa/utils.py @@ -4,15 +4,17 @@ import os from commands import getstatusoutput from logger import logfile -def header(message): +def header(message, log = True): now=time.strftime("%H:%M:%S", time.localtime()) output = "*"+now+'--'+message print output - print >> logfile, output + if log: + print >> logfile, output def popen(command, fatal=True, verbose = False): + header(command) if verbose: - header(command) + header(command, False) (stdin, stdout, stderr) = os.popen3(command) output = stdout.readlines() print >> logfile, "+ "+command @@ -27,14 +29,14 @@ def popen(command, fatal=True, verbose = False): def popen3(command, verbose = False): if verbose: - header(command) + header(command, False) (stdin, stdout, stderr) = os.popen3(command) print >> logfile, "+ "+command return (stdin, stdout, stderr) def commands(command, fatal = True, verbose = False): if verbose: - header(command) + header(command, False) (status, output) = getstatusoutput(command) print >> logfile, "+ "+command print >> logfile, output.strip()