diff options
author | Mattia Rizzolo <mattia@mapreri.org> | 2015-08-17 10:26:32 +0000 |
---|---|---|
committer | Mattia Rizzolo <mattia@mapreri.org> | 2015-08-17 10:27:10 +0000 |
commit | 15efd34ed215bbb6cdaafa77fbc5e9922b79fc3e (patch) | |
tree | d5d456a383f814548a584e8d5767fb57a0abd820 | |
parent | b2ef162763e9f5304d9e824e8211b87a68f461d1 (diff) | |
download | jenkins.debian.net-15efd34ed215bbb6cdaafa77fbc5e9922b79fc3e.tar.xz |
reproducible: common.py: nest try/except clauses to really catch every possible sql error
-rwxr-xr-x | bin/reproducible_common.py | 35 |
1 files changed, 18 insertions, 17 deletions
diff --git a/bin/reproducible_common.py b/bin/reproducible_common.py index 6ddcf398..653bff12 100755 --- a/bin/reproducible_common.py +++ b/bin/reproducible_common.py @@ -320,23 +320,24 @@ def start_udd_connection(): port = 5432 db = "udd" try: - log.debug("Starting connection to the UDD database") - conn = psycopg2.connect( - database=db, - user=username, - host=host, - password=password, - connect_timeout=5, - ) - except psycopg2.OperationalError as err: - if str(err) == 'timeout expired\n': - log.error('Connection to the UDD database replice timed out. ' - 'Probably the machine is offline or just unavailable.') - log.error('Failing nicely anyway, all queries will return an ' - 'empty response.') - return None - else: - raise + try: + log.debug("Starting connection to the UDD database") + conn = psycopg2.connect( + database=db, + user=username, + host=host, + password=password, + connect_timeout=5, + ) + except psycopg2.OperationalError as err: + if str(err) == 'timeout expired\n': + log.error('Connection to the UDD database replice timed out. ' + 'Maybe the machine is offline or just unavailable.') + log.error('Failing nicely anyway, all queries will return an ' + 'empty response.') + return None + else: + raise except: log.error('Erorr connecting to the UDD database replica.' + 'The full error is:') |