18 from eric7 import Globals, Preferences |
18 from eric7 import Globals, Preferences |
19 from eric7.EricNetwork.EricJsonServer import EricJsonServer |
19 from eric7.EricNetwork.EricJsonServer import EricJsonServer |
20 from eric7.EricWidgets.EricApplication import ericApp |
20 from eric7.EricWidgets.EricApplication import ericApp |
21 from eric7.EricWidgets import EricMessageBox |
21 from eric7.EricWidgets import EricMessageBox |
22 from eric7.QScintilla.Editor import Editor |
22 from eric7.QScintilla.Editor import Editor |
|
23 |
|
24 try: |
|
25 from eric7.SystemUtilities.PythonUtilities import ( |
|
26 getPythonLibraryDirectory, |
|
27 getPythonExecutable, |
|
28 ) |
|
29 except ImportError: |
|
30 # imports for eric < 23.1 |
|
31 from eric7.Globals import getPythonExecutable, getPythonLibraryDirectory |
23 |
32 |
24 |
33 |
25 class CodeAssistServer(EricJsonServer): |
34 class CodeAssistServer(EricJsonServer): |
26 """ |
35 """ |
27 Class implementing the autocompletion interface to rope. |
36 Class implementing the autocompletion interface to rope. |
700 |
709 |
701 client = os.path.join(os.path.dirname(__file__), "CodeAssistClient.py") |
710 client = os.path.join(os.path.dirname(__file__), "CodeAssistClient.py") |
702 ok, exitCode = self.startClient( |
711 ok, exitCode = self.startClient( |
703 interpreter, |
712 interpreter, |
704 client, |
713 client, |
705 clientArgs=[configDir, Globals.getPythonLibraryDirectory()], |
714 clientArgs=[configDir, getPythonLibraryDirectory()], |
706 idString=idString, |
715 idString=idString, |
707 environment=clientEnv, |
716 environment=clientEnv, |
708 ) |
717 ) |
709 if not ok: |
718 if not ok: |
710 if exitCode == 42: |
719 if exitCode == 42: |
806 else: |
815 else: |
807 venvName = "" |
816 venvName = "" |
808 if venvName: |
817 if venvName: |
809 interpreter = venvManager.getVirtualenvInterpreter(venvName) |
818 interpreter = venvManager.getVirtualenvInterpreter(venvName) |
810 if not interpreter: |
819 if not interpreter: |
811 interpreter = Globals.getPythonExecutable() |
820 interpreter = getPythonExecutable() |
812 execPath = venvManager.getVirtualenvExecPath(venvName) |
821 execPath = venvManager.getVirtualenvExecPath(venvName) |
813 |
822 |
814 # build a suitable environment |
823 # build a suitable environment |
815 if execPath: |
824 if execPath: |
816 if "PATH" in clientEnv: |
825 if "PATH" in clientEnv: |