From: Jay Freeman (saurik) Date: Mon, 7 Jul 2014 07:26:44 +0000 (+0000) Subject: Support poorly-designed WebCyte "maintenance mode". X-Git-Url: https://git.saurik.com/cyql.git/commitdiff_plain/18e35f4680d7dd44664d391daebeb56f60516028 Support poorly-designed WebCyte "maintenance mode". --- diff --git a/__init__.py b/__init__.py index 47f54fd..6e53915 100644 --- a/__init__.py +++ b/__init__.py @@ -17,6 +17,9 @@ import psycopg2.pool psycopg2.extensions.register_type(psycopg2.extensions.UNICODE) psycopg2.extensions.register_type(psycopg2.extensions.UNICODEARRAY) +class ConnectionError(): + pass + class connect(object): def __init__(self, dsn): options = dsn.copy() @@ -38,6 +41,8 @@ class connect(object): self.driver = psycopg2.connect(**options) break except psycopg2.OperationalError, e: + if e.message.startswith('could not connect to server: Connection refused\n'): + raise ConnectionError() if attempt == 2: raise attempt = attempt + 1