mirror of
https://github.com/clockworkpi/launcher.git
synced 2025-12-13 02:08:50 +01:00
gateway switch bug fix
This commit is contained in:
parent
df03f2889a
commit
9bd4a6e965
@ -172,12 +172,11 @@ class GateWayPage(Page):
|
|||||||
for i in self._MyList:
|
for i in self._MyList:
|
||||||
i._Active = False
|
i._Active = False
|
||||||
|
|
||||||
cur_li._Active = True
|
|
||||||
self._Screen._MsgBox.SetText("Applying")
|
self._Screen._MsgBox.SetText("Applying")
|
||||||
self._Screen._MsgBox.Draw()
|
self._Screen._MsgBox.Draw()
|
||||||
self._Screen.SwapAndShow()
|
self._Screen.SwapAndShow()
|
||||||
|
|
||||||
self.ApplyGateWay(cur_li._Value)
|
cur_li._Active = self.ApplyGateWay(cur_li._Value)
|
||||||
|
|
||||||
pygame.time.delay(1000)
|
pygame.time.delay(1000)
|
||||||
self._Screen.Draw()
|
self._Screen.Draw()
|
||||||
@ -190,7 +189,7 @@ class GateWayPage(Page):
|
|||||||
def ApplyGateWay(self,gateway):
|
def ApplyGateWay(self,gateway):
|
||||||
os.system("sudo ip route del 0/0")
|
os.system("sudo ip route del 0/0")
|
||||||
if gateway== "usb0":
|
if gateway== "usb0":
|
||||||
out = commands.getstatus("sudo ifconfig usb0 | grep inet | tr -s \" \"| cut -d \" \" -f3")
|
out = commands.getstatusoutput("sudo ifconfig usb0 | grep inet | tr -s \" \"| cut -d \" \" -f3")
|
||||||
if len(out[1]) > 7:
|
if len(out[1]) > 7:
|
||||||
if "error" not in out[1]:
|
if "error" not in out[1]:
|
||||||
parts = out[1].split(".")
|
parts = out[1].split(".")
|
||||||
@ -199,15 +198,21 @@ class GateWayPage(Page):
|
|||||||
if tmp > 255:
|
if tmp > 255:
|
||||||
tmp = 255
|
tmp = 255
|
||||||
parts[3] = str(tmp)
|
parts[3] = str(tmp)
|
||||||
ipaddress = parts.join(".")
|
ipaddress = ".".join(parts)
|
||||||
os.system("sudo route add default gw "+ipaddress)
|
os.system("sudo route add default gw "+ipaddress)
|
||||||
|
return true
|
||||||
else:
|
else:
|
||||||
if is_wifi_connected_now():
|
if is_wifi_connected_now():
|
||||||
os.system("sudo dhclient wlan0")
|
os.system("sudo dhclient wlan0")
|
||||||
|
return true
|
||||||
else:
|
else:
|
||||||
self._Screen._MsgBox.SetText("Wi-Fi is not connected")
|
self._Screen._MsgBox.SetText("Wi-Fi is not connected")
|
||||||
self._Screen._MsgBox.Draw()
|
self._Screen._MsgBox.Draw()
|
||||||
self._Screen.SwapAndShow()
|
self._Screen.SwapAndShow()
|
||||||
|
return false
|
||||||
|
|
||||||
|
return false
|
||||||
|
|
||||||
|
|
||||||
def OnLoadCb(self):
|
def OnLoadCb(self):
|
||||||
self._Scrolled = 0
|
self._Scrolled = 0
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user