src/eric7/MicroPython/WifiDialogs/WifiStatusDialog.py

branch
mpy_network
changeset 9798
4402d76c5fa9
parent 9797
3be7b2326e2c
child 9828
32c8a5b57332
equal deleted inserted replaced
9797:3be7b2326e2c 9798:4402d76c5fa9
17 class WifiStatusDialog(QDialog, Ui_WifiStatusDialog): 17 class WifiStatusDialog(QDialog, Ui_WifiStatusDialog):
18 """ 18 """
19 Class implementing a dialog to show the WiFi status of the connected device. 19 Class implementing a dialog to show the WiFi status of the connected device.
20 """ 20 """
21 21
22 def __init__(self, clientStatus, apStatus, parent=None): 22 def __init__(self, clientStatus, apStatus, overallStatus, parent=None):
23 """ 23 """
24 Constructor 24 Constructor
25 25
26 @param clientStatus dictionary containing the WiFi status data of the 26 @param clientStatus dictionary containing the WiFi status data of the
27 client interface 27 client interface
28 @type dict 28 @type dict
29 @param apStatus dictionary containing the WiFi status data of the 29 @param apStatus dictionary containing the WiFi status data of the
30 access point interface 30 access point interface
31 @type dict 31 @type dict
32 @param overallStatus dictionary containing the overall WiFi status data
33 @type dict
32 @param parent reference to the parent widget (defaults to None) 34 @param parent reference to the parent widget (defaults to None)
33 @type QWidget (optional) 35 @type QWidget (optional)
34 """ 36 """
35 super().__init__(parent) 37 super().__init__(parent)
36 self.setupUi(self) 38 self.setupUi(self)
37 39
38 self.statusTree.setColumnCount(2) 40 self.statusTree.setColumnCount(2)
41
42 # overall status
43 QTreeWidgetItem(
44 self.statusTree,
45 [
46 self.tr("Active"),
47 self.tr("Yes") if overallStatus["active"] else self.tr("No"),
48 ],
49 )
39 50
40 # client interface 51 # client interface
41 if clientStatus: 52 if clientStatus:
42 header = self.__createHeader(self.tr("Client")) 53 header = self.__createHeader(self.tr("Client"))
43 QTreeWidgetItem( 54 QTreeWidgetItem(
53 [ 64 [
54 self.tr("Connected"), 65 self.tr("Connected"),
55 self.tr("Yes") if clientStatus["connected"] else self.tr("No"), 66 self.tr("Yes") if clientStatus["connected"] else self.tr("No"),
56 ], 67 ],
57 ) 68 )
58 QTreeWidgetItem(header, [self.tr("Status"), clientStatus["status"]]) 69 with contextlib.suppress(KeyError):
70 QTreeWidgetItem(header, [self.tr("Status"), clientStatus["status"]])
71 with contextlib.suppress(KeyError):
72 QTreeWidgetItem(
73 header, [self.tr("Hostname"), clientStatus["hostname"]]
74 )
59 QTreeWidgetItem( 75 QTreeWidgetItem(
60 header, [self.tr("IPv4 Address"), clientStatus["ifconfig"][0]] 76 header, [self.tr("IPv4 Address"), clientStatus["ifconfig"][0]]
61 ) 77 )
62 QTreeWidgetItem( 78 QTreeWidgetItem(
63 header, [self.tr("Netmask"), clientStatus["ifconfig"][1]] 79 header, [self.tr("Netmask"), clientStatus["ifconfig"][1]]
100 [ 116 [
101 self.tr("Connected"), 117 self.tr("Connected"),
102 self.tr("Yes") if apStatus["connected"] else self.tr("No"), 118 self.tr("Yes") if apStatus["connected"] else self.tr("No"),
103 ], 119 ],
104 ) 120 )
105 QTreeWidgetItem(header, [self.tr("Status"), apStatus["status"]]) 121 with contextlib.suppress(KeyError):
122 QTreeWidgetItem(header, [self.tr("Status"), apStatus["status"]])
123 with contextlib.suppress(KeyError):
124 QTreeWidgetItem(header, [self.tr("Hostname"), apStatus["hostname"]])
106 QTreeWidgetItem( 125 QTreeWidgetItem(
107 header, [self.tr("IPv4 Address"), apStatus["ifconfig"][0]] 126 header, [self.tr("IPv4 Address"), apStatus["ifconfig"][0]]
108 ) 127 )
109 QTreeWidgetItem(header, [self.tr("Netmask"), apStatus["ifconfig"][1]]) 128 QTreeWidgetItem(header, [self.tr("Netmask"), apStatus["ifconfig"][1]])
110 QTreeWidgetItem(header, [self.tr("Gateway"), apStatus["ifconfig"][2]]) 129 QTreeWidgetItem(header, [self.tr("Gateway"), apStatus["ifconfig"][2]])
111 QTreeWidgetItem(header, [self.tr("DNS"), apStatus["ifconfig"][3]]) 130 QTreeWidgetItem(header, [self.tr("DNS"), apStatus["ifconfig"][3]])
112 QTreeWidgetItem(header, [self.tr("SSID"), apStatus["essid"]]) 131 with contextlib.suppress(KeyError):
132 QTreeWidgetItem(header, [self.tr("SSID"), apStatus["essid"]])
113 QTreeWidgetItem(header, [self.tr("MAC-Address"), apStatus["mac"]]) 133 QTreeWidgetItem(header, [self.tr("MAC-Address"), apStatus["mac"]])
114 QTreeWidgetItem(header, [self.tr("Channel"), str(apStatus["channel"])]) 134 with contextlib.suppress(KeyError):
135 QTreeWidgetItem(
136 header, [self.tr("Channel"), str(apStatus["channel"])]
137 )
115 with contextlib.suppress(KeyError): 138 with contextlib.suppress(KeyError):
116 QTreeWidgetItem(header, [self.tr("Country"), apStatus["country"]]) 139 QTreeWidgetItem(header, [self.tr("Country"), apStatus["country"]])
117 with contextlib.suppress(KeyError): 140 with contextlib.suppress(KeyError):
118 QTreeWidgetItem( 141 QTreeWidgetItem(
119 header, 142 header,

eric ide

mercurial