mirror of https://github.com/tLDP/python-tldp
relocating function
This commit is contained in:
parent
b2e01eec73
commit
e7794eea20
|
@ -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()
|
||||
|
|
Loading…
Reference in New Issue