]> git.saurik.com Git - cyql.git/commitdiff
Support poorly-designed WebCyte "maintenance mode".
authorJay Freeman (saurik) <saurik@saurik.com>
Mon, 7 Jul 2014 07:26:44 +0000 (07:26 +0000)
committerJay Freeman (saurik) <saurik@saurik.com>
Mon, 7 Jul 2014 07:27:07 +0000 (07:27 +0000)
__init__.py

index 47f54fd19972e4a9f2e09a25e1430fab5e826247..6e53915a73de9443299dee42d256c8cb51236390 100644 (file)
@@ -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