From 3041a8ee16da71288fed16a7a3462b00695e7939 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre-Elliott=20B=C3=A9cue?= Date: Mon, 30 Mar 2015 17:05:50 +0200 Subject: [PATCH] Quand on veut qu'une variable globale soit lisible dans une fonction, faut faire gaffe... MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * ~100 mails sur une dizaine d'adhérents plus loin... --- surveillance/deconnexion2.py | 46 ++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/surveillance/deconnexion2.py b/surveillance/deconnexion2.py index d06e6647..8823fc95 100755 --- a/surveillance/deconnexion2.py +++ b/surveillance/deconnexion2.py @@ -30,6 +30,29 @@ import gestion.mail as mail_module # Ça printe au lieu de faire bobo quand c'est à True DEBUG = False +LDAP = shortcuts.lc_ldap_admin() + +# Connection à la base sql via pgsql +PGSQL = psycopg2.connect(database='filtrage', user='crans') +PGSQL.set_session(autocommit=True) +CURSEUR = PGSQL.cursor(cursor_factory=psycopg2.extras.DictCursor) + +# Avertis upload hard +REQUETE = "SELECT type, id FROM avertis_upload_hard WHERE date > now() - %(interval)s;" +CURSEUR.execute(REQUETE, { + 'interval': DELTA, +}) + +AVERTIS_UPLOAD_HARD = CURSEUR.fetchall() + +# Avertis upload soft +REQUETE = "SELECT type, id FROM avertis_upload_soft WHERE date > now() - %(interval)s" +CURSEUR.execute(REQUETE, { + 'interval': DELTA, +}) + +AVERTIS_UPLOAD_SOFT = CURSEUR.fetchall() + EPOCH = pytz.utc.localize(datetime.datetime(1970, 1, 1)) TZ = pytz.timezone('Europe/Paris') DELTA = datetime.timedelta(0, upload.interval * 3600, 0) @@ -473,27 +496,4 @@ def reperage_chambre(mac): return "Inconnue", "Inconnue" if __name__ == "__main__": - LDAP = shortcuts.lc_ldap_admin() - - # Connection à la base sql via pgsql - PGSQL = psycopg2.connect(database='filtrage', user='crans') - PGSQL.set_session(autocommit=True) - CURSEUR = PGSQL.cursor(cursor_factory=psycopg2.extras.DictCursor) - - # Avertis upload hard - REQUETE = "SELECT type, id FROM avertis_upload_hard WHERE date > now() - %(interval)s;" - CURSEUR.execute(REQUETE, { - 'interval': DELTA, - }) - - AVERTIS_UPLOAD_HARD = CURSEUR.fetchall() - - # Avertis upload soft - REQUETE = "SELECT type, id FROM avertis_upload_soft WHERE date > now() - %(interval)s" - CURSEUR.execute(REQUETE, { - 'interval': DELTA, - }) - - AVERTIS_UPLOAD_SOFT = CURSEUR.fetchall() - main(CURSEUR, LDAP)