class RemoteLibrary:

    def __init__(self, name, uri):
        self.name = name
        self._uri = uri
        self._open_connection()
        self._keywords = None

    def _open_connection(self):
        self._remote_lib = RobotRemoteLibrary(self._uri)

    def get_keyword_names(self):
        if self._keywords is None:
            self._keywords = list(self._remote_lib.getKeywordNames())
        return self._keywords

    def has_keyword(self, name):
        return name in self._keywords

    def run_keyword(self, name, args):
        try:
            self._remote_lib.ping()
        except RemoteAccessException:
            print "*DEBUG* Reconnecting"
            self._open_connection()
        return self._remote_lib.runKeyword(name, args)
 def _get_jars_from_classpath(self):
     jars = []
     for url in RobotRemoteLibrary.getClassLoader().getResources("org/robotframework/remoteapplications/client/RobotRemoteLibrary.class"):
         if url.getProtocol() == 'jar':
             jars.append(url.openConnection().getJarFileURL().getFile())
     if not jars:
         raise RuntimeError("Could not find any jars from classpath.")
     return jars
 def _open_connection(self):
     self._remote_lib = RobotRemoteLibrary(self._uri)