jirimakarius / OctoPrint-Dashboard

Dashboard for OctoPrint, which is able to manage multiple OctoPrint instances
MIT License
6 stars 2 forks source link

Python 3.4 compatiblity #2

Closed hroncok closed 7 years ago

hroncok commented 7 years ago

The only thing that prevent's 3.4 to run this is the missing json.JSONDecodeError exception:

https://github.com/meadowfrey/OctoPrint-Dashboard/blob/8e96cdd026e16a9251b24c1fb62487192d1b0ed7/octoprint_dashboard/services/octoprintService.py#L1

In order to make this 3.4 compatible (as 3.4 runs in FIT CTU classrooms), you should probably send a PR to octoclient not to leak this exception, but as a workaround, you can try to get ValueError instead (raised by 3.4:

try:
    from json import JSONDecodeError
except ImportError:  # Python 3.4
    JSONDecodeError = ValueError

Or (even better) catch ValueError here instead of json.JSONDecodeError (this works thanks to class inheritance).

>>> from json import JSONDecodeError
>>> JSONDecodeError.__base__
<class 'ValueError'>
ghost commented 7 years ago

fixed with commit 9d2ff2a5a2daa0b62121d253779515f6b7d647e4