Commit 4bcde299 authored by Julien Muchembled's avatar Julien Muchembled Committed by Klaus Wölfel

taskdistribution: style

parent 2dc1a764
...@@ -39,9 +39,8 @@ Example use: ...@@ -39,9 +39,8 @@ Example use:
# Run the test_line.name test # Run the test_line.name test
test_line.stop() test_line.stop()
""" """
from __future__ import print_function
import httplib import httplib
import logging
import select
import socket import socket
import threading import threading
import time import time
...@@ -57,8 +56,8 @@ if xmlrpclib.ExpatParser and isinstance(parser, xmlrpclib.ExpatParser): ...@@ -57,8 +56,8 @@ if xmlrpclib.ExpatParser and isinstance(parser, xmlrpclib.ExpatParser):
SAFE_RPC_EXCEPTION_LIST.append(xmlrpclib.expat.ExpatError) SAFE_RPC_EXCEPTION_LIST.append(xmlrpclib.expat.ExpatError)
else: else:
import sys import sys
print >> sys.stderr, 'Warning: unhandled xmlrpclib parser %r, some ' \ print('Warning: unhandled xmlrpclib parser %r, some exceptions might get'
'exceptions might get through safeRpcCall' % (parser, ) ' through safeRpcCall' % parser, file=sys.stderr)
del sys del sys
SAFE_RPC_EXCEPTION_LIST = tuple(SAFE_RPC_EXCEPTION_LIST) SAFE_RPC_EXCEPTION_LIST = tuple(SAFE_RPC_EXCEPTION_LIST)
del parser, _ del parser, _
...@@ -110,7 +109,6 @@ def binarize_args(arg): ...@@ -110,7 +109,6 @@ def binarize_args(arg):
class RPCRetry(object): class RPCRetry(object):
def __init__(self, proxy, retry_time, logger): def __init__(self, proxy, retry_time, logger):
super(RPCRetry, self).__init__()
self._proxy = proxy self._proxy = proxy
self._retry_time = retry_time self._retry_time = retry_time
self._logger = logger self._logger = logger
...@@ -159,7 +157,8 @@ class TestResultLineProxy(RPCRetry): ...@@ -159,7 +157,8 @@ class TestResultLineProxy(RPCRetry):
Tell if test result line is still alive on site. Tell if test result line is still alive on site.
""" """
try: try:
return bool(self._retryRPC('isTestCaseAlive', [self._test_result_line_path])) return bool(self._retryRPC('isTestCaseAlive',
(self._test_result_line_path,)))
except: except:
raise ValueError('isTestCaseAlive Failed.') raise ValueError('isTestCaseAlive Failed.')
...@@ -222,6 +221,7 @@ class TestResultProxy(RPCRetry): ...@@ -222,6 +221,7 @@ class TestResultProxy(RPCRetry):
self._watcher_period = 60 self._watcher_period = 60
self._watcher_dict = {} self._watcher_dict = {}
self._watcher_condition = threading.Condition() self._watcher_condition = threading.Condition()
def __repr__(self): def __repr__(self):
return '<%s(%r, %r, %r) at %x>' % (self.__class__.__name__, return '<%s(%r, %r, %r) at %x>' % (self.__class__.__name__,
self._test_result_path, self._node_title, self._revision, id(self)) self._test_result_path, self._node_title, self._revision, id(self))
...@@ -381,7 +381,6 @@ class TestResultProxy(RPCRetry): ...@@ -381,7 +381,6 @@ class TestResultProxy(RPCRetry):
def stop(self): def stop(self):
""" """
""" """
return self._retryRPC('stopTest', [self._test_result_path]) return self._retryRPC('stopTest', [self._test_result_path])
...@@ -409,41 +408,37 @@ class ServerProxy(xmlrpclib.ServerProxy): ...@@ -409,41 +408,37 @@ class ServerProxy(xmlrpclib.ServerProxy):
class TaskDistributor(RPCRetry): class TaskDistributor(RPCRetry):
def __init__(self,portal_url,retry_time=64,logger=None): def __init__(self, portal_url, retry_time=64, logger=None):
if logger is None: if logger is None:
logger = null_logger logger = null_logger
if portal_url is None: if portal_url is None:
proxy = DummyTaskDistributor() proxy = DummyTaskDistributor()
else: else:
proxy = ServerProxy(portal_url, allow_none=True) proxy = ServerProxy(portal_url, allow_none=True)
super(TaskDistributor, self).__init__(proxy, retry_time,logger) super(TaskDistributor, self).__init__(proxy, retry_time, logger)
protocol_revision = self._retryRPC('getProtocolRevision') protocol_revision = self._retryRPC('getProtocolRevision')
if protocol_revision != 1: if protocol_revision != 1:
raise ValueError('Unsupported protocol revision: %r', raise ValueError('Unsupported protocol revision: %r',
protocol_revision) protocol_revision)
def startTestSuite(self,node_title,computer_guid='unknown'): def startTestSuite(self, node_title, computer_guid='unknown'):
""" """
Returns None if no test suite is needed. Returns None if no test suite is needed.
therwise, returns a JSON with all the test suite parameters. therwise, returns a JSON with all the test suite parameters.
""" """
result = self._retryRPC('startTestSuite',(node_title,computer_guid,)) return self._retryRPC('startTestSuite', (node_title, computer_guid))
return result
def getTestType(self): def getTestType(self):
""" """
Return the Test Type Return the Test Type
""" """
result = self._retryRPC('getTestType') return self._retryRPC('getTestType')
return result
def subscribeNode(self, node_title, computer_guid): def subscribeNode(self, node_title, computer_guid):
""" """
Susbscribes node with the node title and the computer guid. Susbscribes node with the node title and the computer guid.
""" """
result = self._retryRPC('subscribeNode', (node_title,computer_guid,)) return self._retryRPC('subscribeNode', (node_title, computer_guid))
return result
def generateConfiguration(self, test_suite_title): def generateConfiguration(self, test_suite_title):
""" """
......
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