eric7/WebBrowser/VirusTotal/VirusTotalIpReportDialog.py

branch
eric7
changeset 8312
800c432b34c8
parent 8218
7c09585bd960
child 8318
962bce857696
equal deleted inserted replaced
8311:4e8b98454baa 8312:800c432b34c8
1 # -*- coding: utf-8 -*-
2
3 # Copyright (c) 2015 - 2021 Detlev Offenbach <detlev@die-offenbachs.de>
4 #
5
6 """
7 Module implementing a dialog to show the VirusTotal IP address report.
8 """
9
10 from PyQt5.QtCore import Qt
11 from PyQt5.QtWidgets import QDialog, QTreeWidgetItem
12
13 from .Ui_VirusTotalIpReportDialog import Ui_VirusTotalIpReportDialog
14
15 import UI.PixmapCache
16
17
18 class VirusTotalIpReportDialog(QDialog, Ui_VirusTotalIpReportDialog):
19 """
20 Class implementing a dialog to show the VirusTotal IP address report.
21 """
22 def __init__(self, ip, owner, resolutions, urls, parent=None):
23 """
24 Constructor
25
26 @param ip IP address
27 @type str
28 @param owner owner of the IP address
29 @type str
30 @param resolutions list of resolved host names
31 @type list of dict
32 @param urls list of detected URLs
33 @type list of dict
34 @param parent reference to the parent widget
35 @type QWidget
36 """
37 super().__init__(parent)
38 self.setupUi(self)
39 self.setWindowFlags(Qt.WindowType.Window)
40
41 self.headerLabel.setText(
42 self.tr("<b>Report for IP {0}</b>").format(ip))
43 self.headerPixmap.setPixmap(
44 UI.PixmapCache.getPixmap("virustotal"))
45 self.ownerLabel.setText(owner)
46
47 for resolution in resolutions:
48 QTreeWidgetItem(
49 self.resolutionsList,
50 [resolution["hostname"],
51 resolution["last_resolved"].split()[0]]
52 )
53 self.resolutionsList.resizeColumnToContents(0)
54 self.resolutionsList.resizeColumnToContents(1)
55 self.resolutionsList.sortByColumn(0, Qt.SortOrder.AscendingOrder)
56
57 if not urls:
58 self.detectedUrlsGroup.setVisible(False)
59 for url in urls:
60 QTreeWidgetItem(
61 self.urlsList,
62 [url["url"],
63 self.tr("{0}/{1}", "positives / total").format(
64 url["positives"], url["total"]),
65 url["scan_date"].split()[0]]
66 )
67 self.urlsList.resizeColumnToContents(0)
68 self.urlsList.resizeColumnToContents(1)
69 self.urlsList.resizeColumnToContents(2)
70 self.urlsList.sortByColumn(0, Qt.SortOrder.AscendingOrder)

eric ide

mercurial