18 |
18 |
19 from PyQt6.QtCore import QProcess, QThread, QTimer, pyqtSignal |
19 from PyQt6.QtCore import QProcess, QThread, QTimer, pyqtSignal |
20 from PyQt6.QtNetwork import QHostAddress, QTcpServer |
20 from PyQt6.QtNetwork import QHostAddress, QTcpServer |
21 from PyQt6.QtWidgets import QApplication |
21 from PyQt6.QtWidgets import QApplication |
22 |
22 |
23 from eric7 import Globals, Preferences, Utilities |
23 from eric7 import Preferences |
24 from eric7.EricWidgets import EricMessageBox |
24 from eric7.EricWidgets import EricMessageBox |
25 from eric7.EricWidgets.EricApplication import ericApp |
25 from eric7.EricWidgets.EricApplication import ericApp |
|
26 from eric7.SystemUtilities import FileSystemUtilities, PythonUtilities |
26 |
27 |
27 |
28 |
28 class BackgroundService(QTcpServer): |
29 class BackgroundService(QTcpServer): |
29 """ |
30 """ |
30 Class implementing the main part of the background service. |
31 Class implementing the main part of the background service. |
95 venvName = Preferences.getDebugger("Python3VirtualEnv") |
96 venvName = Preferences.getDebugger("Python3VirtualEnv") |
96 interpreter = ( |
97 interpreter = ( |
97 ericApp().getObject("VirtualEnvManager").getVirtualenvInterpreter(venvName) |
98 ericApp().getObject("VirtualEnvManager").getVirtualenvInterpreter(venvName) |
98 ) |
99 ) |
99 if not interpreter: |
100 if not interpreter: |
100 interpreter = Globals.getPythonExecutable() |
101 interpreter = PythonUtilities.getPythonExecutable() |
101 return interpreter |
102 return interpreter |
102 |
103 |
103 def __startExternalClient(self, interpreter, port): |
104 def __startExternalClient(self, interpreter, port): |
104 """ |
105 """ |
105 Private method to start the background client as external process. |
106 Private method to start the background client as external process. |
109 @param port socket port to which the interpreter should connect |
110 @param port socket port to which the interpreter should connect |
110 @type int |
111 @type int |
111 @return the process object |
112 @return the process object |
112 @rtype QProcess or None |
113 @rtype QProcess or None |
113 """ |
114 """ |
114 if interpreter == "" or not Utilities.isinpath(interpreter): |
115 if interpreter == "" or not FileSystemUtilities.isinpath(interpreter): |
115 return None |
116 return None |
116 |
117 |
117 backgroundClient = os.path.join( |
118 backgroundClient = os.path.join( |
118 os.path.dirname(__file__), "BackgroundClient.py" |
119 os.path.dirname(__file__), "BackgroundClient.py" |
119 ) |
120 ) |
122 args = [ |
123 args = [ |
123 backgroundClient, |
124 backgroundClient, |
124 self.__hostAddress, |
125 self.__hostAddress, |
125 str(port), |
126 str(port), |
126 str(Preferences.getUI("BackgroundServiceProcesses")), |
127 str(Preferences.getUI("BackgroundServiceProcesses")), |
127 Globals.getPythonLibraryDirectory(), |
128 PythonUtilities.getPythonLibraryDirectory(), |
128 ] |
129 ] |
129 proc.start(interpreter, args) |
130 proc.start(interpreter, args) |
130 if not proc.waitForStarted(10000): |
131 if not proc.waitForStarted(10000): |
131 proc = None |
132 proc = None |
132 return proc |
133 return proc |