Commit Graph

9628 Commits

Author SHA1 Message Date
Laurent Monin
ec9090f115 PICARD-2481: shorten country long lists in search results
Use limited_join() as we do elsewhere to limit the size of the list to something usable.

Add new `countries_shortlist()` to wrap call to `limited_join()`
2023-06-13 15:55:51 +02:00
Laurent Monin
8f09816c66 Avoid setting format, it's a builtin, rename to fmt 2023-06-13 11:51:51 +02:00
Laurent Monin
351a099845 _request_recording_relationships(): drop unused config parameter
config isn't used in the method, so no need to set it or to pass it
2023-06-13 11:51:51 +02:00
Laurent Monin
db41001a32 Merge pull request #2235 from zas/i18n_tidyup
Rework _try_locales(), introduce _try_encodings(), and add tests for …
2023-06-13 08:25:10 +02:00
Laurent Monin
497aeae35b Rework _try_locales(), introduce _try_encodings(), and add tests for them 2023-06-12 23:29:56 +02:00
Philipp Wolfer
54337a2dff Changed UI translations from Transifex since last release 2023-06-12 08:46:15 +02:00
Philipp Wolfer
580617b5e7 Build with PyInstaller 5.12 2023-06-11 17:44:27 +02:00
Philipp Wolfer
27edb07068 Merge pull request #2231 from phw/i18n-tests
Refactor loading of locales in i18n module, extended logging and added tests
2023-06-11 17:40:51 +02:00
Laurent Monin
86bbf2a45f Merge pull request #2225 from zas/ws_url
Introduce WebService (get|post|put|delete|download)_url() methods
2023-06-11 17:09:30 +02:00
Laurent Monin
b9e45fdaa2 Log related env variables when language is set to system 2023-06-11 16:56:37 +02:00
Laurent Monin
53c859944e Rework the way locales are guessed and set, simplify code
- create lists of candidates, then try
- improve logging
- instead of setting env vars for gettext language selection, use `gettext.translation()` `languages` parameter
- try 'UTF-8' only once if it is the preferred encoding
2023-06-11 16:56:37 +02:00
Laurent Monin
c495ab4a42 macos: return set locale if possible, and just return set_locale_from_env() if not 2023-06-11 16:56:37 +02:00
Laurent Monin
54801d97df Now that we default to 'C' locale for tests, remove redundant setups 2023-06-11 16:56:37 +02:00
Laurent Monin
386bbd683d test_existing_locales(): assert the _() changed after setup 2023-06-11 16:56:37 +02:00
Laurent Monin
1dba99303e Introduce set_locale_from_env(): it ensures we fallback on C locale if setting from env fails
Log much more infos to ease debugging locale/language-related issues
2023-06-11 16:56:37 +02:00
Laurent Monin
be393f60af Default to C locale for all tests
It ensures tests aren't locale-dependent.
2023-06-11 16:56:37 +02:00
Laurent Monin
663b7f5ebb Merge pull request #2234 from phw/fix-packaged-module-path
Fix logging module path for PyInstaller packages
2023-06-11 09:01:21 +02:00
Philipp Wolfer
20d6402159 Logging: Only resolve paths if they are absolute 2023-06-11 02:30:48 +02:00
Philipp Wolfer
ab99fafd2e PyInstaller recommends checking both the frozen and _MEIPASS attributes 2023-06-11 02:04:55 +02:00
Philipp Wolfer
1dfcd9e6e6 Fix logging module path for PyInstaller packages 2023-06-11 02:04:54 +02:00
Laurent Monin
29ef7406c5 Merge pull request #2233 from zas/fix_log_path
Improve records name & path in log output
2023-06-10 23:17:36 +02:00
Laurent Monin
cd6faa7ff1 Improve records name & path in log output
- use pathlib
- get picard module real path using importlib
2023-06-10 09:12:53 +02:00
Laurent Monin
93204c2ece Avoid a warning on Picard start-up about send_to_pipe
Before this patch, Picard is logging a warning before anything else that looks like:

`W: pipe.send_to_pipe:276: Couldn't send: '\x00'`

At this point, the pipe isn't fully functional, and this message is expected, as Picard sends a message to pipe to see if it's the owner or not (in `AbstractPipe.__init__()`).
The behavior is normal, the warning isn't.

To fix it, check if the pipe is marked as running before logging such warning.
2023-06-09 16:49:37 +02:00
Laurent Monin
db4d9cfa0a Move /v2 to ACOUSTID_URL 2023-06-09 16:08:36 +02:00
Laurent Monin
20fbea6454 WebService: rework (mostly debug) logging of URLs
- ensure UserInfo is removed everywhere
- use QUrl.toDisplayString()
- keep spaces encoded (`%20`) in order to avoid breaking URLs (useful for terminal allowing to follow links)
- avoid having a ':' displayed just after URL (it also breaks links as : is legit in URLs)
- drop http_response_safe_url() in favor of more generic display_url()
- use constant variable naming scheme
2023-06-09 11:18:25 +02:00
Laurent Monin
5d486c94fc WebService: add more tests for queryargs and unencoded_queryargs 2023-06-09 10:20:20 +02:00
Philipp Wolfer
3daf66e158 Minor code cleanup for ReleaseGroup._parse_versions 2023-06-09 09:19:34 +02:00
Philipp Wolfer
866ef71dce Skip locale test if locales are not built, build locales in CI tests 2023-06-09 09:19:07 +02:00
Philipp Wolfer
79cbc53f4d i18n: basic tests for working locales 2023-06-09 08:59:16 +02:00
Laurent Monin
5395cbfc3d MBAPIHelper: introduce _make_inc_arg() to build inc parameter value
- it produces a more stable output (elements are sorted)
- it gets rid of empty elements (preventing a++b case)
- it accepts any iterable
- add a test for it

I also removed 2 useless conversion to tuple() (it can use a set() anyway)
2023-06-09 08:50:34 +02:00
Laurent Monin
9a0bedff20 Keep MBAPIHelper base_url dynamic 2023-06-08 22:38:53 +02:00
Laurent Monin
58f6b8dc7b Get rid of APIHelper path list, just pass the path string to append 2023-06-08 16:44:15 +02:00
Laurent Monin
cfbdb1fb48 PluginsOptionsPage: use unencoded_queryargs (as they are unencoded) 2023-06-08 16:44:15 +02:00
Laurent Monin
3f7b70d1be CoverArtImage: remove unneeded parse_url()
- there's no point for it now, just ensure we have a QUrl
- instead of CoverArtImage.host, use CoverArtImage.url.host()
2023-06-08 16:44:15 +02:00
Laurent Monin
efde79a5e1 API Helpers: use unencoded_queryargs 2023-06-08 16:44:15 +02:00
Laurent Monin
ab7ab8a431 WSRequest: add unencoded_queryargs parameters
It works the same as queryargs, but it encodes values
2023-06-08 16:44:15 +02:00
Philipp Wolfer
c7acf9ea5b Use base_url in APIHelper instead of separate url and base_path properties 2023-06-08 16:44:15 +02:00
Laurent Monin
59550aa366 Simplify code using encoded_queryargs() 2023-06-08 16:44:15 +02:00
Laurent Monin
944a92eecd Add an helper method to encode query arguments: encoded_queryargs() 2023-06-08 16:44:15 +02:00
Laurent Monin
dffb7cd7db WSRequest: make it clear queryargs should consist of encoded arguments 2023-06-08 16:44:15 +02:00
Laurent Monin
60778cd9fe Mark WebService.(get|post|put|delete|download)() methods as deprecated
- log a warning
2023-06-08 16:44:15 +02:00
Laurent Monin
f876fc0403 CoverArtBox: simplify code using WebService.download_url() 2023-06-08 16:44:15 +02:00
Laurent Monin
16ff3c5c97 Move few functions to new webservice.utils and introduce set_minimum_delay_for_url()
- it limits the need to import hostkey_from_url()
- it reduces the size of webservice.py
- it reduces dependencies between files
2023-06-08 16:44:15 +02:00
Laurent Monin
886cc15ef3 Drop ACOUSTID_HOST, ACOUSTID_PORT in favor of new ACOUSTID_URL 2023-06-08 16:44:15 +02:00
Laurent Monin
a39932c264 Introduce APIHelper url property and replace host & port properties
- __init__() calls in subclasses are not needed anymore
- base_path class property defines the url path prefix
2023-06-08 16:44:15 +02:00
Laurent Monin
884b7e1990 Convert MBAPIHelper 2023-06-08 16:44:15 +02:00
Laurent Monin
6583ba7524 Convert APIHelper 2023-06-08 16:44:15 +02:00
Laurent Monin
2e54681fd6 Introduce host_port_to_url()
This method will help with the move, since we have in many places just host & port (including in Options dialog).

Basically it does its best to convert it to an URL.
2023-06-08 16:44:15 +02:00
Laurent Monin
8b243e72b6 Get rid of CAA_HOST / CAA_PORT, replaced by CAA_URL 2023-06-08 16:44:15 +02:00
Laurent Monin
d10397d30a Introduce hostkey_from_url()
It calculates (host, port) from passed URL.
With matching tests.
2023-06-08 16:44:15 +02:00