Merge branch '2.4.4' of ssh://git.tasktools.org/tm/task into 2.4.4

This commit is contained in:
Paul Beckingham
2015-04-26 09:23:08 -04:00
2 changed files with 26 additions and 6 deletions

View File

@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
from __future__ import division
from __future__ import division, print_function
import os
import tempfile
import shutil
@@ -39,7 +39,7 @@ class Taskd(object):
TASKD_NOT_LISTENING = 3
def __init__(self, taskd=DEFAULT_TASKD, certpath=None,
address="localhost"):
address="127.0.0.1"):
"""Initialize a Task server that runs in the background and stores data
in a temporary folder
@@ -207,6 +207,8 @@ class Taskd(object):
self.proc = Popen(cmd, stdout=PIPE, stderr=PIPE, stdin=DEVNULL,
env=self.env)
else:
self.show_log_contents()
raise OSError("Taskd server is still running or crashed")
# Wait for server to listen by checking connectivity in the port
@@ -218,6 +220,8 @@ class Taskd(object):
return
elif status == self.TASKD_NEVER_STARTED:
self.show_log_contents()
raise OSError("Task server was never started. "
"This shouldn't happen!!")
@@ -225,6 +229,8 @@ class Taskd(object):
# Collect output logs
out, err = self.proc.communicate()
self.show_log_contents()
raise OSError(
"Task server launched with '{0}' crashed or exited "
"prematurely. Exit code: {1}. "
@@ -242,6 +248,8 @@ class Taskd(object):
sleep(1 / tries_per_minute)
else:
self.show_log_contents()
raise OSError("Unknown running status for taskd '{0}'".format(
status))
@@ -251,6 +259,8 @@ class Taskd(object):
# Collect output logs
out, err = self.proc.communicate()
self.show_log_contents()
raise OSError("Task server didn't start and listen on port {0} after "
"{1} minutes. Stdout: {2!r}. Stderr: {3!r}.".format(
self.port, minutes, out, err))
@@ -339,4 +349,14 @@ class Taskd(object):
return parse_datafile(file)
def show_log_contents(self):
"""Print to to STDOUT the contents of taskd.log
"""
if os.path.isfile(self.tasklog):
with open(self.tasklog) as fh:
print("#### Start taskd.log ####")
for line in fh:
print(line, end='')
print("#### End taskd.log ####")
# vim: ai sts=4 et sw=4

View File

@@ -130,8 +130,8 @@ def _queue_output(arguments, pidq, outputq):
"",
("Unexpected exception caught during execution of taskw: '{0}' . "
"If you are running out-of-tree tests set USE_PATH=1 in shell "
"env before execution and add the location of the task binary to "
"the PATH".format(e)),
"env before execution and add the location of the task(d) binary "
"to the PATH".format(e)),
255)) # false exitcode
return
@@ -279,7 +279,7 @@ def get_IPs(hostname):
return output
def port_used(addr="localhost", port=None):
def port_used(addr="127.0.0.1", port=None):
"Return True if port is in use, False otherwise"
if port is None:
raise TypeError("Argument 'port' may not be None")
@@ -304,7 +304,7 @@ def port_used(addr="localhost", port=None):
return False
def find_unused_port(addr="localhost", start=53589, track=True):
def find_unused_port(addr="127.0.0.1", start=53589, track=True):
"""Find an unused port starting at `start` port
If track=False the returned port will not be marked as in-use and the code