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)