oliexdev / openScale

Open-source weight and body metrics tracker, with support for Bluetooth scales
GNU General Public License v3.0
1.68k stars 292 forks source link

Wiki import scripts rely on deprecated python2 with ambiguous shebang #922

Open meliache opened 1 year ago

meliache commented 1 year ago

Is your feature request related to a problem? Please describe. The Python import scripts in the Wiki at wiki/Useful-import-scripts seem to rely on python version 2, which is incompatible with the current Python 3. Python 2 reached end-of-life in 2020 and is not getting security updates anymore. It's still available in most mainstream Linux distributions but slowly being dropped in favor of Python 3.

Further , the #!/usr/bin/env python shebangs cannot be expected to refer to python2 anymore. On ArchLinux for example, python links to python3 instead of python2. I'm not sure about the status in other distributions but they will surely follow eventually if they haven't yet. It would be more explicit to use #!/usr/bin/env python2, at least it would communicate to the user that the script is python2-based.

I didn't check all scripts, but the main thing that seems incompatible with python3 is the print statement, which is a print function in python3.

Describe the solution you'd like As a hotfix I would change all python shebangs to #!/usr/bin/env python2 for consistency.

Then would either rewrite the scripts completely to use python3 (e.g. by using tools like 2to3, which nowadays should be available on most computers. Optionally, as an intermediate step one could write it in a style that's compatible with both python versions, e.g. by using things like from __future__ import print_function etc. The python3 print function also allows writing to stderr with print(..., file=sys.stderr), which I think is appropriate if what you print is an error message.

Describe alternatives you've considered The 2 to 3 transition in python is a mess that leads to such problems. If the target would be just Linux a bash script might avoid being dependent on the python installation, but that would not work with windows.

In addition to just wiki scripts, actually providing a python package that makes some scripts visible might be better, as you could then define the required python versions etc in the project, e.g. setup.py or pyproject.toml. This could then be installed by the user via pip or into an isolated environment via pipx.

Additional context Add any other context or screenshots about the feature request here.

oliexdev commented 1 year ago

Thanks for the hint but these scripts are provided by the openScale community. What I don't do is to maintain these scripts or to provide python packages. But that should not stop anyone from doing it anyway. Feel free to change these scripts to support python2 and send a PR or to provide these scripts as packages.