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:
#write out the child pid
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
#since it will do the right cleanups that we want
#not calling any atexit functions, which would

View File

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