class EditorSupportCall: contexturl = "" config = {} browser = None def __init__(self, view): # Load the connection settings, use the file path of the active view for context whfsroot, username, password, contexturl, config = load_whconn_config(view.file_name()) self.contexturl = contexturl self.config = config print(self.contexturl, self.config) # Construct the RPC url and setup a server proxy for the RPC calls up = urlsplit(whfsroot) adminurl = urlunsplit((up.scheme, username + ":" + password + "@" + up.netloc, "/wh_services/blex_alpha/editorsupport", "", "")) self.browser = ServerProxy(adminurl) def call(self, method, param1 = None, param2 = None): try: # Set (global) socket timeout globally socket.setdefaulttimeout(10) # Call the remote function and return the result if method == "getremoteerrorlist": return self.browser.getRemoteErrorList(self.contexturl, self.config) elif method == "symbolsearch": return self.browser.symbolSearch(param1, self.contexturl, self.config) elif method == "documentationsearch": return self.browser.documentationSearch(param1, self.contexturl, self.config) elif method == "validate": return self.browser.validate(self.contexturl, self.config) elif method == "compile": self.config["force"] = True return self.browser.compile(self.contexturl, self.config) elif method == "validateharescriptsource": return self.browser.validateharescriptsource(self.contexturl, param1, self.config) elif method == "getloadlibsuggestions": return self.browser.rpc_getloadlibsuggestions(self.contexturl, param1, self.config) elif method == "addloadlibtosource": return self.browser.rpc_addloadlibtosource(self.contexturl, param1, param2, self.config) elif method == "resolveuri": return self.browser.rpc_resolveuri(self.contexturl, param1, self.config) except Error as e: # Display a message sublime.status_message("Error retrieving " + method + " result") print("Error", e) return None except IOError as e: # Display a message sublime.status_message("Error connecting to server") print("IOError", e) return None except socket.error as e: # Display a message sublime.status_message("Error connecting to server") print("socket.error", e) return None finally: # Reset (global) socket timeout to default value socket.setdefaulttimeout(None)