33 @param host ip address the background service is listening |
32 @param host ip address the background service is listening |
34 @type str |
33 @type str |
35 @param port port of the background service |
34 @param port port of the background service |
36 @type int |
35 @type int |
37 """ |
36 """ |
|
37 self.__exitClient = False |
38 self.__connection = socket.create_connection((host, port)) |
38 self.__connection = socket.create_connection((host, port)) |
39 |
39 |
40 def sendJson(self, command, params): |
40 def sendJson(self, command, params): |
41 """ |
41 """ |
42 Public method to send a single refactoring command to the server. |
42 Public method to send a single refactoring command to the server. |
79 }) |
79 }) |
80 return |
80 return |
81 |
81 |
82 method = commandDict["method"] |
82 method = commandDict["method"] |
83 params = commandDict["params"] |
83 params = commandDict["params"] |
84 self.handleCall(method, params) |
84 |
|
85 if method == "Exit": |
|
86 self.__exitClient = True |
|
87 else: |
|
88 self.handleCall(method, params) |
85 |
89 |
86 def handleCall(self, method, params): |
90 def handleCall(self, method, params): |
87 """ |
91 """ |
88 Public method to handle a method call from the server. |
92 Public method to handle a method call from the server. |
89 |
93 |
110 # just carry on |
114 # just carry on |
111 continue |
115 continue |
112 |
116 |
113 if self.__connection in rrdy: |
117 if self.__connection in rrdy: |
114 self.__receiveJson() |
118 self.__receiveJson() |
|
119 |
|
120 if self.__exitClient: |
|
121 break |
115 |
122 |
116 except Exception: |
123 except Exception: |
117 exctype, excval, exctb = sys.exc_info() |
124 exctype, excval, exctb = sys.exc_info() |
118 tbinfofile = io.StringIO() |
125 tbinfofile = io.StringIO() |
119 traceback.print_tb(exctb, None, tbinfofile) |
126 traceback.print_tb(exctb, None, tbinfofile) |