FormerLurker / ArcWelderPlugin

A plugin for OctoPrint used to convert G0/G1 commands to G2/G3 commands. Reduce the size of your gcode files, and reduce number of gcodes per second sent to your printer.
Other
444 stars 26 forks source link

Avoid comparison with NoneType #159

Closed 7FM closed 3 years ago

7FM commented 3 years ago

During octoprint startup I get a small stacktrace due to a comparison with None. Thus a simple fix should be replacing the fallthrough if checks with if else

octoprint - ERROR - Error while trying to migrate settings for plugin arc_welder, ignoring it
Traceback (most recent call last):
  File "/home/pi/oprint/lib/python3.7/site-packages/octoprint/__init__.py", line 509, in init_settings_plugin_config_migration_and_cleanup
    implementation._identifier, implementation
  File "/home/pi/oprint/lib/python3.7/site-packages/octoprint/__init__.py", line 493, in settings_plugin_config_migration_and_cleanup
    settings_migrator(settings_version, stored_version)
  File "/home/pi/oprint/lib/python3.7/site-packages/octoprint/util/__init__.py", line 1890, in wrapper
    return f(*args, **kwargs)
  File "/home/pi/oprint/lib/python3.7/site-packages/octoprint_arc_welder/__init__.py", line 194, in on_settings_migrate
    if current < 2:
TypeError: '<' not supported between instances of 'NoneType' and 'int'

PS: Any suggestion to get a version number for my settings?^^ And of course thanks a lot for your dedication! I am using this plugin for a while now without problems :)

FormerLurker commented 3 years ago

Looks like that line should actually be this:

        if current is None:
            current = -1
        if current < 2:
            logger.info("Migrating settings to version 2.")

In your code, the settings migration would be skipped if current is None. I did fix the issue (thanks for locating it!), so I'll close this out.