aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rw-r--r--scripts/database.py8
-rw-r--r--scripts/exceptions.py4
-rwxr-xr-xscripts/initialize.py2
3 files changed, 14 insertions, 0 deletions
diff --git a/scripts/database.py b/scripts/database.py
index 18ed724..0c4abe9 100644
--- a/scripts/database.py
+++ b/scripts/database.py
@@ -3,6 +3,7 @@ import postgresql
import collections
import utils
+import exceptions
from conf import conf
def __git_describe__():
@@ -28,6 +29,13 @@ class database:
host = conf.db_host,
port = conf.db_port
)
+ # check if tables are present
+ tables = ('toolsgit', 'configurations', 'measure')
+ for tab in tables:
+ val = self.db.prepare("""SELECT COUNT(*) FROM pg_class
+ WHERE relname = $1""")(tab)[0][0]
+ if val < 1:
+ raise exceptions.DatabaseUninitialized()
def check_toolsgit(self):
"Return id of toolsgit row. If missing, it is inserted"
diff --git a/scripts/exceptions.py b/scripts/exceptions.py
index ec170ba..730664a 100644
--- a/scripts/exceptions.py
+++ b/scripts/exceptions.py
@@ -39,3 +39,7 @@ class ProcessFailed(Exception):
def __str__(self):
return "Process failed: " + str(self.process) + \
" with return code: " + str(self.returncode)
+
+class DatabaseUninitialized(Exception):
+ def __str__(self):
+ return "Database seems to be uninitialized."
diff --git a/scripts/initialize.py b/scripts/initialize.py
index 5171320..d4470b8 100755
--- a/scripts/initialize.py
+++ b/scripts/initialize.py
@@ -21,6 +21,8 @@ def all():
solution.generate()
except exceptions.NoSolution:
pass
+ # check if database is initialized
+ database.database()
def base():
print('Initialize base...')