Commit 8ffce0bd authored by Łukasz Nowak's avatar Łukasz Nowak

squash! taskdistribution: Wrap in xmlrpclib.Binary if needed

Do not binarize on low level in _retryRPC, but choose some parameters,
especially those, which come from subprocess output or similar unsure
sources.
parent 328d4a2c
...@@ -96,7 +96,8 @@ def patchRPCParser(error_handler): ...@@ -96,7 +96,8 @@ def patchRPCParser(error_handler):
parser_klass.feed = verbose_feed parser_klass.feed = verbose_feed
def binarize_args(arg): def binarize_args(arg):
# Converts recursively basestring arg into Binary # Converts recursively basestring arg into xmlrpclib.Binary, as they can
# contain non-XML allowed characters
if isinstance(arg, basestring): if isinstance(arg, basestring):
if isinstance(arg, unicode): if isinstance(arg, unicode):
arg = arg.encode('utf-8') arg = arg.encode('utf-8')
...@@ -119,9 +120,6 @@ class RPCRetry(object): ...@@ -119,9 +120,6 @@ class RPCRetry(object):
def _retryRPC(self, func_id, args=()): def _retryRPC(self, func_id, args=()):
retry_time = self._retry_time retry_time = self._retry_time
# Wrap basestrings into xmlrpclib.Binary, as they can contain
# non-XML allowed characters
args = binarize_args(args)
while True: while True:
try: try:
return self._RPC(func_id, args) return self._RPC(func_id, args)
...@@ -185,16 +183,16 @@ class TestResultLineProxy(RPCRetry): ...@@ -185,16 +183,16 @@ class TestResultLineProxy(RPCRetry):
('skip_count', skip_count), ('skip_count', skip_count),
('duration', duration), ('duration', duration),
('date', date), ('date', date),
('command', command), ('command', binarize_args(command)),
('stdout', stdout), ('stdout', binarize_args(stdout)),
('stderr', stderr), ('stderr', binarize_args(stderr)),
('html_test_result', html_test_result), ('html_test_result', binarize_args(html_test_result)),
) if x[1] is not None) ) if x[1] is not None)
if kw: if kw:
self._logger.info('Extra parameters provided: %r', kw) self._logger.info('Extra parameters provided: %r', kw)
status_dict.update(kw) status_dict.update(kw)
self._retryRPC('stopUnitTest', (self._test_result_line_path, self._retryRPC('stopUnitTest', (self._test_result_line_path,
status_dict)) binarize_args(status_dict)))
class TestResultProxy(RPCRetry): class TestResultProxy(RPCRetry):
""" """
...@@ -244,7 +242,7 @@ class TestResultProxy(RPCRetry): ...@@ -244,7 +242,7 @@ class TestResultProxy(RPCRetry):
do. do.
""" """
result = self._retryRPC('startUnitTest', (self._test_result_path, result = self._retryRPC('startUnitTest', (self._test_result_path,
exclude_list)) binarize_args(exclude_list)))
if result: if result:
line_url, test_name = result line_url, test_name = result
result = TestResultLineProxy(self._proxy, self._retry_time, result = TestResultLineProxy(self._proxy, self._retry_time,
...@@ -267,7 +265,7 @@ class TestResultProxy(RPCRetry): ...@@ -267,7 +265,7 @@ class TestResultProxy(RPCRetry):
if stderr is not None: if stderr is not None:
status_dict['stderr'] = stderr status_dict['stderr'] = stderr
self._retryRPC('reportTaskFailure', args=(self._test_result_path, self._retryRPC('reportTaskFailure', args=(self._test_result_path,
status_dict, self._node_title)) binarize_args(status_dict), self._node_title))
def reportStatus(self, command, stdout, stderr): def reportStatus(self, command, stdout, stderr):
""" """
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment