eric6/WebBrowser/VirusTotal/VirusTotalApi.py

changeset 8260
2161475d9639
parent 8218
7c09585bd960
child 8560
532068b0edb4
equal deleted inserted replaced
8259:2bbec88047dd 8260:2161475d9639
77 77
78 def __loadSettings(self): 78 def __loadSettings(self):
79 """ 79 """
80 Private method to load the settings. 80 Private method to load the settings.
81 """ 81 """
82 if Preferences.getWebBrowser("VirusTotalSecure"): 82 protocol = (
83 protocol = "https" 83 "https"
84 else: 84 if Preferences.getWebBrowser("VirusTotalSecure") else
85 protocol = "http" 85 "http"
86 )
86 self.GetFileReportUrl = self.GetFileReportPattern.format(protocol) 87 self.GetFileReportUrl = self.GetFileReportPattern.format(protocol)
87 self.ScanUrlUrl = self.ScanUrlPattern.format(protocol) 88 self.ScanUrlUrl = self.ScanUrlPattern.format(protocol)
88 self.GetUrlReportUrl = self.GetUrlReportPattern.format(protocol) 89 self.GetUrlReportUrl = self.GetUrlReportPattern.format(protocol)
89 self.GetIpAddressReportUrl = self.GetIpAddressReportPattern.format( 90 self.GetIpAddressReportUrl = self.GetIpAddressReportPattern.format(
90 protocol) 91 protocol)
107 Public method to check the validity of the given service key. 108 Public method to check the validity of the given service key.
108 109
109 @param key service key (string) 110 @param key service key (string)
110 @param protocol protocol used to access VirusTotal (string) 111 @param protocol protocol used to access VirusTotal (string)
111 """ 112 """
112 if protocol == "": 113 urlStr = (
113 urlStr = self.GetFileReportUrl 114 self.GetFileReportUrl
114 else: 115 if protocol == "" else
115 urlStr = self.GetFileReportPattern.format(protocol) 116 self.GetFileReportPattern.format(protocol)
117 )
116 request = QNetworkRequest(QUrl(urlStr)) 118 request = QNetworkRequest(QUrl(urlStr))
117 request.setHeader(QNetworkRequest.KnownHeaders.ContentTypeHeader, 119 request.setHeader(QNetworkRequest.KnownHeaders.ContentTypeHeader,
118 "application/x-www-form-urlencoded") 120 "application/x-www-form-urlencoded")
119 params = QByteArray("apikey={0}&resource={1}".format( 121 params = QByteArray("apikey={0}&resource={1}".format(
120 key, self.TestServiceKeyScanID).encode("utf-8")) 122 key, self.TestServiceKeyScanID).encode("utf-8"))

eric ide

mercurial