summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar √Čtienne Deparis 2020-01-28 13:31:45 +0100
committerGravatar √Čtienne Deparis 2020-01-28 13:31:45 +0100
commit0975d07ef23f01ff907a0fc36975d44fd4f24867 (patch)
tree8b8ea3ac0962ef137438b4c5baef36507be2eed7
parent89d66a33876b895eb203a1854285cfcfa6396450 (diff)
downloadeshelf-0975d07ef23f01ff907a0fc36975d44fd4f24867.tar.gz
eshelf-0975d07ef23f01ff907a0fc36975d44fd4f24867.tar.xz
eshelf-0975d07ef23f01ff907a0fc36975d44fd4f24867.zip
Fix database closing workflow
-rw-r--r--eshelf/cli.py4
-rw-r--r--eshelf/reader_orm.py3
2 files changed, 4 insertions, 3 deletions
diff --git a/eshelf/cli.py b/eshelf/cli.py
index 9815c99..7c83e84 100644
--- a/eshelf/cli.py
+++ b/eshelf/cli.py
@@ -66,8 +66,6 @@ class EShelfCli:
self.reader_db = ReaderOrm(
os.path.join(self.reader_mount_point, 'system', 'library')
)
- if self.reader_db is None:
- sys.exit(1)
self.remote_physical_path = self.config.get(
'remote_physical_path', '/mnt/fat'
@@ -77,7 +75,7 @@ class EShelfCli:
self.bye()
def bye(self, return_code=0):
- if self.reader_db is not None:
+ if self.reader_db.is_opened():
self.reader_db.close()
sys.exit(return_code)
diff --git a/eshelf/reader_orm.py b/eshelf/reader_orm.py
index 3e971bc..1055304 100644
--- a/eshelf/reader_orm.py
+++ b/eshelf/reader_orm.py
@@ -16,6 +16,9 @@ class ReaderOrm:
return None
return reader_db
+ def is_opened(self):
+ return self.reader_db is not None
+
def close(self):
if self.reader_db is not None:
self.reader_db.close()