Open MardukNT opened 3 years ago
This issue appears to persist to this day. I looked at the code in src/resources.py and at line 60 it seems to assume a 'wlan0' entry in the network[] list which would not be true when not connected to wifi. I tried to remedy it by putting the similar try/except block around that line but that didn't work as expected, either. {unlike MardukNT my Pi is simply wired to eth0, no wifi at all). This would also be an issue for completely non-connected PI's, as well, correct?
I got it to work by changing the "IndexError" try keywords to (IndexError, KeyError) to match the exception occurring. This is my wlan0 code starting around line 60 in src/resources.py:
`try: ipv4wlan0 = network['wlan0'][0][1] broadcastwlan = network['wlan0'][0][3] macwlan0 = network['wlan0'][2][1] except (IndexError, KeyError): ipv4wlan0 = None macwlan0 = None broadcastwlan = None
try: ipv6wlan0 = network['wlan0'][1][1] except (IndexError, KeyError): ipv6wlan0 = None ` {Sorry, but you'll need to do the proper indents yourself since I don't know how to get github to preserve mine; everything is indented except the "try" and "except" lines} So devs/maintainers, watchout for those assumptions that we all make. Programming challenges!?!
Other than this hickup this is a REALLY handy utility that should be included in the main OS.
System Specs:
OS Mod: Twister OS Lite version 2.0.3 OS: Raspbian GNU/Linux 10 (buster) armv7l Host: Raspberry Pi 4 Model B Rev 1.1 Kernel: 5.10.17-v7l+ Shell: bash 5.0.3 CPU: BCM2711 (4) @ 2.000GHz Memory: 776MiB / 3774MiB Disk (/): 5.6G / 110G (6%)
Issue:
CommanderPi v1.0 GUI fails to launch when dtoverlay=disable-wifi is used in /boot/config.txt
Steps to reproduce:
sudo nano /boot/config.txt
and hit Enter.dtoverlay=disable-wifi
under the [All] section. Then Save and Exit.Expected behavior:
CommanderPi should launch and function properly if/when WiFi is disabled at startup in the boot config file.
Troubleshooting performed:
From a Terminal session, I ran the following command
sudo python3 ${HOME}/CommanderPi/src/main.py ${HOME}
Command output (emphasis added by me):
Here is home_path /home/pi
Here is app-1 Version 1.0
Exist and read
Traceback (most recent call last):
File "/home/pi/CommanderPi/src/main.py", line 2, in <module>
import gui as g
File "/home/pi/CommanderPi/src/gui.py", line 4, in <module>
import resources as rs
File "/home/pi/CommanderPi/src/resources.py", line 60, in <module>
ipv4wlan0 = network['wlan0'][0][1]
KeyError: 'wlan0'
Note: Removing or commenting out
dtoverlay=disable-wifi
from /boot/config.txt and rebooting, resolves the issue (but not the underlying conflict).Final Thoughts:
Thank you for your attention to this matter. Kindly reach out to me, if you require further information or further testing. --MardukNT