mirror of
https://github.com/rommapp/romm.git
synced 2026-06-28 14:56:01 +00:00
Merge pull request #2228 from rommapp/misc/remove-emoji-dependency
misc: Replace emoji dependency with constants
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
import asyncio
|
||||
|
||||
import emoji
|
||||
from decorators.auth import protected_route
|
||||
from endpoints.responses.search import SearchCoverSchema, SearchRomSchema
|
||||
from exceptions.endpoint_exceptions import SGDBInvalidAPIKeyException
|
||||
@@ -21,6 +20,7 @@ from handler.scan_handler import get_main_platform_igdb_id
|
||||
from logger.formatter import BLUE, CYAN
|
||||
from logger.formatter import highlight as hl
|
||||
from logger.logger import log
|
||||
from utils import emoji
|
||||
from utils.router import APIRouter
|
||||
|
||||
router = APIRouter(
|
||||
@@ -66,15 +66,13 @@ async def search_rom(
|
||||
return []
|
||||
|
||||
log.info(
|
||||
emoji.emojize(":magnifying_glass_tilted_right: Searching metadata providers...")
|
||||
f"{emoji.EMOJI_MAGNIFYING_GLASS_TILTED_RIGHT} Searching metadata providers..."
|
||||
)
|
||||
matched_roms: list = []
|
||||
|
||||
log.info(f"Searching by {hl(search_by.lower(), color=CYAN)}:")
|
||||
log.info(
|
||||
emoji.emojize(
|
||||
f":video_game: {hl(rom.platform_display_name, color=BLUE)} [{rom.platform_fs_slug}]: {hl(search_term)}[{rom.fs_name}]"
|
||||
)
|
||||
f"{emoji.EMOJI_VIDEO_GAME} {hl(rom.platform_display_name, color=BLUE)} [{rom.platform_fs_slug}]: {hl(search_term)}[{rom.fs_name}]"
|
||||
)
|
||||
|
||||
igdb_matched_roms: list[IGDBRom] = []
|
||||
|
||||
@@ -4,7 +4,6 @@ from dataclasses import dataclass
|
||||
from itertools import batched
|
||||
from typing import Any, Final
|
||||
|
||||
import emoji
|
||||
import socketio # type: ignore
|
||||
from config import DEV_MODE, REDIS_URL, SCAN_TIMEOUT
|
||||
from endpoints.responses.platform import PlatformSchema
|
||||
@@ -39,6 +38,7 @@ from models.rom import Rom, RomFile
|
||||
from rq import Worker
|
||||
from rq.job import Job
|
||||
from sqlalchemy.inspection import inspect
|
||||
from utils import emoji
|
||||
from utils.context import initialize_context
|
||||
|
||||
STOP_SCAN_FLAG: Final = "scan:stop"
|
||||
@@ -363,9 +363,7 @@ async def _identify_platform(
|
||||
|
||||
if len(fs_firmware) == 0:
|
||||
log.warning(
|
||||
emoji.emojize(
|
||||
f"{hl(':warning:', color=LIGHTYELLOW)} No firmware found for {hl(platform.custom_name or platform.name, color=BLUE)}[{hl(platform.fs_slug)}]"
|
||||
)
|
||||
f"{hl(emoji.EMOJI_WARNING, color=LIGHTYELLOW)} No firmware found for {hl(platform.custom_name or platform.name, color=BLUE)}[{hl(platform.fs_slug)}]"
|
||||
)
|
||||
else:
|
||||
log.info(f"{hl(str(len(fs_firmware)))} firmware files found")
|
||||
@@ -385,9 +383,7 @@ async def _identify_platform(
|
||||
|
||||
if len(fs_roms) == 0:
|
||||
log.warning(
|
||||
emoji.emojize(
|
||||
f"{hl(':warning:', color=LIGHTYELLOW)} No roms found, verify that the folder structure is correct"
|
||||
)
|
||||
f"{hl(emoji.EMOJI_WARNING, color=LIGHTYELLOW)} No roms found, verify that the folder structure is correct"
|
||||
)
|
||||
else:
|
||||
log.info(f"{hl(str(len(fs_roms)))} roms found in the file system")
|
||||
@@ -464,7 +460,7 @@ async def scan_platforms(
|
||||
scan_stats = ScanStats()
|
||||
|
||||
async def stop_scan():
|
||||
log.info(emoji.emojize(":stop_sign: Scan stopped manually"))
|
||||
log.info(f"{emoji.EMOJI_STOP_SIGN} Scan stopped manually")
|
||||
await sm.emit("scan:done", scan_stats.__dict__)
|
||||
redis_client.delete(STOP_SCAN_FLAG)
|
||||
|
||||
@@ -478,10 +474,8 @@ async def scan_platforms(
|
||||
|
||||
if len(platform_list) == 0:
|
||||
log.warning(
|
||||
emoji.emojize(
|
||||
f"{hl(':warning:', color=LIGHTYELLOW)} No platforms found, verify that the folder structure is right and the volume is mounted correctly. \
|
||||
Check https://github.com/rommapp/romm?tab=readme-ov-file#folder-structure for more details."
|
||||
)
|
||||
f"{hl(emoji.EMOJI_WARNING, color=LIGHTYELLOW)} No platforms found, verify that the folder structure is right and the volume is mounted correctly."
|
||||
"Check https://github.com/rommapp/romm?tab=readme-ov-file#folder-structure for more details."
|
||||
)
|
||||
else:
|
||||
log.info(
|
||||
@@ -504,7 +498,7 @@ async def scan_platforms(
|
||||
for p in missed_platforms:
|
||||
log.warning(f" - {p.slug}")
|
||||
|
||||
log.info(emoji.emojize(":check_mark: Scan completed "))
|
||||
log.info(f"{emoji.EMOJI_CHECK_MARK} Scan completed")
|
||||
await sm.emit("scan:done", scan_stats.__dict__)
|
||||
except ScanStoppedException:
|
||||
await stop_scan()
|
||||
@@ -524,7 +518,7 @@ async def scan_handler(_sid: str, options: dict[str, Any]):
|
||||
options (dict): Socket options
|
||||
"""
|
||||
|
||||
log.info(emoji.emojize(":magnifying_glass_tilted_right: Scanning"))
|
||||
log.info(f"{emoji.EMOJI_MAGNIFYING_GLASS_TILTED_RIGHT} Scanning")
|
||||
|
||||
platform_ids = options.get("platforms", [])
|
||||
scan_type = ScanType[options.get("type", "quick").upper()]
|
||||
@@ -553,12 +547,12 @@ async def scan_handler(_sid: str, options: dict[str, Any]):
|
||||
async def stop_scan_handler(_sid: str):
|
||||
"""Stop scan socket endpoint"""
|
||||
|
||||
log.info(emoji.emojize(":stop_button: Stop scan requested..."))
|
||||
log.info(f"{emoji.EMOJI_STOP_BUTTON} Stop scan requested...")
|
||||
|
||||
async def cancel_job(job: Job):
|
||||
job.cancel()
|
||||
redis_client.set(STOP_SCAN_FLAG, 1)
|
||||
log.info(emoji.emojize(":stop_button: Job found, stopping scan..."))
|
||||
log.info(f"{emoji.EMOJI_STOP_BUTTON} Job found, stopping scan...")
|
||||
|
||||
existing_jobs = high_prio_queue.get_jobs()
|
||||
for job in existing_jobs:
|
||||
@@ -575,4 +569,4 @@ async def stop_scan_handler(_sid: str):
|
||||
):
|
||||
return await cancel_job(current_job)
|
||||
|
||||
log.info(emoji.emojize(":stop_button: No running scan to stop"))
|
||||
log.info(f"{emoji.EMOJI_STOP_BUTTON} No running scan to stop")
|
||||
|
||||
@@ -2,7 +2,6 @@ import asyncio
|
||||
import enum
|
||||
from typing import Any
|
||||
|
||||
import emoji
|
||||
from config.config_manager import config_manager as cm
|
||||
from handler.database import db_platform_handler
|
||||
from handler.filesystem import fs_asset_handler, fs_firmware_handler
|
||||
@@ -34,6 +33,7 @@ from models.firmware import Firmware
|
||||
from models.platform import Platform
|
||||
from models.rom import Rom
|
||||
from models.user import User
|
||||
from utils import emoji
|
||||
|
||||
LOGGER_MODULE_NAME = {"module_name": "scan"}
|
||||
|
||||
@@ -170,16 +170,12 @@ async def scan_platform(
|
||||
or tgdb_platform["tgdb_id"]
|
||||
):
|
||||
log.info(
|
||||
emoji.emojize(
|
||||
f"Folder {hl(platform_attrs['slug'])}[{hl(fs_slug, color=LIGHTYELLOW)}] identified as {hl(platform_attrs['name'], color=BLUE)} :video_game:"
|
||||
),
|
||||
f"Folder {hl(platform_attrs['slug'])}[{hl(fs_slug, color=LIGHTYELLOW)}] identified as {hl(platform_attrs['name'], color=BLUE)} {emoji.EMOJI_VIDEO_GAME}",
|
||||
extra={"module_name": "scan"},
|
||||
)
|
||||
else:
|
||||
log.warning(
|
||||
emoji.emojize(
|
||||
f"Platform {hl(platform_attrs['slug'])} not identified :cross_mark:"
|
||||
),
|
||||
f"Platform {hl(platform_attrs['slug'])} not identified {emoji.EMOJI_CROSS_MARK}",
|
||||
extra=LOGGER_MODULE_NAME,
|
||||
)
|
||||
|
||||
@@ -368,10 +364,8 @@ async def scan_rom(
|
||||
h_igdb_id = hasheous_rom.get("igdb_id")
|
||||
if h_igdb_id:
|
||||
log.debug(
|
||||
emoji.emojize(
|
||||
f"{hl(rom_attrs['fs_name'])} identified by Hasheous as "
|
||||
f"{hl(str(h_igdb_id), color=BLUE)} :alien_monster:"
|
||||
),
|
||||
f"{hl(rom_attrs['fs_name'])} identified by Hasheous as "
|
||||
f"{hl(str(h_igdb_id), color=BLUE)} {emoji.EMOJI_ALIEN_MONSTER}",
|
||||
extra=LOGGER_MODULE_NAME,
|
||||
)
|
||||
return await meta_igdb_handler.get_rom_by_id(h_igdb_id)
|
||||
@@ -379,10 +373,8 @@ async def scan_rom(
|
||||
# Use Playmatch matches to get the IGDB ID
|
||||
if playmatch_rom["igdb_id"] is not None:
|
||||
log.debug(
|
||||
emoji.emojize(
|
||||
f"{hl(rom_attrs['fs_name'])} identified by Playmatch as "
|
||||
f"{hl(str(playmatch_rom["igdb_id"]), color=BLUE)} :alien_monster:"
|
||||
),
|
||||
f"{hl(rom_attrs['fs_name'])} identified by Playmatch as "
|
||||
f"{hl(str(playmatch_rom["igdb_id"]), color=BLUE)} {emoji.EMOJI_ALIEN_MONSTER}",
|
||||
extra=LOGGER_MODULE_NAME,
|
||||
)
|
||||
|
||||
@@ -475,10 +467,8 @@ async def scan_rom(
|
||||
h_ra_id = hasheous_rom.get("ra_id")
|
||||
if h_ra_id:
|
||||
log.debug(
|
||||
emoji.emojize(
|
||||
f"{hl(rom_attrs['fs_name'])} identified by Hasheous as "
|
||||
f"{hl(str(h_ra_id), color=BLUE)} :alien_monster:"
|
||||
),
|
||||
f"{hl(rom_attrs['fs_name'])} identified by Hasheous as "
|
||||
f"{hl(str(h_ra_id), color=BLUE)} {emoji.EMOJI_ALIEN_MONSTER}",
|
||||
extra=LOGGER_MODULE_NAME,
|
||||
)
|
||||
return await meta_ra_handler.get_rom_by_id(rom=rom, ra_id=h_ra_id)
|
||||
@@ -602,7 +592,7 @@ async def scan_rom(
|
||||
and not hasheous_handler_rom.get("hasheous_id")
|
||||
):
|
||||
log.warning(
|
||||
emoji.emojize(f"{hl(rom_attrs['fs_name'])} not identified :cross_mark:"),
|
||||
f"{hl(rom_attrs['fs_name'])} not identified {emoji.EMOJI_CROSS_MARK}",
|
||||
extra=LOGGER_MODULE_NAME,
|
||||
)
|
||||
return Rom(**rom_attrs)
|
||||
@@ -634,9 +624,7 @@ async def scan_rom(
|
||||
rom_attrs.update({**sgdb_hander_rom})
|
||||
|
||||
log.info(
|
||||
emoji.emojize(
|
||||
f"{hl(rom_attrs['fs_name'])} identified as {hl(rom_attrs['name'], color=BLUE)} :alien_monster:"
|
||||
),
|
||||
f"{hl(rom_attrs['fs_name'])} identified as {hl(rom_attrs['name'], color=BLUE)} {emoji.EMOJI_ALIEN_MONSTER}",
|
||||
extra=LOGGER_MODULE_NAME,
|
||||
)
|
||||
if rom.multi:
|
||||
|
||||
8
backend/utils/emoji.py
Normal file
8
backend/utils/emoji.py
Normal file
@@ -0,0 +1,8 @@
|
||||
EMOJI_ALIEN_MONSTER = "👾"
|
||||
EMOJI_CHECK_MARK = "✔\ufe0f"
|
||||
EMOJI_CROSS_MARK = "❌"
|
||||
EMOJI_MAGNIFYING_GLASS_TILTED_RIGHT = "🔎"
|
||||
EMOJI_STOP_BUTTON = "⏹\ufe0f"
|
||||
EMOJI_STOP_SIGN = "🛑"
|
||||
EMOJI_VIDEO_GAME = "🎮"
|
||||
EMOJI_WARNING = "⚠\ufe0f"
|
||||
@@ -20,7 +20,6 @@ dependencies = [
|
||||
"authlib ~= 1.3",
|
||||
"colorama ~= 0.4",
|
||||
"defusedxml ~= 0.7.1",
|
||||
"emoji == 2.10.1",
|
||||
"fastapi-pagination[sqlalchemy] ~= 0.12",
|
||||
"fastapi[standard-no-fastapi-cloud-cli] ~= 0.116",
|
||||
"gunicorn == 23.0.0",
|
||||
|
||||
11
uv.lock
generated
11
uv.lock
generated
@@ -421,15 +421,6 @@ wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/d7/ee/bf0adb559ad3c786f12bcbc9296b3f5675f529199bef03e2df281fa1fadb/email_validator-2.2.0-py3-none-any.whl", hash = "sha256:561977c2d73ce3611850a06fa56b414621e0c8faa9d66f2611407d87465da631", size = 33521, upload-time = "2024-06-20T11:30:28.248Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "emoji"
|
||||
version = "2.10.1"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/6c/5c/486737f2f26b9a3f684cfe2f642b618d79635905513f1d14a265f3b47b70/emoji-2.10.1.tar.gz", hash = "sha256:16287283518fb7141bde00198f9ffff4e1c1cb570efb68b2f1ec50975c3a581d", size = 428315, upload-time = "2024-01-31T12:58:27.778Z" }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/98/00/00d56e704d69cee4a92b1d517676579b4af5f2f8bc72946c464a504705b2/emoji-2.10.1-py2.py3-none-any.whl", hash = "sha256:11fb369ea79d20c14efa4362c732d67126df294a7959a2c98bfd7447c12a218e", size = 421524, upload-time = "2024-01-31T12:58:25.439Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "executing"
|
||||
version = "2.2.0"
|
||||
@@ -1752,7 +1743,6 @@ dependencies = [
|
||||
{ name = "authlib" },
|
||||
{ name = "colorama" },
|
||||
{ name = "defusedxml" },
|
||||
{ name = "emoji" },
|
||||
{ name = "fastapi", extra = ["standard-no-fastapi-cloud-cli"] },
|
||||
{ name = "fastapi-pagination", extra = ["sqlalchemy"] },
|
||||
{ name = "gunicorn" },
|
||||
@@ -1814,7 +1804,6 @@ requires-dist = [
|
||||
{ name = "authlib", specifier = "~=1.3" },
|
||||
{ name = "colorama", specifier = "~=0.4" },
|
||||
{ name = "defusedxml", specifier = "~=0.7.1" },
|
||||
{ name = "emoji", specifier = "==2.10.1" },
|
||||
{ name = "fakeredis", marker = "extra == 'test'", specifier = "~=2.21" },
|
||||
{ name = "fastapi", extras = ["standard-no-fastapi-cloud-cli"], specifier = "~=0.116" },
|
||||
{ name = "fastapi-pagination", extras = ["sqlalchemy"], specifier = "~=0.12" },
|
||||
|
||||
Reference in New Issue
Block a user