From e7794eea2065cc1322ee4859c681d6681a316089 Mon Sep 17 00:00:00 2001 From: "Martin A. Brown" Date: Mon, 7 Mar 2016 22:13:23 -0800 Subject: [PATCH] relocating function --- tldp/utils.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tldp/utils.py b/tldp/utils.py index 1d12225..adec896 100644 --- a/tldp/utils.py +++ b/tldp/utils.py @@ -100,14 +100,6 @@ def swapdirs(a, b): os.rmdir(tdir) -def conditionallogging(result, prefix, fname): - if logger.isEnabledFor(logging.DEBUG): - logfilecontents(logger.info, prefix, fname) # -- always - elif logger.isEnabledFor(logging.INFO): - if result != 0: - logfilecontents(logger.info, prefix, fname) # -- error - - def logfilecontents(logmethod, prefix, fname): '''log all lines of a file with a prefix ''' with open(fname) as f: @@ -115,6 +107,14 @@ def logfilecontents(logmethod, prefix, fname): logmethod("%s: %s", prefix, line.rstrip()) +def conditionallogging(result, prefix, fname): + if logger.isEnabledFor(logging.DEBUG): + logfilecontents(logger.debug, prefix, fname) # -- always + elif logger.isEnabledFor(logging.INFO): + if result != 0: + logfilecontents(logger.info, prefix, fname) # -- error + + def execute(cmd, stdin=None, stdout=None, stderr=None, logdir=None, env=os.environ): '''(yet another) wrapper around subprocess.Popen()