RefactoringRope/JsonServer.py

branch
server_client_variant
changeset 166
6fc202183b3b
parent 163
6a9e7b37a18b
child 168
53d76b4fc1ac
equal deleted inserted replaced
165:ea41742015af 166:6fc202183b3b
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, QThread
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
68 68
69 self.__connection = connection 69 self.__connection = connection
70 connection.readyRead.connect(self.__receiveJson) 70 connection.readyRead.connect(self.__receiveJson)
71 connection.disconnected.connect(self.__handleDisconnect) 71 connection.disconnected.connect(self.__handleDisconnect)
72 72
73 self.sendJson("ping", {}) 73 self.sendJson("GetConfig", {})
74 74
75 @pyqtSlot() 75 @pyqtSlot()
76 def __handleDisconnect(self): 76 def __handleDisconnect(self):
77 """ 77 """
78 Private slot handling a disconnect of the refactoring client. 78 Private slot handling a disconnect of the refactoring client.
89 """ 89 """
90 while self.__connection and self.__connection.canReadLine(): 90 while self.__connection and self.__connection.canReadLine():
91 data = self.__connection.readLine() 91 data = self.__connection.readLine()
92 jsonLine = bytes(data).decode("utf-8", 'backslashreplace') 92 jsonLine = bytes(data).decode("utf-8", 'backslashreplace')
93 93
94 print("JSON Server: ", jsonLine) ##debug 94 ## print("JSON Server: ", jsonLine) ##debug
95 95
96 try: 96 try:
97 clientDict = json.loads(jsonLine.strip()) 97 clientDict = json.loads(jsonLine.strip())
98 except (TypeError, ValueError) as err: 98 except (TypeError, ValueError) as err:
99 E5MessageBox.critical( 99 E5MessageBox.critical(
181 181
182 def stopClient(self): 182 def stopClient(self):
183 """ 183 """
184 Public method to stop the client process. 184 Public method to stop the client process.
185 """ 185 """
186 self.sendJson("Exit", {})
187
188 QThread.msleep(200)
189
186 self.__clientProcess.close() 190 self.__clientProcess.close()
187 self.__clientProcess = None 191 self.__clientProcess = None
188 192
189 # 193 #
190 # eflag: noqa = M801 194 # eflag: noqa = M801

eric ide

mercurial