WebBrowser/VirusTotal/VirusTotalApi.py

changeset 6121
d3d64f3128b3
parent 6048
82ad8ec9548c
child 6645
ad476851d7e0
equal deleted inserted replaced
6120:4c60a21ce6dd 6121:d3d64f3128b3
125 125
126 import WebBrowser.WebBrowserWindow 126 import WebBrowser.WebBrowserWindow
127 nam = WebBrowser.WebBrowserWindow.WebBrowserWindow\ 127 nam = WebBrowser.WebBrowserWindow.WebBrowserWindow\
128 .networkManager() 128 .networkManager()
129 reply = nam.post(request, params) 129 reply = nam.post(request, params)
130 reply.finished.connect(self.__checkServiceKeyValidityFinished) 130 reply.finished.connect(
131 self.__replies.append(reply) 131 lambda: self.__checkServiceKeyValidityFinished(reply))
132 132 self.__replies.append(reply)
133 def __checkServiceKeyValidityFinished(self): 133
134 def __checkServiceKeyValidityFinished(self, reply):
134 """ 135 """
135 Private slot to determine the result of the service key validity check. 136 Private slot to determine the result of the service key validity check.
137
138 @param reply reference to the network reply
139 @type QNetworkReply
136 """ 140 """
137 res = False 141 res = False
138 msg = "" 142 msg = ""
139 143
140 reply = self.sender()
141 if reply.error() == QNetworkReply.NoError: 144 if reply.error() == QNetworkReply.NoError:
142 res = True 145 res = True
143 elif reply.error() == self.ServiceCode_InvalidKey: 146 elif reply.error() == self.ServiceCode_InvalidKey:
144 res = False 147 res = False
145 else: 148 else:
167 .networkManager() 170 .networkManager()
168 reply = nam.post(request, params) 171 reply = nam.post(request, params)
169 reply.finished.connect(self.__submitUrlFinished) 172 reply.finished.connect(self.__submitUrlFinished)
170 self.__replies.append(reply) 173 self.__replies.append(reply)
171 174
172 def __submitUrlFinished(self): 175 def __submitUrlFinished(self, reply):
173 """ 176 """
174 Private slot to determine the result of the URL scan submission. 177 Private slot to determine the result of the URL scan submission.
175 """ 178
176 reply = self.sender() 179 @param reply reference to the network reply
180 @type QNetworkReply
181 """
177 if reply.error() == QNetworkReply.NoError: 182 if reply.error() == QNetworkReply.NoError:
178 result = json.loads(str(reply.readAll(), "utf-8")) 183 result = json.loads(str(reply.readAll(), "utf-8"))
179 if result["response_code"] == self.ServiceResult_ItemPresent: 184 if result["response_code"] == self.ServiceResult_ItemPresent:
180 self.urlScanReport.emit(result["permalink"]) 185 self.urlScanReport.emit(result["permalink"])
181 self.__getUrlScanReportUrl(result["scan_id"]) 186 self.__getUrlScanReportUrl(result["scan_id"])
211 .networkManager() 216 .networkManager()
212 reply = nam.post(request, params) 217 reply = nam.post(request, params)
213 reply.finished.connect(self.__getUrlScanReportUrlFinished) 218 reply.finished.connect(self.__getUrlScanReportUrlFinished)
214 self.__replies.append(reply) 219 self.__replies.append(reply)
215 220
216 def __getUrlScanReportUrlFinished(self): 221 def __getUrlScanReportUrlFinished(self, reply):
217 """ 222 """
218 Private slot to determine the result of the URL scan report URL 223 Private slot to determine the result of the URL scan report URL.
224
225 @param reply reference to the network reply
226 @type QNetworkReply
219 request. 227 request.
220 """ 228 """
221 reply = self.sender()
222 if reply.error() == QNetworkReply.NoError: 229 if reply.error() == QNetworkReply.NoError:
223 result = json.loads(str(reply.readAll(), "utf-8")) 230 result = json.loads(str(reply.readAll(), "utf-8"))
224 if "filescan_id" in result and result["filescan_id"] is not None: 231 if "filescan_id" in result and result["filescan_id"] is not None:
225 self.__getFileScanReportUrl(result["filescan_id"]) 232 self.__getFileScanReportUrl(result["filescan_id"])
226 self.__replies.remove(reply) 233 self.__replies.remove(reply)
244 .networkManager() 251 .networkManager()
245 reply = nam.post(request, params) 252 reply = nam.post(request, params)
246 reply.finished.connect(self.__getFileScanReportUrlFinished) 253 reply.finished.connect(self.__getFileScanReportUrlFinished)
247 self.__replies.append(reply) 254 self.__replies.append(reply)
248 255
249 def __getFileScanReportUrlFinished(self): 256 def __getFileScanReportUrlFinished(self, reply):
250 """ 257 """
251 Private slot to determine the result of the file scan report URL 258 Private slot to determine the result of the file scan report URL
252 request. 259 request.
253 """ 260
254 reply = self.sender() 261 @param reply reference to the network reply
262 @type QNetworkReply
263 """
255 if reply.error() == QNetworkReply.NoError: 264 if reply.error() == QNetworkReply.NoError:
256 result = json.loads(str(reply.readAll(), "utf-8")) 265 result = json.loads(str(reply.readAll(), "utf-8"))
257 self.fileScanReport.emit(result["permalink"]) 266 self.fileScanReport.emit(result["permalink"])
258 self.__replies.remove(reply) 267 self.__replies.remove(reply)
259 reply.deleteLater() 268 reply.deleteLater()
282 .networkManager() 291 .networkManager()
283 reply = nam.get(request) 292 reply = nam.get(request)
284 reply.finished.connect(self.__getIpAddressReportFinished) 293 reply.finished.connect(self.__getIpAddressReportFinished)
285 self.__replies.append(reply) 294 self.__replies.append(reply)
286 295
287 def __getIpAddressReportFinished(self): 296 def __getIpAddressReportFinished(self, reply):
288 """ 297 """
289 Private slot to process the IP address report data. 298 Private slot to process the IP address report data.
290 """ 299
291 reply = self.sender() 300 @param reply reference to the network reply
301 @type QNetworkReply
302 """
292 if reply.error() == QNetworkReply.NoError: 303 if reply.error() == QNetworkReply.NoError:
293 result = json.loads(str(reply.readAll(), "utf-8")) 304 result = json.loads(str(reply.readAll(), "utf-8"))
294 if result["response_code"] == 0: 305 if result["response_code"] == 0:
295 E5MessageBox.information( 306 E5MessageBox.information(
296 None, 307 None,
338 349
339 import WebBrowser.WebBrowserWindow 350 import WebBrowser.WebBrowserWindow
340 nam = WebBrowser.WebBrowserWindow.WebBrowserWindow\ 351 nam = WebBrowser.WebBrowserWindow.WebBrowserWindow\
341 .networkManager() 352 .networkManager()
342 reply = nam.get(request) 353 reply = nam.get(request)
343 reply.finished.connect(self.__getDomainReportFinished) 354 reply.finished.connect(lambda: self.__getDomainReportFinished(reply))
344 self.__replies.append(reply) 355 self.__replies.append(reply)
345 356
346 def __getDomainReportFinished(self): 357 def __getDomainReportFinished(self, reply):
347 """ 358 """
348 Private slot to process the IP address report data. 359 Private slot to process the IP address report data.
349 """ 360
350 reply = self.sender() 361 @param reply reference to the network reply
362 @type QNetworkReply
363 """
351 if reply.error() == QNetworkReply.NoError: 364 if reply.error() == QNetworkReply.NoError:
352 result = json.loads(str(reply.readAll(), "utf-8")) 365 result = json.loads(str(reply.readAll(), "utf-8"))
353 if result["response_code"] == 0: 366 if result["response_code"] == 0:
354 E5MessageBox.information( 367 E5MessageBox.information(
355 None, 368 None,

eric ide

mercurial