@@ -140,26 +140,25 @@ def networkdictionary():
140
140
return maindictionary
141
141
142
142
143
- def connectionStatus (card ) :
143
+ def connectionStatus (card : str , network_info : dict ) -> str :
144
144
if card is None :
145
145
netstate = "Network card is not enabled"
146
146
elif 'wlan' in card :
147
147
if not ifWlanDisable (card ) and ifStatue (card ):
148
148
cmd1 = "ifconfig %s | grep ssid" % card
149
149
cmd2 = "ifconfig %s | grep 'inet '" % card
150
- out1 = Popen (cmd1 , shell = True , stdout = PIPE ,
151
- universal_newlines = True )
152
- out2 = Popen ( cmd2 , shell = True , stdout = PIPE ,
153
- universal_newlines = True )
154
- line1 = out1 . stdout . read (). strip ()
155
- line2 = out2 . stdout . read (). strip ()
156
- netstate = line1 + ' \n ' + subnetHexToDec (line2 )
150
+ out1 = Popen (cmd1 , shell = True , stdout = PIPE , universal_newlines = True )
151
+ out2 = Popen ( cmd2 , shell = True , stdout = PIPE , universal_newlines = True )
152
+ ssid_info = out1 . stdout . read (). strip ()
153
+ inet_info = out2 . stdout . read (). strip ( )
154
+ ssid = network_info [ 'cards' ][ card ][ 'state' ][ "ssid" ]
155
+ percentage = network_info [ 'cards' ][ card ][ 'info' ][ ssid ][ 4 ]
156
+ netstate = f"Signal Strength: { percentage } % \n { ssid_info } \n { subnetHexToDec (inet_info ) } "
157
157
else :
158
158
netstate = "WiFi %s not connected" % card
159
159
else :
160
160
cmd = "ifconfig %s | grep 'inet '" % card
161
- out = Popen (cmd , shell = True , stdout = PIPE ,
162
- universal_newlines = True )
161
+ out = Popen (cmd , shell = True , stdout = PIPE , universal_newlines = True )
163
162
line = out .stdout .read ().strip ()
164
163
netstate = subnetHexToDec (line )
165
164
return netstate
0 commit comments