test windows
This commit is contained in:
@@ -71,6 +71,14 @@ config.init_font()
|
|||||||
config.screen_width, config.screen_height = pygame.display.get_surface().get_size()
|
config.screen_width, config.screen_height = pygame.display.get_surface().get_size()
|
||||||
logger.debug(f"Résolution d'écran : {config.screen_width}x{config.screen_height}")
|
logger.debug(f"Résolution d'écran : {config.screen_width}x{config.screen_height}")
|
||||||
|
|
||||||
|
|
||||||
|
# Vérification des dossiers pour le débogage
|
||||||
|
logger.debug(f"SYSTEM_FOLDER: {config.SYSTEM_FOLDER}")
|
||||||
|
logger.debug(f"ROMS_FOLDER: {config.ROMS_FOLDER}")
|
||||||
|
logger.debug(f"SAVE_FOLDER: {config.SAVE_FOLDER}")
|
||||||
|
logger.debug(f"APP_FOLDER: {config.APP_FOLDER}")
|
||||||
|
|
||||||
|
|
||||||
# Initialisation des variables de grille
|
# Initialisation des variables de grille
|
||||||
config.current_page = 0
|
config.current_page = 0
|
||||||
config.selected_platform = 0
|
config.selected_platform = 0
|
||||||
|
|||||||
57
config.py
57
config.py
@@ -1,19 +1,62 @@
|
|||||||
import pygame # type: ignore
|
import pygame # type: ignore
|
||||||
import os
|
import os
|
||||||
|
import sys
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
# Version actuelle de l'application
|
# Version actuelle de l'application
|
||||||
app_version = "1.9.7.7"
|
app_version = "1.9.7.7"
|
||||||
|
|
||||||
|
def get_application_root():
|
||||||
|
"""Détermine le dossier de l'application de manière portable."""
|
||||||
|
try:
|
||||||
|
# Obtenir le chemin absolu du fichier config.py
|
||||||
|
current_file = os.path.abspath(__file__)
|
||||||
|
# Remonter au dossier parent de config.py (par exemple, dossier de l'application)
|
||||||
|
app_root = os.path.dirname(os.path.dirname(current_file))
|
||||||
|
return app_root
|
||||||
|
except NameError:
|
||||||
|
# Si __file__ n'est pas défini (par exemple, exécution dans un REPL)
|
||||||
|
return os.path.abspath(os.getcwd())
|
||||||
|
|
||||||
|
def get_system_root():
|
||||||
|
"""Détermine le dossier racine du système de fichiers (par exemple, /userdata ou C:\\)."""
|
||||||
|
try:
|
||||||
|
if sys.platform.startswith("win"):
|
||||||
|
# Sur Windows, extraire la lettre de disque
|
||||||
|
current_path = os.path.abspath(__file__)
|
||||||
|
drive, _ = os.path.splitdrive(current_path)
|
||||||
|
system_root = drive + os.sep
|
||||||
|
return system_root
|
||||||
|
else:
|
||||||
|
# Sur Linux/Batocera, remonter jusqu'à atteindre /userdata ou /
|
||||||
|
current_path = os.path.abspath(__file__)
|
||||||
|
current_dir = current_path
|
||||||
|
while current_dir != os.path.dirname(current_dir): # Tant qu'on peut remonter
|
||||||
|
parent_dir = os.path.dirname(current_dir)
|
||||||
|
if os.path.basename(parent_dir) == "userdata": # Vérifier si le parent est userdata
|
||||||
|
system_root = parent_dir
|
||||||
|
return system_root
|
||||||
|
current_dir = parent_dir
|
||||||
|
# Si userdata n'est pas trouvé, retourner /
|
||||||
|
return "/"
|
||||||
|
except NameError:
|
||||||
|
# Si __file__ n'est pas défini, utiliser le répertoire de travail actuel
|
||||||
|
return "/" if not sys.platform.startswith("win") else os.path.splitdrive(os.getcwd())[0] + os.sep
|
||||||
|
|
||||||
# Chemins de base
|
# Chemins de base
|
||||||
SYSTEM_FOLDER = "/userdata"
|
SYSTEM_FOLDER = get_system_root()
|
||||||
|
APP_FOLDER = os.path.join(get_application_root(), "RGSX")
|
||||||
ROMS_FOLDER = os.path.join(SYSTEM_FOLDER, "roms")
|
ROMS_FOLDER = os.path.join(SYSTEM_FOLDER, "roms")
|
||||||
APP_FOLDER = os.path.join(ROMS_FOLDER, "ports", "RGSX")
|
SAVE_FOLDER = os.path.join(SYSTEM_FOLDER, "saves", "ports", "rgsx")
|
||||||
|
|
||||||
|
# Configuration du logging
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
log_dir = os.path.join(APP_FOLDER, "logs")
|
||||||
|
log_file = os.path.join(log_dir, "RGSX.log")
|
||||||
|
|
||||||
|
# Chemins de base
|
||||||
UPDATE_FOLDER = os.path.join(APP_FOLDER, "update")
|
UPDATE_FOLDER = os.path.join(APP_FOLDER, "update")
|
||||||
GAMELISTXML = os.path.join(APP_FOLDER, "gamelist.xml")
|
GAMELISTXML = os.path.join(APP_FOLDER, "gamelist.xml")
|
||||||
SAVE_FOLDER = os.path.join(SYSTEM_FOLDER, "saves", "ports", "rgsx")
|
|
||||||
IMAGES_FOLDER = os.path.join(APP_FOLDER, "images", "systemes")
|
IMAGES_FOLDER = os.path.join(APP_FOLDER, "images", "systemes")
|
||||||
GAMES_FOLDER = os.path.join(APP_FOLDER, "games")
|
GAMES_FOLDER = os.path.join(APP_FOLDER, "games")
|
||||||
CONTROLS_CONFIG_PATH = os.path.join(SAVE_FOLDER, "controls.json")
|
CONTROLS_CONFIG_PATH = os.path.join(SAVE_FOLDER, "controls.json")
|
||||||
@@ -21,13 +64,11 @@ HISTORY_PATH = os.path.join(SAVE_FOLDER, "history.json")
|
|||||||
LANGUAGE_CONFIG_PATH = os.path.join(SAVE_FOLDER, "language.json")
|
LANGUAGE_CONFIG_PATH = os.path.join(SAVE_FOLDER, "language.json")
|
||||||
JSON_EXTENSIONS = os.path.join(APP_FOLDER, "rom_extensions.json")
|
JSON_EXTENSIONS = os.path.join(APP_FOLDER, "rom_extensions.json")
|
||||||
|
|
||||||
# Configuration du logging
|
|
||||||
logger = logging.getLogger(__name__)
|
|
||||||
log_dir = os.path.join(APP_FOLDER, "logs")
|
|
||||||
log_file = os.path.join(log_dir, "RGSX.log")
|
|
||||||
|
|
||||||
# URL
|
# URL
|
||||||
OTA_SERVER_URL = "https://retrogamesets.fr/softs"
|
OTA_SERVER_URL = "https://retrogamesets.fr/softs/"
|
||||||
OTA_VERSION_ENDPOINT = os.path.join(OTA_SERVER_URL, "version.json")
|
OTA_VERSION_ENDPOINT = os.path.join(OTA_SERVER_URL, "version.json")
|
||||||
OTA_UPDATE_ZIP = os.path.join(OTA_SERVER_URL, "RGSX.zip")
|
OTA_UPDATE_ZIP = os.path.join(OTA_SERVER_URL, "RGSX.zip")
|
||||||
OTA_data_ZIP = os.path.join(OTA_SERVER_URL, "rgsx-data.zip")
|
OTA_data_ZIP = os.path.join(OTA_SERVER_URL, "rgsx-data.zip")
|
||||||
|
|||||||
20
network.py
20
network.py
@@ -1,6 +1,7 @@
|
|||||||
import requests
|
import requests
|
||||||
import subprocess
|
import subprocess
|
||||||
import os
|
import os
|
||||||
|
import sys
|
||||||
import threading
|
import threading
|
||||||
import pygame # type: ignore
|
import pygame # type: ignore
|
||||||
import zipfile
|
import zipfile
|
||||||
@@ -24,17 +25,28 @@ cache = {}
|
|||||||
CACHE_TTL = 3600 # 1 heure
|
CACHE_TTL = 3600 # 1 heure
|
||||||
|
|
||||||
def test_internet():
|
def test_internet():
|
||||||
|
"""Teste la connexion Internet de manière portable pour Windows et Linux/Batocera."""
|
||||||
logger.debug("Test de connexion Internet")
|
logger.debug("Test de connexion Internet")
|
||||||
|
|
||||||
|
# Choisir l'option ping en fonction de la plateforme
|
||||||
|
ping_option = '-n' if sys.platform.startswith("win") else '-c'
|
||||||
|
logger.debug(f"Utilisation de ping avec option {ping_option}")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
result = subprocess.run(['ping', '-c', '4', '8.8.8.8'], capture_output=True, text=True, timeout=5)
|
result = subprocess.run(
|
||||||
|
['ping', ping_option, '4', '8.8.8.8'],
|
||||||
|
capture_output=True,
|
||||||
|
text=True,
|
||||||
|
timeout=5
|
||||||
|
)
|
||||||
if result.returncode == 0:
|
if result.returncode == 0:
|
||||||
logger.debug("Connexion Internet OK")
|
logger.debug("Connexion Internet OK (ping)")
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
logger.debug("Échec ping 8.8.8.8")
|
logger.debug(f"Échec ping 8.8.8.8, code retour: {result.returncode}")
|
||||||
return False
|
return False
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.debug(f"Erreur test Internet: {str(e)}")
|
logger.debug(f"Erreur test Internet (ping): {str(e)}")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user