relocating function

This commit is contained in:
Martin A. Brown 2016-03-07 22:13:23 -08:00
parent b2e01eec73
commit e7794eea20
1 changed files with 8 additions and 8 deletions

View File

@ -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()