Skip to content

Commit

Permalink
Merge 5e6db29 into ebc5e40
Browse files Browse the repository at this point in the history
  • Loading branch information
opalmer committed Nov 1, 2015
2 parents ebc5e40 + 5e6db29 commit 4589e90
Show file tree
Hide file tree
Showing 2 changed files with 608 additions and 23 deletions.
28 changes: 16 additions & 12 deletions pyfarm/jobtypes/core/jobtype.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import tempfile
from errno import EEXIST
from datetime import datetime, timedelta
from functools import partial
from string import Template
from os.path import expanduser, abspath, isdir, join
from pprint import pformat
Expand All @@ -44,7 +43,6 @@

import treq
from twisted.internet import reactor
from twisted.internet.defer import Deferred
from twisted.internet.error import ProcessDone, ProcessTerminated
from twisted.python.failure import Failure
from twisted.internet.defer import inlineCallbacks, Deferred, returnValue
Expand All @@ -55,7 +53,7 @@
from pyfarm.core.enums import INTEGER_TYPES, STRING_TYPES, WorkState, WINDOWS
from pyfarm.core.utility import ImmutableDict
from pyfarm.agent.config import config
from pyfarm.agent.http.core.client import post, http_retry_delay, post_direct
from pyfarm.agent.http.core.client import http_retry_delay, post_direct
from pyfarm.agent.logger import getLogger
from pyfarm.agent.sysinfo import memory, system
from pyfarm.agent.sysinfo.user import is_administrator, username
Expand Down Expand Up @@ -646,22 +644,22 @@ def get_command_data(self):
raise NotImplementedError("`get_command_data` must be implemented")

# TODO: finish map_path() implementation
# TODO: update TestJobTypeMapPath
def map_path(self, path):
"""
Takes a string argument. Translates a given path for any OS to
what it should be on this particular node. This does not communicate
with the master.
"""
self._check_map_path_inputs(path)
path = self.expandvars(path)
return path
return self.expandvars(path)

def expandvars(self, value, environment=None, expand=None):
"""
Expands variables inside of a string using an environment. Exp
Expands variables inside of a string using an environment.
:param string value:
The path to expand
The string to expand.
:param dict environment:
The environment to use for expanding ``value``. If this
Expand Down Expand Up @@ -1555,13 +1553,16 @@ def handle_stdout_line(self, protocol, stdout):
"""
# Preprocess
preprocessed = self.preprocess_stdout_line(protocol, stdout)
if preprocessed is not None:
stdout = preprocessed

if preprocessed is False:
return

if preprocessed is not None:
stdout = preprocessed

# Format
formatted = self.format_stdout_line(protocol, stdout)

if formatted is not None:
stdout = formatted

Expand Down Expand Up @@ -1605,13 +1606,16 @@ def handle_stderr_line(self, protocol, stderr):
"""
# Preprocess
preprocessed = self.preprocess_stderr_line(protocol, stderr)

if preprocessed is False:
return

if preprocessed is not None:
stderr = preprocessed
if preprocessed == False:
return

# Format
formatted = self.format_stderr_line(protocol, stderr)

if formatted is not None:
stderr = formatted

Expand Down Expand Up @@ -1759,7 +1763,7 @@ def log_stderr_line(self, protocol, stderr):
produced by this method will not be consumed by other methods.
"""
if config["jobtype_capture_process_output"]:
process_stdout.info("task %r: %s", protocol.id, stderr)
process_stderr.info("task %r: %s", protocol.id, stderr)
else:
logpool.log(self.uuid, STDERR, stderr, protocol.pid)

Expand Down

0 comments on commit 4589e90

Please sign in to comment.