Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when locale does use a special character for the decimal #6

Open
ghost opened this issue Oct 11, 2020 · 2 comments
Open

Error when locale does use a special character for the decimal #6

ghost opened this issue Oct 11, 2020 · 2 comments

Comments

@ghost
Copy link

ghost commented Oct 11, 2020

After setting up the locale to fr_FR.UTF-8 using raspi-configand launching the script, I get the following error :

pi@raspberrypi:~nas-kit $ python3 main/raspi_omv_main.py
Exception in thread Thread-1
Traceback (most recent call last):
  File "/usr/lib/python3.7/threading.py", line 917, in _boostrap_inner
    self.run()
  File "/usr/lib/python3.7/threading.py", line 865, in run
    self._target(*self._args, **self._kwargs)
  File "main/raspi_omv_main.py", line 312, in main
    page(current_page)
  File "/home/pi/nas-kit/main/page.py", line 76, in __call__
    eval(cmd)
  File "<string>", line 1, in <module>
  File "/home/pi/nas-kit/main/page.py", line 99, in page_1_update
    pi_msg = pi_read()
  File "/home/pi/nas-kit/main/page.py", line 150, in pi_read
    "cpu_usage": cpu_usage(),
  File "/home/pi/nas-kit/main/page.py", line 106, in cpu_usage
    result = round(100 - float(result), 2)
ValueError: could not convert string to float: '80,35'

The problem seems to come fram the fact that the french locale use , as a decimal separator, and not ..
The workaround is to revert back to en_US.UTF-8 locale, but it should be possible to handle this problem using the locale library.

@nostromo1st
Copy link

Hello Blablux,

I have the same problem. Have you resolved it or not ?

@ghost
Copy link
Author

ghost commented Oct 18, 2020

@nostromo1st I'm still using the en_US.UTF-8 locale.
I had no time yet to look into the code...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant