From c64c89ddd3c775a93ef669ff258919efb18974a4 Mon Sep 17 00:00:00 2001 From: Nicolas Dandrimont Date: Tue, 7 Sep 2010 14:50:40 +0200 Subject: [PATCH] =?UTF-8?q?[annuaires=5Fpg]=20=C3=89vite=20de=20tout=20pla?= =?UTF-8?q?nter=20quand=20la=20connexion=20=C3=A0=20PgSQL=20chie?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit darcs-hash:20100907125040-ffbb2-efe3bdf518a51a2e2aa6c8d623d76954682b0b22.gz --- gestion/annuaires_pg.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/gestion/annuaires_pg.py b/gestion/annuaires_pg.py index f2a6a0ac..2938f5f0 100755 --- a/gestion/annuaires_pg.py +++ b/gestion/annuaires_pg.py @@ -3,13 +3,18 @@ import psycopg2 -conn = psycopg2.connect("user=crans dbname=switchs host=pgsql.adm.crans.org") +try: + conn = psycopg2.connect("user=crans dbname=switchs host=pgsql.adm.crans.org") + + # Population de la tâble avec les bâtiments + cur = conn.cursor() + + cur.execute("SELECT DISTINCT batiment FROM prises") + bat_switchs = [i[0] for i in cur.fetchall()] +except psycopg2.OperationalError: + bat_switchs = ["a", "b", "c", "g", "h", "i", "j", "m", "o", "p"] -# Population de la tâble avec les bâtiments -cur = conn.cursor() -cur.execute("SELECT DISTINCT batiment FROM prises") -bat_switchs = [i[0] for i in cur.fetchall()] bat_manuels = []