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( |