GoPiGo3 icon indicating copy to clipboard operation
GoPiGo3 copied to clipboard

False "Firmware update is needed" on failed Bullseye installs

Open slowrunner opened this issue 2 years ago • 1 comments

When an update_gopigo3.sh install to Bullseye fails, the “check_if_firmware_upgrade_needed” will fail instantiating a GoPiGo3 because the setuptools was not present to install the gopigo3 egg files. When that instantiation fails because of the missing modules, the check executes the exception clause which improperly states “Firmware Upgrade Is Needed”

try:
        g = gopigo3.GoPiGo3()
        current_firmware = g.get_version_firmware()
        if current_firmware == available_firmware:
                print(f"\nThe GoPiGo is already running the latest firmare: {current_firmware}. \nAn upgrade is not needed at this time.\n")
                exit(1)
except Exception as e:
        print(e)
        print("Firmware upgrade is needed")
        exit(0)

While the end of the installation does give an error, many folks do not seem to read it.

GOPIGO3 SOFTWARE INSTALLATION FAILURE: +Traceback (most recent call last): File "<string>", line 1, in <module> ModuleNotFoundError: No module named 'gopigo3'
Suggest installing over Legacy Pi OS (Buster).

======== Suggestion for check_if_firmware_update_is_needed.py move the firmware upgrade needed notice to an else clause:

...
 if current_firmware == available_firmware:
                print(f"\nThe GoPiGo is already running the latest firmware: {current_firmware}. \nAn upgrade is not needed at this time.\n")
                exit(1)
 else:
        # print("Firmware upgrade is needed")
        print(f"\nThe GoPiGo3 is running firmware: {current_firmware}.  An upgrade to {available_firmware} is needed.\n")
        exit(0)

except Exception as e:
        print(e)
        exit(0)

slowrunner avatar Apr 23 '22 04:04 slowrunner

Isn't zero a successful exit code?

Why does the successful exit, exit with a "1" and the errors exit with a "0"?

jharris1993 avatar Apr 24 '22 23:04 jharris1993