Skip to content

Commit

Permalink
[robotframework#2937] ability to do remote server reset
Browse files Browse the repository at this point in the history
- remote library instace connection can be resetted
- needs remote library used in own library, no possibility to straight
  call "Reset Connection" kw from robot scripts
  • Loading branch information
juhoarvid committed Aug 21, 2018
1 parent bccc457 commit 04972b0
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/robot/libraries/Remote.py
Expand Up @@ -102,6 +102,9 @@ def run_keyword(self, name, args, kwargs):
result.continuable)
return result.return_

def reset_connection(self, timeout=None):
self._client.reset_connection(timeout=timeout)


class ArgumentCoercer(object):
binary = re.compile('[\x00-\x08\x0B\x0C\x0E-\x1F]')
Expand Down Expand Up @@ -197,13 +200,28 @@ def _convert(self, value):
class XmlRpcRemoteClient(object):

def __init__(self, uri, timeout=None):
self.uri = uri
self.timeout = timeout
self._create_connection(uri, timeout)

def _create_connection(self, uri, timeout):
if uri.startswith('https://'):
transport = TimeoutHTTPSTransport(timeout=timeout)
else:
transport = TimeoutHTTPTransport(timeout=timeout)
self._server = xmlrpclib.ServerProxy(uri, encoding='UTF-8',
transport=transport)

def reset_connection(self, uri=None, timeout=None):
uri = self.uri if uri is None else uri
timeout = self.timeout if timeout is None else timeout
try:
self._server.close()
self._server = None
except:
pass
self._create_connection(uri, timeout)

def get_keyword_names(self):
try:
return self._server.get_keyword_names()
Expand Down

0 comments on commit 04972b0

Please sign in to comment.