diff -r 9986ec0e559a -r 10516539f238 Helpviewer/VirusTotalApi.py --- a/Helpviewer/VirusTotalApi.py Tue Oct 15 22:03:54 2013 +0200 +++ b/Helpviewer/VirusTotalApi.py Fri Oct 18 23:00:41 2013 +0200 @@ -4,7 +4,8 @@ # """ -Module implementing the <a href="http://www.virustotal.com">VirusTotal</a> API class. +Module implementing the <a href="http://www.virustotal.com">VirusTotal</a> +API class. """ from __future__ import unicode_literals # __IGNORE_WARNING__ @@ -16,22 +17,25 @@ import json from PyQt4.QtCore import QObject, QUrl, QByteArray, pyqtSignal -from PyQt4.QtNetwork import QNetworkRequest, QNetworkReply, QNetworkAccessManager +from PyQt4.QtNetwork import QNetworkRequest, QNetworkReply, \ + QNetworkAccessManager import Preferences class VirusTotalAPI(QObject): """ - Class implementing the <a href="http://www.virustotal.com">VirusTotal</a> API. + Class implementing the <a href="http://www.virustotal.com">VirusTotal</a> + API. - @signal checkServiceKeyFinished(bool, str) emitted after the service key check - has been performed. It gives a flag indicating validity (boolean) and - an error message in case of a network error (string). + @signal checkServiceKeyFinished(bool, str) emitted after the service key + check has been performed. It gives a flag indicating validity + (boolean) and an error message in case of a network error (string). @signal submitUrlError(str) emitted with the error string, if the URL scan - submission returned an error. + submission returned an error. @signal urlScanReport(str) emitted with the URL of the URL scan report page - @signal fileScanReport(str) emitted with the URL of the file scan report page + @signal fileScanReport(str) emitted with the URL of the file scan report + page """ checkServiceKeyFinished = pyqtSignal(bool, str) submitUrlError = pyqtSignal(str) @@ -50,8 +54,10 @@ ScanUrlPattern = "{0}://www.virustotal.com/api/scan_url.json" GetUrlReportPattern = "{0}://www.virustotal.com/api/get_url_report.json" - ReportUrlScanPagePattern = "http://www.virustotal.com/url-scan/report.html?id={0}" - ReportFileScanPagePattern = "http://www.virustotal.com/file-scan/report.html?id={0}" + ReportUrlScanPagePattern = \ + "http://www.virustotal.com/url-scan/report.html?id={0}" + ReportFileScanPagePattern = \ + "http://www.virustotal.com/file-scan/report.html?id={0}" SearchUrl = "http://www.virustotal.com/search.html" @@ -97,8 +103,6 @@ @param key service key (string) @param protocol protocol used to access VirusTotal (string) - @return flag indicating validity (boolean) and an error message in - case of a network error (string) """ if protocol == "": urlStr = self.GetFileReportUrl @@ -139,13 +143,12 @@ Public method to submit an URL to be scanned. @param url url to be scanned (QUrl) - @return flag indicating success (boolean) and the scan ID (string) """ request = QNetworkRequest(QUrl(self.ScanUrlUrl)) request.setHeader(QNetworkRequest.ContentTypeHeader, "application/x-www-form-urlencoded") - params = QByteArray( - "key={0}&url=".format(Preferences.getHelp("VirusTotalServiceKey")))\ + params = QByteArray("key={0}&url=".format( + Preferences.getHelp("VirusTotalServiceKey")))\ .append(QUrl.toPercentEncoding(url.toString())) import Helpviewer.HelpWindow @@ -176,7 +179,6 @@ Private method to get the report URL for a file scan. @param scanId ID of the scan to get the report URL for (string) - @return file scan report URL (string) """ request = QNetworkRequest(QUrl(self.GetUrlReportUrl)) request.setHeader(QNetworkRequest.ContentTypeHeader, @@ -192,14 +194,16 @@ def __getFileScanReportUrlFinished(self): """ - Private slot to determine the result of the file scan report URL request. + Private slot to determine the result of the file scan report URL + request. """ reply = self.sender() if reply.error() == QNetworkReply.NoError: result = json.loads(str(reply.readAll(), "utf-8")) if "file-report" in result: self.fileScanReport.emit( - self.ReportFileScanPagePattern.format(result["file-report"])) + self.ReportFileScanPagePattern.format( + result["file-report"])) self.__replies.remove(reply) @classmethod