feat: Introduce robust database initialization, versioning, and seed synchronization for initial setup and updates in frozen applications.

This commit is contained in:
kiyreload27
2025-12-31 16:57:16 +00:00
parent 04a2c1bcb3
commit d7d1318a55
5 changed files with 36 additions and 15 deletions

View File

@@ -6,7 +6,7 @@ a = Analysis(
pathex=[],
binaries=[],
datas=[('images', 'images'), ('database/umamusume_seed.db', 'database'), ('version.py', '.'), ('updater', 'updater')],
hiddenimports=['requests'],
hiddenimports=['requests', 'PIL', 'PIL._tkinter_finder'],
hookspath=[],
hooksconfig={},
runtime_hooks=[],
@@ -23,13 +23,13 @@ exe = EXE(
a.datas,
[],
name='UmamusumeCardManager',
debug=False,
debug=True,
bootloader_ignore_signals=False,
strip=False,
upx=True,
upx=False,
upx_exclude=[],
runtime_tmpdir=None,
console=False,
console=True,
disable_windowed_traceback=False,
argv_emulation=False,
target_arch=None,

Binary file not shown.

View File

@@ -108,7 +108,8 @@ def check_for_updates():
cleanup_orphaned_data()
except Exception as e:
print(f"Update check failed: {e}")
import traceback
print(f"Update check failed: {e}\n{traceback.format_exc()}")
def sync_from_seed(seed_path):
"""Merge new data from seed into user database"""
@@ -195,12 +196,12 @@ def sync_from_seed(seed_path):
""")
seed_events = cur.fetchall()
# Prepare Skill map: seed_event_id -> list of (skill_name)
cur.execute("SELECT event_id, skill_name FROM seed.event_skills")
# Prepare Skill map: seed_event_id -> list of (skill_name, is_gold, is_or)
cur.execute("SELECT event_id, skill_name, is_gold, is_or FROM seed.event_skills")
seed_skills = {}
for ev_id, sk_name in cur.fetchall():
for ev_id, sk_name, is_gold, is_or in cur.fetchall():
if ev_id not in seed_skills: seed_skills[ev_id] = []
seed_skills[ev_id].append(sk_name)
seed_skills[ev_id].append((sk_name, is_gold, is_or))
# Main Card Map: gametora_url -> main_card_id
cur.execute("SELECT gametora_url, card_id FROM main.support_cards")
@@ -216,9 +217,9 @@ def sync_from_seed(seed_path):
# Insert Skills
if seed_ev_id in seed_skills:
for sk_name in seed_skills[seed_ev_id]:
cur.execute("INSERT INTO main.event_skills (event_id, skill_name) VALUES (?, ?)",
(new_event_id, sk_name))
for sk_name, is_gold, is_or in seed_skills[seed_ev_id]:
cur.execute("INSERT INTO main.event_skills (event_id, skill_name, is_gold, is_or) VALUES (?, ?, ?, ?)",
(new_event_id, sk_name, is_gold, is_or))
cur.execute("PRAGMA foreign_keys = ON")
conn.commit()

24
main.py
View File

@@ -14,7 +14,17 @@ def run_scraper():
from scraper.gametora_scraper import run_scraper as scrape
scrape()
except Exception as e:
logging.error(f"An error occurred while running the scraper: {e}")
import traceback
error_msg = f"An error occurred while running the scraper:\n\n{e}\n\n{traceback.format_exc()}"
logging.error(error_msg)
try:
import tkinter as tk
from tkinter import messagebox
root = tk.Tk()
root.withdraw()
messagebox.showerror("Scraper Error", error_msg)
except:
pass
sys.exit(1)
def run_gui():
@@ -23,7 +33,17 @@ def run_gui():
app = MainWindow()
app.run()
except Exception as e:
logging.error(f"An error occurred while launching the GUI: {e}")
import traceback
error_msg = f"An error occurred while launching the GUI:\n\n{e}\n\n{traceback.format_exc()}"
logging.error(error_msg)
try:
import tkinter as tk
from tkinter import messagebox
root = tk.Tk()
root.withdraw()
messagebox.showerror("Application Error", error_msg)
except:
pass
sys.exit(1)
def main():

View File

@@ -4,7 +4,7 @@ This file is the single source of truth for the application version.
"""
# Semantic versioning: MAJOR.MINOR.PATCH
VERSION: str = "7.0.0"
VERSION: str = "12.1.0"
# Application metadata
APP_NAME: str = "UmamusumeCardManager"