Skip to content

Commit

Permalink
replace Enable Networking by Restart Networking.
Browse files Browse the repository at this point in the history
  • Loading branch information
ericbsd committed Feb 19, 2024
1 parent 325d94c commit 0a3cd3f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 15 deletions.
4 changes: 2 additions & 2 deletions NetworkMgr/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
defaultcard,
nics_list,
restart_card_network,
restart_rounting_and_dhcp,
restart_routing_and_dhcp,
start_static_network,
wait_inet
)
Expand Down Expand Up @@ -477,7 +477,7 @@ def update_system(self):
# sometimes the inet address isn't available immediately after dhcp is enabled.
start_static_network(nic, inet, netmask)
wait_inet(nic)
restart_rounting_and_dhcp(nic)
restart_routing_and_dhcp(nic)

self.destroy()

Expand Down
10 changes: 7 additions & 3 deletions NetworkMgr/net_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,15 @@ def get_ssid(wificard):


def nics_list():
notnics_regex = r"(enc|lo|fwe|fwip|tap|plip|pfsync|pflog|ipfw|tun|sl|" \
not_nics_regex = r"(enc|lo|fwe|fwip|tap|plip|pfsync|pflog|ipfw|tun|sl|" \
r"faith|ppp|bridge|wg)[0-9]+(\s*)|vm-[a-z]+(\s*)"
nics = Popen(
'ifconfig -l',
shell=True,
stdout=PIPE,
universal_newlines=True
).stdout.read().strip()
return sorted(re.sub(notnics_regex, '', nics).strip().split())
return sorted(re.sub(not_nics_regex, '', nics).strip().split())


def ifcardconnected(netcard):
Expand Down Expand Up @@ -184,6 +184,10 @@ def switch_default(nic):
return


def restart_all_nics(widget):
run('service netif restart', shell=True)


def stopallnetwork():
run('service netif stop', shell=True)

Expand All @@ -201,7 +205,7 @@ def restart_card_network(netcard):
run(f'service netif restart {netcard}', shell=True)


def restart_rounting_and_dhcp(netcard):
def restart_routing_and_dhcp(netcard):
run('service routing restart', shell=True)
sleep(1)
run(f'service dhclient restart {netcard}', shell=True)
Expand Down
15 changes: 5 additions & 10 deletions NetworkMgr/trayicon.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
stopnetworkcard,
startnetworkcard,
wifiDisconnection,
restart_all_nics,
stopallnetwork,
startallnetwork,
connectToSsid,
Expand Down Expand Up @@ -137,16 +138,10 @@ def nm_menu(self):
self.menu.append(configure_item)
self.menu.append(Gtk.SeparatorMenuItem())
wifinum += 1
if self.cardinfo['service'] is False:
open_item = Gtk.MenuItem(_("Enable Networking"))
open_item.connect("activate", self.openNetwork)
self.menu.append(open_item)
else:
close_item = Gtk.MenuItem(_("Disable Networking"))
close_item.connect("activate", self.closeNetwork)
self.menu.append(close_item)
# else:
# print('service netif status not supported')

open_item = Gtk.MenuItem(_("Restart Networking"))
open_item.connect("activate", restart_all_nics)
self.menu.append(open_item)
close_manager = Gtk.MenuItem(_("Close Network Manager"))
close_manager.connect("activate", self.stop_manager)
self.menu.append(close_manager)
Expand Down

0 comments on commit 0a3cd3f

Please sign in to comment.