feat: Introduce robust database initialization, versioning, and seed synchronization for initial setup and updates in frozen applications.
This commit is contained in:
@@ -6,7 +6,7 @@ a = Analysis(
|
|||||||
pathex=[],
|
pathex=[],
|
||||||
binaries=[],
|
binaries=[],
|
||||||
datas=[('images', 'images'), ('database/umamusume_seed.db', 'database'), ('version.py', '.'), ('updater', 'updater')],
|
datas=[('images', 'images'), ('database/umamusume_seed.db', 'database'), ('version.py', '.'), ('updater', 'updater')],
|
||||||
hiddenimports=['requests'],
|
hiddenimports=['requests', 'PIL', 'PIL._tkinter_finder'],
|
||||||
hookspath=[],
|
hookspath=[],
|
||||||
hooksconfig={},
|
hooksconfig={},
|
||||||
runtime_hooks=[],
|
runtime_hooks=[],
|
||||||
@@ -23,13 +23,13 @@ exe = EXE(
|
|||||||
a.datas,
|
a.datas,
|
||||||
[],
|
[],
|
||||||
name='UmamusumeCardManager',
|
name='UmamusumeCardManager',
|
||||||
debug=False,
|
debug=True,
|
||||||
bootloader_ignore_signals=False,
|
bootloader_ignore_signals=False,
|
||||||
strip=False,
|
strip=False,
|
||||||
upx=True,
|
upx=False,
|
||||||
upx_exclude=[],
|
upx_exclude=[],
|
||||||
runtime_tmpdir=None,
|
runtime_tmpdir=None,
|
||||||
console=False,
|
console=True,
|
||||||
disable_windowed_traceback=False,
|
disable_windowed_traceback=False,
|
||||||
argv_emulation=False,
|
argv_emulation=False,
|
||||||
target_arch=None,
|
target_arch=None,
|
||||||
|
|||||||
Binary file not shown.
@@ -108,7 +108,8 @@ def check_for_updates():
|
|||||||
cleanup_orphaned_data()
|
cleanup_orphaned_data()
|
||||||
|
|
||||||
except Exception as e:
|
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):
|
def sync_from_seed(seed_path):
|
||||||
"""Merge new data from seed into user database"""
|
"""Merge new data from seed into user database"""
|
||||||
@@ -195,12 +196,12 @@ def sync_from_seed(seed_path):
|
|||||||
""")
|
""")
|
||||||
seed_events = cur.fetchall()
|
seed_events = cur.fetchall()
|
||||||
|
|
||||||
# Prepare Skill map: seed_event_id -> list of (skill_name)
|
# Prepare Skill map: seed_event_id -> list of (skill_name, is_gold, is_or)
|
||||||
cur.execute("SELECT event_id, skill_name FROM seed.event_skills")
|
cur.execute("SELECT event_id, skill_name, is_gold, is_or FROM seed.event_skills")
|
||||||
seed_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] = []
|
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
|
# Main Card Map: gametora_url -> main_card_id
|
||||||
cur.execute("SELECT gametora_url, card_id FROM main.support_cards")
|
cur.execute("SELECT gametora_url, card_id FROM main.support_cards")
|
||||||
@@ -216,9 +217,9 @@ def sync_from_seed(seed_path):
|
|||||||
|
|
||||||
# Insert Skills
|
# Insert Skills
|
||||||
if seed_ev_id in seed_skills:
|
if seed_ev_id in seed_skills:
|
||||||
for sk_name in seed_skills[seed_ev_id]:
|
for sk_name, is_gold, is_or in seed_skills[seed_ev_id]:
|
||||||
cur.execute("INSERT INTO main.event_skills (event_id, skill_name) VALUES (?, ?)",
|
cur.execute("INSERT INTO main.event_skills (event_id, skill_name, is_gold, is_or) VALUES (?, ?, ?, ?)",
|
||||||
(new_event_id, sk_name))
|
(new_event_id, sk_name, is_gold, is_or))
|
||||||
|
|
||||||
cur.execute("PRAGMA foreign_keys = ON")
|
cur.execute("PRAGMA foreign_keys = ON")
|
||||||
conn.commit()
|
conn.commit()
|
||||||
|
|||||||
24
main.py
24
main.py
@@ -14,7 +14,17 @@ def run_scraper():
|
|||||||
from scraper.gametora_scraper import run_scraper as scrape
|
from scraper.gametora_scraper import run_scraper as scrape
|
||||||
scrape()
|
scrape()
|
||||||
except Exception as e:
|
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)
|
sys.exit(1)
|
||||||
|
|
||||||
def run_gui():
|
def run_gui():
|
||||||
@@ -23,7 +33,17 @@ def run_gui():
|
|||||||
app = MainWindow()
|
app = MainWindow()
|
||||||
app.run()
|
app.run()
|
||||||
except Exception as e:
|
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)
|
sys.exit(1)
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ This file is the single source of truth for the application version.
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
# Semantic versioning: MAJOR.MINOR.PATCH
|
# Semantic versioning: MAJOR.MINOR.PATCH
|
||||||
VERSION: str = "7.0.0"
|
VERSION: str = "12.1.0"
|
||||||
|
|
||||||
# Application metadata
|
# Application metadata
|
||||||
APP_NAME: str = "UmamusumeCardManager"
|
APP_NAME: str = "UmamusumeCardManager"
|
||||||
|
|||||||
Reference in New Issue
Block a user