From f2f68e1918daa24c882f2cf098aca48115c73979 Mon Sep 17 00:00:00 2001 From: sidya82 Date: Thu, 27 Feb 2014 20:06:37 +0100 Subject: [PATCH] =?UTF-8?q?=09modifi=C3=A9:=20=20=20=20=20=20=20=20=20supe?= =?UTF-8?q?rTornado.py?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- superTornado.py | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/superTornado.py b/superTornado.py index c2edb72..0900243 100644 --- a/superTornado.py +++ b/superTornado.py @@ -2,8 +2,10 @@ import tornado.ioloop import tornado.web import tornado.httpserver from loadConf import * +from login import * confAveug = False +ficLog = Login() class MainHandler(tornado.web.RequestHandler): def get(self): @@ -11,14 +13,40 @@ class MainHandler(tornado.web.RequestHandler): def post(self): iden = self.get_argument("id","") mdp = self.get_argument("mdp","") - self.write("Le pseudo est :") - self.write(iden) + + login = Login() + autorise = login.connexion(iden, mdp) + #maison = httplib.HTTPConnection("192.168.16.150", 80) + if autorise == True: + ficLog.enregDansLog(iden,"Authorized user connection",info[0]) + if confAveug == True: + print '->Send audio alarm authorized user' + print 'maison.request("GET", "micom/say.php?source=toto&text=Connection%20a%20la%20camera%20autorisee")' + else: + print '->Send visual alarm authorized user' + print 'maison.request("GET", "micom/lamp.php?room=salon1&order=1")' + print "->Send to client authorized user access" + #redirection autorisé + + else: + ficLog.enregDansLog(iden,"Unauthorized user connection",info[0]) + if confAveug == True: + print '->Send audio alarm unauthorized user' + print 'maison.request("GET", "micom/say.php?source=toto&text=Connection%20a%20la%20camera%20non%20autorisee")' + else: + print '->Send visual alarm unauthorized user' + print 'maison.request("GET", "micom/lamp.php?room=salon1&order=1")' + print "->Send to client unauthorized user access" + #redirection non autorisé + application = tornado.web.Application([ (r"/", MainHandler), + (r"/video", VideoHandler), + (r"/authorized", VideoHandler), ]) if __name__ == "__main__":