1
0
Fork 0
mirror of https://codeberg.org/Mo8it/AdvLabDB.git synced 2024-09-19 18:31:16 +00:00

Wrap everything in a try-except… If you read this, consider rewriting in Rust!

This commit is contained in:
Mo 2023-11-03 22:10:33 +01:00
parent 91f0effd3a
commit 26a8785d7a

View file

@ -25,10 +25,13 @@ def backup(backup_prefix):
now = datetime.now().strftime("%d_%m_%Y_%H_%M_%S") now = datetime.now().strftime("%d_%m_%Y_%H_%M_%S")
dest = db_bk_dir / f"{backup_prefix}_{now}.sqlite" dest = db_bk_dir / f"{backup_prefix}_{now}.sqlite"
try:
status = subprocess.run(["sqlite3", db_path, f".backup {dest}"], check=False).returncode status = subprocess.run(["sqlite3", db_path, f".backup {dest}"], check=False).returncode
if status == 0: if status == 0:
flash(f"Created a database backup at the path {dest}", "success") flash(f"Created a database backup at the path {dest}", "success")
else: else:
flash("Failed to create a database backup!", "danger")
except:
flash("Failed to create a database backup! Make sure that `sqlite3` is installed on your system!", "danger") flash("Failed to create a database backup! Make sure that `sqlite3` is installed on your system!", "danger")