Updated so fork does not have output when it writes to its pid file and updated util to make this possible.

This commit is contained in:
Joshua Harlow
2012-01-21 19:42:10 -08:00
parent 938c4517d6
commit 92df56947e
2 changed files with 15 additions and 10 deletions

View File

@@ -145,7 +145,7 @@ class ForkRunner(runner.Runner):
else: else:
#write out the child pid #write out the child pid
contents = str(pid) + os.linesep contents = str(pid) + os.linesep
sh.write_file(pid_fn, contents) sh.write_file(pid_fn, contents, quiet=True)
#not exit or sys.exit, this is recommended #not exit or sys.exit, this is recommended
#since it will do the right cleanups that we want #since it will do the right cleanups that we want
#not calling any atexit functions, which would #not calling any atexit functions, which would

View File

@@ -187,25 +187,28 @@ def mkdirslist(path):
return dirs_made return dirs_made
def append_file(fn, text, flush=True): def append_file(fn, text, flush=True, quiet=False):
LOG.debug("Appending to file %s (%d bytes)", fn, len(text)) if(not quiet):
LOG.debug("Appending to file %s (%d bytes)", fn, len(text))
with open(fn, "a") as f: with open(fn, "a") as f:
f.write(text) f.write(text)
if(flush): if(flush):
f.flush() f.flush()
def write_file(fn, text, flush=True): def write_file(fn, text, flush=True, quiet=False):
LOG.debug("Writing to file %s (%d bytes)", fn, len(text)) if(not quiet):
LOG.debug("Writing to file %s (%d bytes)", fn, len(text))
with open(fn, "w") as f: with open(fn, "w") as f:
f.write(text) f.write(text)
if(flush): if(flush):
f.flush() f.flush()
def touch_file(fn, die_if_there=True): def touch_file(fn, die_if_there=True, quiet=False):
if(not isfile(fn)): if(not isfile(fn)):
LOG.debug("Touching and truncating file %s", fn) if(not quiet):
LOG.debug("Touching and truncating file %s", fn)
with open(fn, "w") as f: with open(fn, "w") as f:
f.truncate(0) f.truncate(0)
else: else:
@@ -214,12 +217,14 @@ def touch_file(fn, die_if_there=True):
raise excp.FileException(msg) raise excp.FileException(msg)
def load_file(fn): def load_file(fn, quiet=False):
LOG.debug("Loading data from file %s", fn) if(not quiet):
LOG.debug("Loading data from file %s", fn)
data = "" data = ""
with open(fn, "r") as f: with open(fn, "r") as f:
data = f.read() data = f.read()
LOG.debug("Loaded (%d) bytes from file %s", len(data), fn) if(not quiet):
LOG.debug("Loaded (%d) bytes from file %s", len(data), fn)
return data return data