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

The Python code does not respect the RPi's locale setting by default. #36

Open
Short-bus opened this issue Dec 11, 2023 · 2 comments
Open
Labels
question Further information is requested

Comments

@Short-bus
Copy link
Owner

Short-bus commented Dec 11, 2023

Jérémie / (Bobleponge91) found that pilomar.py and libraries do not understand "," as a decimal separator within Python functions if the locale specifies that character.
As a workaround the RPi's locale needs to be set to one with "." as the decimal character such as "en_GB" or "en_US".
Is there anything simple which can be implemented to make the program more tolerant of other locales?

@Short-bus Short-bus added the question Further information is requested label Dec 11, 2023
@Short-bus
Copy link
Owner Author

Short-bus commented Feb 5, 2024

65rbeyer on Instructables reported the same problem with his build.

Traceback (most recent call last):
 File "pilomar.py", line 1206, in <module>
  SDCardMonitor = discmonitor(name='root',devname='/dev/root',path='/',disctype='boot',logger=MainLog.Log) # Create new disc space monitor for the SD card.
 File "/home/pi/pilomar/src/pilomardisc.py", line 54, in __init__
  self.Poll(force=True) # Kickstart the values.
 File "/home/pi/pilomar/src/pilomardisc.py", line 98, in Poll
  dfdict = self.GetDfDictionary()
 File "/home/pi/pilomar/src/pilomardisc.py", line 86, in GetDfDictionary
  v = int(float(v[:-1]) * ji[1]) # Convert from HR text value into absolute value.
ValueError: could not convert string to float: '4,2'

@Short-bus
Copy link
Owner Author

Some progress made here finally while investigating UTF-8 vs LATIN-1 character set issues.
The locale library can perform conversion of strings into the en_US numeric format.
My current development copy has been working smoothly with fr_FR language set, it now seems to recognise the different number format that the O/S commands can generate when the language is non English.

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

No branches or pull requests

1 participant