From 738149c9bfb9965d013d01ef99f9bb1c2819e7e8 Mon Sep 17 00:00:00 2001 From: Luca Falavigna Date: Tue, 15 Jun 2010 14:28:22 +0000 Subject: Imported Upstream version 2.0.0 --- bin/time-scons.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'bin/time-scons.py') diff --git a/bin/time-scons.py b/bin/time-scons.py index 78d26e5..b7d8ef1 100644 --- a/bin/time-scons.py +++ b/bin/time-scons.py @@ -46,7 +46,7 @@ TimeSCons_revision = 4569 TimeSCons_pieces = ['QMTest', 'timings', 'runtest.py'] -class CommandRunner: +class CommandRunner(object): """ Executor class for commands, including "commands" implemented by Python functions. @@ -81,11 +81,11 @@ class CommandRunner: def display(self, command, stdout=None, stderr=None): if not self.verbose: return - if type(command) == type(()): + if isinstance(command, tuple): func = command[0] args = command[1:] s = '%s(%s)' % (func.__name__, ', '.join(map(repr, args))) - if type(command) == type([]): + if isinstance(command, list): # TODO: quote arguments containing spaces # TODO: handle meta characters? s = ' '.join(command) @@ -102,12 +102,12 @@ class CommandRunner: """ if not self.active: return 0 - if type(command) == type(''): + if isinstance(command, str): command = self.subst(command) cmdargs = shlex.split(command) if cmdargs[0] == 'cd': command = (os.chdir,) + tuple(cmdargs[1:]) - if type(command) == type(()): + if isinstance(command, tuple): func = command[0] args = command[1:] return func(*args) @@ -260,13 +260,15 @@ def do_revisions(cr, opts, branch, revisions, scripts): lf = os.path.join(opts.origin, opts.logsdir, subdir, log_name) out = open(lf, 'w') err = None + close_out = True else: out = stdout err = stderr + close_out = False s = cr.run(script_command(script), stdout=out, stderr=err) if s and status == 0: status = s - if out not in (sys.stdout, None): + if close_out: out.close() out = None -- cgit v1.2.3