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 = []