Commit Graph

9275 Commits

Author SHA1 Message Date
Michael Manganiello
33e6c2310e Merge pull request #1034 from rommapp/misc/use-PYTEST_VERSION-to-detect-pytest-runs
misc: Use PYTEST_VERSION variable to detect Pytest runs
2024-07-27 13:43:46 -03:00
Georges-Antoine Assi
ecc021e824 Merge branch 'master' into calc-file-hashes-roms 2024-07-27 12:17:18 -04:00
Michael Manganiello
749e4d65c1 misc: Use PYTEST_VERSION variable to detect Pytest runs
Pytest v8.2 introduced the `PYTEST_VERSION` environment variable [1],
that can be used to check if code is running from within a pytest run.

This way, we can avoid checking the loaded `sys` modules.

[1] https://docs.pytest.org/en/stable/changelog.html#id57
2024-07-27 12:03:44 -03:00
Michael Manganiello
9246f87f38 Merge pull request #1032 from rommapp/fix/quick-return-if-igdb-exact-match
fix: Return early if IGDB finds an exact match
2024-07-27 11:51:37 -03:00
Michael Manganiello
66f4c0a6d8 Merge pull request #1033 from rommapp/fix/scheduled-switch-title-db-run
fix: Initialize context on scheduled task
2024-07-27 11:51:07 -03:00
Michael Manganiello
fe5759fec7 fix: Initialize context on scheduled task
Only for this scheduled task, the run was failing because there was no
context initialization that created the httpx session.

Other schedules work as expected, because they do have context
initialization in the functions they call to (e.g. `scan_platforms`).
2024-07-27 01:22:29 -03:00
Michael Manganiello
9319081ff6 fix: Return early if IGDB finds an exact match
This improvement avoids extra IGDB API requests when a received Rom is
an exact match. It avoids up to 2 requests per Rom, when an exact match
is found.
2024-07-27 00:53:27 -03:00
Michael Manganiello
9b52a4b813 Merge pull request #1030 from rommapp/fix/enable-async-rules-ruff
fix: Enable flake8-async rules in ruff and fix warnings
2024-07-27 00:41:32 -03:00
Michael Manganiello
d1fda9081f fix: Add missing awaits on read/write for async opened files 2024-07-27 00:38:05 -03:00
Michael Manganiello
c5b150c1eb fix: Enable flake8-async rules in ruff and fix warnings
`ASYNC` rules [1] tries to find issues regarding asynchronous code. This
change enables `ruff` to start reporting these issues, and fixes
existing warnings.

[1] https://docs.astral.sh/ruff/rules/#flake8-async-async
2024-07-26 21:40:46 -03:00
Michael Manganiello
146c26cc53 Merge pull request #1023 from rommapp/misc/migrate-igdb-handler-to-async
misc: Migrate IGDBBaseHandler to async
2024-07-26 21:25:46 -03:00
Michael Manganiello
96699a2f1b fix: Catch ProtocolError when writing screenshots/covers 2024-07-26 21:19:18 -03:00
Michael Manganiello
aced1f1ff2 misc: Migrate IGDBBaseHandler to async
Convert `IGDBBaseHandler` methods to be asynchronous, and use an `httpx`
async client, instead of `requests` sync client.

This change also removes the direct dependency with `requests`, as the
project no longer uses it, preferring `httpx` instead.
2024-07-26 21:19:01 -03:00
Georges-Antoine Assi
efc0b75cdb Merge branch 'master' into calc-file-hashes-roms 2024-07-25 22:42:46 -04:00
Georges-Antoine Assi
141edf9d2e Merge pull request #1028 from rommapp/share-public-collections
Public collections
2024-07-25 22:38:21 -04:00
Georges-Antoine Assi
ad3a588631 filter collections for each user 2024-07-25 19:53:44 -04:00
Georges-Antoine Assi
fafd48586c Merge pull request #1026 from rommapp/romm-1025
[ROMM-1025] Replace game-and-watch with g-and-w
2024-07-25 17:41:09 -04:00
Zurdi
38a500f577 Merge branch 'master' into romm-1025 2024-07-25 21:35:18 +02:00
Georges-Antoine Assi
7555c0607a [ROMM-1025] Replace game-and-watch with g-and-w 2024-07-25 14:26:06 -04:00
Michael Manganiello
377d460623 Merge pull request #1024 from rommapp/misc/refactor-scan-process
misc: Refactor scan process by splitting single function
2024-07-25 15:05:15 -03:00
Georges-Antoine Assi
92b23656aa start making collecitons public 2024-07-25 13:49:43 -04:00
Michael Manganiello
2bfc3c4c7e misc: Refactor scan process by splitting single function
This change mainly refactors the `scan_platforms` function, moving part
of its logic to `_identify_platform`, `_identify_firmware`, and
`_identify_rom`.

The logic is simpler this way, each smaller function returns `ScanStats`
that can be merged by the caller, and it simplifies future performance
improvements.
2024-07-25 10:29:46 -03:00
Georges-Antoine Assi
e7e37f4680 Merge pull request #1021 from rommapp/misc/replace-pytest-vcr-with-pytest-recording
misc: Replace pytest-vcr dependency with pytest-recording
2024-07-24 17:57:17 -04:00
Michael Manganiello
959e896aa3 misc: Replace pytest-vcr dependency with pytest-recording
`pytest-vcr` [1] is no longer maintained (last commit was in 2020), and
`VCR.py` recommends [2] `pytest-recording` instead.

Also, `pytest-vcr` does not correctly support `httpx` [3].

This change also removes unused cassettes.

[1] https://github.com/ktosiek/pytest-vcr
[2] https://vcrpy.readthedocs.io/en/latest/usage.html#pytest-integration
[3] https://github.com/ktosiek/pytest-vcr/issues/46
2024-07-24 12:39:41 -03:00
Michael Manganiello
158b16c2c1 Merge pull request #1017 from rommapp/misc/migrate-filesystem-resource-handler-to-async
misc: Migrate filesystem resource handler to async
2024-07-24 11:06:59 -03:00
Michael Manganiello
56066d6765 misc: Migrate filesystem resource handler to async
For filesystem resource handler, `requests` calls have been replaced
with `httpx`, and file I/O has been replaced with `anyio` utils.

The existing approach to save covers and screenshots, by calling
`shutil.copyfileobj` with the raw response is no longer needed. `httpx`
does not provide a file-like object when streaming [1], so there's no
easy drop-in replacement.

However, the applied solution correctly builds the file iteratively, by
consuming the response in chunks.

[1] https://github.com/encode/httpx/discussions/2296
2024-07-24 00:18:17 -03:00
Georges-Antoine Assi
c81fe52820 Merge pull request #1016 from TyroneSlothrop/patch-2
Update config.batocera-retrobat.yml
2024-07-23 21:00:17 -04:00
Tyrone Slothrop
cfd2e129a0 Update config.batocera-retrobat.yml
Updates after discovering all the extra cool icons already available (but not advertised in supported platforms!) and sorting.
2024-07-24 00:15:29 +01:00
Michael Manganiello
b9da72832d Merge pull request #1011 from rommapp/misc/migrate-moby-handler-to-async
misc: Migrate MobyGamesHandler to async
2024-07-23 11:10:27 -03:00
Michael Manganiello
7c6dfa8e50 feat: Use ContextVar to share httpx AsyncClient instance between requests 2024-07-23 01:29:32 -03:00
Georges-Antoine Assi
634e68eaf3 Merge pull request #1013 from TyroneSlothrop/patch-1
Create config.batocera-retrobat.yml
2024-07-22 17:10:21 -04:00
Georges-Antoine Assi
52a96058c4 Merge branch 'master' into patch-1 2024-07-22 16:57:24 -04:00
Tyrone Slothrop
bb01cf62cc Create config.batocera-retrobat.yml
Creates an example config file for Batocera/RetroBat-based mappings, as popular distributions so should hopefully save people a few hours.

Tested with a setup using RetroBat v6.0.3 folder structures, and only keeping matches for which I'm certain.
2024-07-22 21:50:53 +01:00
Michael Manganiello
6d8a8714f5 misc: Migrate MobyGamesHandler to async
Convert `MobyGamesHandler` methods to be asynchronous, and use an
`httpx` async client, instead of `requests` sync client.
2024-07-22 01:09:36 -03:00
Michael Manganiello
e1cec57c55 Merge pull request #1010 from rommapp/misc/add-async-cache
misc: Add Redis async cache
2024-07-21 21:57:44 -03:00
Michael Manganiello
6eb8e6aeff misc: Add Redis async cache
Introduce an asynchronous Redis instance to be used in async functions.
Also, this change migrates most of the sync cache usage to the new async
cache.
2024-07-21 18:23:19 -03:00
Michael Manganiello
0a7fd2a515 Merge pull request #1009 from rommapp/fix/use-specific-session-cookie-name
fix: Use namespaced cookie for session
2024-07-21 01:12:41 -03:00
Michael Manganiello
1ce20cdcfc fix: Use namespaced cookie for session
Avoid conflicting cookie names when RomM runs in the same host as other
applications, by adding a `romm_` namespace to the session cookie.
2024-07-20 21:06:28 -03:00
Zurdi
0eac452377 Merge pull request #989 from rommapp/master
v3.3.0
3.3.0
2024-07-19 23:25:16 +02:00
Zurdi
dd4f9e4c63 Merge pull request #1008 from rommapp/catch-json-decode-errs-0022
Catch and ignore json decode errors in 0022 migration
2024-07-19 17:29:48 +02:00
Georges-Antoine Assi
db1787dff4 fix trunk issues 2024-07-18 22:03:08 -04:00
Georges-Antoine Assi
77afe55625 add support for extracting content in compressed files 2024-07-18 21:50:24 -04:00
Georges-Antoine Assi
bfeddcf623 Catch and ignore json decode errors in migration 2024-07-18 21:01:57 -04:00
Georges-Antoine Assi
591e41a4d5 start checking for specific file exts 2024-07-18 20:51:48 -04:00
Georges-Antoine Assi
3073e16ca9 Merge pull request #1006 from adamantike/fix/handle-switch-titledb-empty-product-id
fix: Filter Switch titledb entries with empty id
2024-07-18 10:15:11 -04:00
Michael Manganiello
04b64f1d97 fix: Filter Switch titledb entries with empty id
The existing code was failing after changes on the upstream JSON file
that included entries with `null` ID.
2024-07-18 11:00:30 -03:00
Georges-Antoine Assi
2e91c440e3 Read into mem in chunks 2024-07-16 17:42:25 -04:00
Zurdi
27c5749ac5 Merge pull request #1004 from rommapp/romm-1003
[ROMM-1003] Fix aborting mid-scan
2024-07-16 08:27:56 +02:00
Georges-Antoine Assi
2b2ff875ee Calculate hashes for rom files 2024-07-15 18:27:29 -04:00
Georges-Antoine Assi
6ec091e5da [ROMM-1003] Fix aborting mid-scan 2024-07-15 13:08:52 -04:00