Skip to content

Commit

Permalink
Merge pull request #93 from kenrap/cleanup
Browse files Browse the repository at this point in the history
Apply some cleanup
  • Loading branch information
ericbsd authored Jul 31, 2023
2 parents 3789efe + bdcf582 commit 86ec65c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
10 changes: 5 additions & 5 deletions src/net_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,12 +160,12 @@ def networkdictionary():
# append left over
info.append(line[83:].strip())
connectioninfo[ssid] = info
if ifWlanDisable(card) is True:
if ifWlanDisable(card):
connectionstat = {
"connection": "Disabled",
"ssid": None,
}
elif ifStatue(card) is False:
elif not ifStatue(card):
connectionstat = {
"connection": "Disconnected",
"ssid": None,
Expand All @@ -181,9 +181,9 @@ def networkdictionary():
'info': connectioninfo
}
else:
if card_online(card) is True:
if card_online(card):
connectionstat = {"connection": "Connected"}
elif ifcardconnected(card) is True:
elif ifcardconnected(card):
connectionstat = {"connection": "Disconnected"}
else:
connectionstat = {"connection": "Unplug"}
Expand All @@ -197,7 +197,7 @@ def connectionStatus(card):
if card is None:
netstate = "Network card is not enabled"
elif 'wlan' in card:
if ifWlanDisable(card) is False and ifStatue(card) is True:
if not ifWlanDisable(card) and ifStatue(card):
cmd1 = "ifconfig %s | grep ssid" % card
cmd2 = "ifconfig %s | grep 'inet '" % card
out1 = Popen(cmd1, shell=True, stdout=PIPE,
Expand Down
14 changes: 7 additions & 7 deletions src/trayicon.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def nm_menu(self):
wc_title.set_sensitive(False)
self.menu.append(wc_title)
connection_item = Gtk.ImageMenuItem(ssid)
connection_item.set_image(self.open_wifi(bar))
connection_item.set_image(self.wifi_signal_icon(bar))
connection_item.show()
disconnect_item = Gtk.MenuItem(_("Disconnect from %s") % ssid)
disconnect_item.connect("activate", self.disconnect_wifi,
Expand All @@ -135,7 +135,7 @@ def nm_menu(self):
wifinum += 1

if openrc:
if self.cardinfo['service'] is False:
if not self.cardinfo['service']:
label = _("Enable Networking")
action = self.openNetwork
else:
Expand All @@ -154,15 +154,15 @@ def nm_menu(self):

def ssid_menu_item(self, caps, ssid, ssid_info):
menu_item = Gtk.ImageMenuItem(ssid)
if caps == 'E' or caps == 'ES':
if caps in ('E', 'ES'):
is_secure = False
click_action = self.menu_click_open
ssid_type = ssid
else:
is_secure = True
click_action = self.menu_click_lock
ssid_type = ssid_info
menu_item.set_image(self.open_wifi(sn, is_secure))
menu_item.set_image(self.wifi_signal_icon(sn, is_secure))
menu_item.connect("activate", click_action, ssid_type, wificard)
menu_item.show()
return menu_item
Expand Down Expand Up @@ -240,7 +240,7 @@ def signal_icon_name(self, bar, suffix):
icon_name = f"nm-signal-00{suffix}"
return icon_name

def open_wifi(self, bar, is_secure=False):
def wifi_signal_icon(self, bar, is_secure=False):
img = Gtk.Image()
suffix = ""
if is_secure:
Expand Down Expand Up @@ -306,7 +306,7 @@ def updatetrayicon(self, defaultdev, card_type):
self.statusIcon.set_from_icon_name(icon_name)

def trayStatus(self, defaultdev):
self.statusIcon.set_tooltip_text("%s" % connectionStatus(defaultdev))
self.statusIcon.set_tooltip_text(connectionStatus(defaultdev))

def tray(self):
self.if_running = False
Expand All @@ -332,7 +332,7 @@ def try_to_connect_to_ssid(self, ssid, ssid_info, card):
delete_ssid_wpa_supplicant_config(ssid)
GLib.idle_add(self.restart_authentication, ssid_info, card)
else:
for _ in list(range(60)):
for _ in range(60):
if wlan_status(card) == 'associated':
self.updateinfo()
break
Expand Down

0 comments on commit 86ec65c

Please sign in to comment.