Thu, 14 Sep 2017 19:39:11 +0200
Coded a distributed progress dialog.
# -*- coding: utf-8 -*- # Copyright (c) 2017 Detlev Offenbach <detlev@die-offenbachs.de> # """ Module implementing the refactoring client interface to rope. """ from __future__ import unicode_literals import sys import os sys.path.insert(0, os.path.dirname(__file__)) if sys.version_info[0] >= 3: path = os.path.join(os.path.dirname(__file__), 'rope_py3') else: path = os.path.join(os.path.dirname(__file__), 'rope_py2') sys.path.insert(0, path) import rope.base.project from JsonClient import JsonClient class RefactoringClient(JsonClient): """ Class implementing the refactoring client interface to rope. """ def __init__(self, host, port, projectPath): """ Constructor @param host ip address the background service is listening @type str @param port port of the background service @type int @param projectPath path to the project @type str """ super(RefactoringClient, self).__init__(host, port) from FileSystemCommands import RefactoringClientFileSystemCommands self.__fsCommands = RefactoringClientFileSystemCommands(self) self.__projectpath = projectPath self.__project = rope.base.project.Project( self.__projectpath, fscommands=self.__fsCommands) self.__progressHandle = None def handleCall(self, method, params): """ Public method to handle a method call from the server. @param method requested method name @type str @param params dictionary with method specific parameters @type dict """ ## if "filename" in params and sys.version_info[0] == 2: ## params["filename"] = params["filename"].encode( ## sys.getfilesystemencoding()) if method == "AbortAction": if self.__progressHandle is not None and \ not self.__progressHandle.is_stopped(): self.__progressHandle.stop() elif method == "ping": self.sendJson("pong", {}) if __name__ == '__main__': if len(sys.argv) != 4: print('Host, port and project path parameters are missing. Abort.') sys.exit(1) host, port, projectPath = sys.argv[1:] client = RefactoringClient(host, int(port), projectPath) # Start the main loop client.run() # # eflag: noqa = M801