gopro / OpenGoPro

An open source interface specification to communicate with a GoPro camera with accompanying demos and tutorials.
https://gopro.github.io/OpenGoPro/
MIT License
676 stars 149 forks source link

Python SDK Wifi Driver should use c.utf-8 instead of en_US #320

Open simohn opened 1 year ago

simohn commented 1 year ago

Problem I would like to use the latest version of the Python SDK on Ubuntu Core. The problem is, that the library requires en_US.UTF-8 as locale, but on Ubuntu Core the locale is C.UTF-8 and unfortunately it's not editable. The language check was introduced in version 0.13.0. https://gopro.github.io/OpenGoPro/python_sdk/changelog.html

Describe the solution you'd like Can you add C.UTF-8 support?

tcamise-gpsw commented 1 year ago

Hello. Sure we can add this. Can you post the error message you are getting so I know exactly what string to compare against? It shoud be something like:

The Wifi driver parses CLI responses and only supports en_US where your language is {language}
tcamise-gpsw commented 1 year ago

Although now that I'm reading about what C.UTF-8 actually is I am worried that it is not going to work. If the CLI responses are different in any way than en-US, it is very likely to break the parsing.

Anyway when you send me the error string, I will make a branch that accepts it but I'll leave it up to you to test.

Reading further it sounds like I should in fact be setting the language to C and parsing that instead of us-EN. If that's the case we can leave this open as a feature request but I have no idea when I'll get to that.

simohn commented 1 year ago

Hello. Sure we can add this. Can you post the error message you are getting so I know exactly what string to compare against? It shoud be something like:

The Wifi driver parses CLI responses and only supports en_US where your language is {language}

Hello. Yes, here it is:

Traceback (most recent call last): File "/snap/cam-controller/x7/bin/cam-controller", line 8, in sys.exit(main()) File "/snap/cam-controller/x7/lib/python3.10/site-packages/cam_controller/app.py", line 5, in main with WirelessGoPro() as gopro: File "/snap/cam-controller/x7/lib/python3.10/site-packages/open_gopro/gopro_wireless.py", line 166, in init wifi_controller=wifi_adapter(wifi_interface, password=sudo_password) if enable_wifi else None, File "/snap/cam-controller/x7/lib/python3.10/site-packages/open_gopro/wifi/adapters/wireless.py", line 86, in init ensure_us_english() File "/snap/cam-controller/x7/lib/python3.10/site-packages/open_gopro/wifi/adapters/wireless.py", line 44, in ensure_us_english raise RuntimeError( RuntimeError: The Wifi driver parses CLI responses and only supports en_US where your language is C.UTF-8

simohn commented 1 year ago

Although now that I'm reading about what C.UTF-8 actually is I am worried that it is not going to work. If the CLI responses are different in any way than en-US, it is very likely to break the parsing.

Anyway when you send me the error string, I will make a branch that accepts it but I'll leave it up to you to test.

Reading further it sounds like I should in fact be setting the language to C and parsing that instead of us-EN. If that's the case we can leave this open as a feature request but I have no idea when I'll get to that.

Ok, I understand. Yes, that sounds also reasonable for me. Hmm. I think I will stay by an older version then and switch to the new release, in case you are going to change it. Thank you.

simohn commented 1 year ago

Is it possible to access the documentation of an older version? On https://gopro.github.io/OpenGoPro/python_sdk/index.html I only get to the latest.

Creepios commented 1 year ago

You can fix this temporarily with this:

import os
os.environ["LANG"] = "en_US"`
MelVimL commented 3 months ago

What kind of CLI-Calls are parsed and where? WifiController? To be honest changing/reinstalling the OS during development is a bit frustrating.

""

Install language" is only set during the Out of Box Experience (OOBE) and then never changes. If the system language is changed, this function returns an incorrect value.

" - https://learn.microsoft.com/en-us/windows/win32/api/winnls/nf-winnls-getsystemdefaultuilanguage

MelVimL commented 3 months ago

If its okay I can try to add Windows with locale de_DE. Maybe some Linux Controller with de_DE too. Document the process to make it others easier to add their locals.

tcamise-gpsw commented 3 months ago

Sure go for it! Please make a pull request here when its reqdy.

Also, I will at some point refactor this to make it easier to add other languages.

MelVimL commented 3 months ago

Should I edit it in the file or is it okay if I split it up into OS adapter files like:

grafik

zeyad-shaban commented 1 month ago

run in temrianl export LANG=en_US.UTF-8