RefactoringRope/JsonServer.py

changeset 285
247d62c682dc
parent 265
68152c23837a
child 293
dd1c7ed6d880
equal deleted inserted replaced
284:18f32c079abc 285:247d62c682dc
9 9
10 from __future__ import unicode_literals 10 from __future__ import unicode_literals
11 11
12 import json 12 import json
13 13
14 from PyQt5.QtCore import pyqtSlot, QProcess 14 from PyQt5.QtCore import pyqtSlot, QProcess, QProcessEnvironment
15 from PyQt5.QtNetwork import QTcpServer, QHostAddress 15 from PyQt5.QtNetwork import QTcpServer, QHostAddress
16 16
17 from E5Gui import E5MessageBox 17 from E5Gui import E5MessageBox
18 18
19 import Preferences 19 import Preferences
202 length = "{0:09d}".format(len(data)) 202 length = "{0:09d}".format(len(data))
203 connection.write(length.encode() + data) 203 connection.write(length.encode() + data)
204 if flush: 204 if flush:
205 connection.flush() 205 connection.flush()
206 206
207 def startClient(self, interpreter, clientScript, clientArgs, idString=""): 207 def startClient(self, interpreter, clientScript, clientArgs, idString="",
208 environment=None):
208 """ 209 """
209 Public method to start a client process. 210 Public method to start a client process.
210 211
211 @param interpreter interpreter to be used for the client 212 @param interpreter interpreter to be used for the client
212 @type str 213 @type str
213 @param clientScript path to the client script 214 @param clientScript path to the client script
214 @type str 215 @type str
215 @param clientArgs list of arguments for the client 216 @param clientArgs list of arguments for the client
216 @param idString id of the client to be started 217 @param idString id of the client to be started
217 @type str 218 @type str
219 @param environment dictionary of environment settings to pass
220 @type dict
218 @return flag indicating a successful client start 221 @return flag indicating a successful client start
219 @rtype bool 222 @rtype bool
220 """ 223 """
221 if interpreter == "" or not Utilities.isinpath(interpreter): 224 if interpreter == "" or not Utilities.isinpath(interpreter):
222 return False 225 return False
223 226
224 proc = QProcess() 227 proc = QProcess()
225 proc.setProcessChannelMode(QProcess.ForwardedChannels) 228 proc.setProcessChannelMode(QProcess.ForwardedChannels)
229 if environment is not None:
230 env = QProcessEnvironment()
231 for key, value in list(environment.items()):
232 env.insert(key, value)
233 proc.setProcessEnvironment(env)
226 args = [clientScript, self.__hostAddress, str(self.serverPort())] 234 args = [clientScript, self.__hostAddress, str(self.serverPort())]
227 if idString: 235 if idString:
228 args.append(idString) 236 args.append(idString)
229 args.extend(clientArgs) 237 args.extend(clientArgs)
230 proc.start(interpreter, args) 238 proc.start(interpreter, args)

eric ide

mercurial