RefactoringRope/RefactoringClient.py

changeset 360
2b35968f3d02
parent 354
a967ff16629a
child 362
792c2651fbd7
--- a/RefactoringRope/RefactoringClient.py	Sun May 09 14:30:51 2021 +0200
+++ b/RefactoringRope/RefactoringClient.py	Mon May 10 20:13:48 2021 +0200
@@ -11,17 +11,14 @@
 import os
 import contextlib
 
-sys.path.insert(0, os.path.dirname(__file__))
-
-import rope
-import rope.base.project
-import rope.base.libutils
-
-from JsonClient import JsonClient
-from ProgressHandle import ProgressHandle
+try:
+    from E5Network.E5JsonClient import E5JsonClient
+except ImportError:
+    # TODO: delete JsonClient once ported to eric7
+    from JsonClient import JsonClient as E5JsonClient
 
 
-class RefactoringClient(JsonClient):
+class RefactoringClient(E5JsonClient):
     """
     Class implementing the refactoring client interface to rope.
     """
@@ -1495,21 +1492,27 @@
 
 
 if __name__ == '__main__':
-    if len(sys.argv) != 4:
-        print('Host, port and project path parameters are missing. Abort.')
+    if len(sys.argv) != 5:
+        print('Host, port, project path and module path parameters are'
+              ' missing. Abort.')
         sys.exit(1)
     
-    host, port, projectPath = sys.argv[1:]
+    host, port, projectPath, modulePath = sys.argv[1:]
     
-    # Create a Qt4/5 application object in order to allow the processing of
+    sys.path.insert(1, modulePath)
+    try:
+        import rope.base.project
+        import rope.base.libutils
+        from ProgressHandle import ProgressHandle
+    except ImportError:
+        sys.exit(42)
+    
+    # Create a Qt5 application object in order to allow the processing of
     # modules containing Qt stuff.
     try:
         from PyQt5.QtCore import QCoreApplication
     except ImportError:
-        try:
-            from PyQt4.QtCore import QCoreApplication
-        except ImportError:
-            QCoreApplication = None
+        QCoreApplication = None
     if QCoreApplication is not None:
         app = QCoreApplication(sys.argv)
     

eric ide

mercurial