From 26a8785d7acc83043f31e1d9efab6fa619074414 Mon Sep 17 00:00:00 2001 From: mo8it Date: Fri, 3 Nov 2023 22:10:33 +0100 Subject: [PATCH] =?UTF-8?q?Wrap=20everything=20in=20a=20try-except?= =?UTF-8?q?=E2=80=A6=20If=20you=20read=20this,=20consider=20rewriting=20in?= =?UTF-8?q?=20Rust!?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- advlabdb/actions.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/advlabdb/actions.py b/advlabdb/actions.py index 62bbbb0..9489a79 100644 --- a/advlabdb/actions.py +++ b/advlabdb/actions.py @@ -25,10 +25,13 @@ def backup(backup_prefix): now = datetime.now().strftime("%d_%m_%Y_%H_%M_%S") dest = db_bk_dir / f"{backup_prefix}_{now}.sqlite" - status = subprocess.run(["sqlite3", db_path, f".backup {dest}"], check=False).returncode - if status == 0: - flash(f"Created a database backup at the path {dest}", "success") - else: + try: + status = subprocess.run(["sqlite3", db_path, f".backup {dest}"], check=False).returncode + if status == 0: + flash(f"Created a database backup at the path {dest}", "success") + 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")