summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorValerie R Young <spectranaut@riseup.net>2016-08-19 15:13:52 -0400
committerHolger Levsen <holger@layer-acht.org>2016-08-19 21:17:08 +0200
commit32f1504173923bf578786b0d6f586a04a4447310 (patch)
treea48bc3f7df41035e4814d4631781fff03505a6de /bin
parentb1b64d98e5971437abb3fe793f6fb58eab1ef4fd (diff)
downloadjenkins.debian.net-32f1504173923bf578786b0d6f586a04a4447310.tar.xz
reproducible debian: make sqlite3 locking errors less noisy
Signed-off-by: Holger Levsen <holger@layer-acht.org>
Diffstat (limited to 'bin')
-rwxr-xr-xbin/reproducible_common.py16
1 files changed, 12 insertions, 4 deletions
diff --git a/bin/reproducible_common.py b/bin/reproducible_common.py
index dcbe05e8..985f2eb7 100755
--- a/bin/reproducible_common.py
+++ b/bin/reproducible_common.py
@@ -30,6 +30,7 @@ from subprocess import call, check_call
from tempfile import NamedTemporaryFile
from datetime import datetime, timedelta
from sqlalchemy import MetaData, Table, sql, create_engine
+from sqlalchemy.exc import NoSuchTableError, OperationalError
DEBUG = False
QUIET = False
@@ -365,7 +366,7 @@ def db_table(table_name):
"""
try:
return Table(table_name, DB_METADATA, autoload=True)
- except sqlalchemy.exc.NoSuchTableError:
+ except NoSuchTableError:
log.error("Table %s does not exist or schema for %s could not be loaded",
table_name, REPRODUCIBLE_DB)
raise
@@ -384,9 +385,16 @@ def query_db(query):
"""
try:
result = conn_db.execute(query)
- except:
- print_critical_message('Error executing this query:\n' + query)
- raise
+ except OperationalError as ex:
+ # if this sqlalchemy.exc.OperationalError was caused by a sqlite3
+ # database locking error, the error will have the following format:
+ if ex.orig and ex.orig.args and ex.orig.args[0] == "database is locked":
+ print_critical_message('SQLite database locked, could not execute ' +
+ 'query:\n"%s"\nExiting script.' % query)
+ exit(1)
+ else:
+ print_critical_message('Error executing this query:\n' + query)
+ raise
if result.returns_rows:
return result.fetchall()