fix random users json in compiled binaries
This commit is contained in:
parent
d7f25c7acd
commit
ea297da0c8
2 changed files with 14 additions and 2 deletions
|
|
@ -20,7 +20,7 @@ a = Analysis(
|
||||||
['disco-reaper.py'],
|
['disco-reaper.py'],
|
||||||
pathex=[],
|
pathex=[],
|
||||||
binaries=[],
|
binaries=[],
|
||||||
datas=[('src/first-info.md', 'src')],
|
datas=[('src/first-info.md', 'src'), ('src/random_users.json', 'src')],
|
||||||
hiddenimports=hiddenimports,
|
hiddenimports=hiddenimports,
|
||||||
hookspath=[],
|
hookspath=[],
|
||||||
hooksconfig={},
|
hooksconfig={},
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ import random
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Optional, Dict, Any
|
from typing import Optional, Dict, Any
|
||||||
import threading
|
import threading
|
||||||
|
import sys
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
@ -167,7 +168,18 @@ class MigrationDatabase:
|
||||||
|
|
||||||
def _generate_alias(self) -> str:
|
def _generate_alias(self) -> str:
|
||||||
"""Generates a unique alias in the format {Adjective}{Name} from random_users.json."""
|
"""Generates a unique alias in the format {Adjective}{Name} from random_users.json."""
|
||||||
|
# Robust path resolution for PyInstaller
|
||||||
|
if hasattr(sys, '_MEIPASS'):
|
||||||
|
# Running as a frozen bundle
|
||||||
|
json_path = Path(sys._MEIPASS) / "src" / "random_users.json"
|
||||||
|
else:
|
||||||
|
# Running in normal python environment (from src/core/)
|
||||||
json_path = Path(__file__).parent.parent / "random_users.json"
|
json_path = Path(__file__).parent.parent / "random_users.json"
|
||||||
|
|
||||||
|
if not json_path.exists():
|
||||||
|
logger.error(f"MigrationDatabase: random_users.json not found at {json_path}")
|
||||||
|
raise FileNotFoundError(f"Missing required resource: {json_path}")
|
||||||
|
|
||||||
with open(json_path, "r", encoding="utf-8") as f:
|
with open(json_path, "r", encoding="utf-8") as f:
|
||||||
data = json.load(f)
|
data = json.load(f)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue