modifié: m/fichier/conf
modifié: m/loadConf.py nouveau fichier: m/log.py modifié: m/login.py modifié: superTornado.py
This commit is contained in:
parent
70c0d27716
commit
f1904ed512
@ -1 +1,3 @@
|
|||||||
handicap=1
|
blind=1
|
||||||
|
camera=192.168.1.13
|
||||||
|
port=80
|
||||||
|
@ -1,16 +1,25 @@
|
|||||||
class LoadConf(object):
|
class LoadConf(object):
|
||||||
def loadHand(self):
|
def loadValue(self, key):
|
||||||
with open("m/fichier/conf", "r") as source :
|
with open("m/fichier/conf", "r") as source :
|
||||||
for ligne in source:
|
for ligne in source:
|
||||||
data = ligne.rstrip('\n\r').split('=')
|
data = ligne.rstrip('\n\r').split('=')
|
||||||
if data[0] in 'handicap' :
|
if data[0] in key :
|
||||||
source.close()
|
source.close()
|
||||||
return data[1]
|
return data[1]
|
||||||
source.close()
|
source.close()
|
||||||
return 0
|
return "error"
|
||||||
|
|
||||||
def estAveugle(self):
|
def isBlind(self):
|
||||||
if self.loadHand() == "1" :
|
rep = self.loadValue("blind")
|
||||||
|
if rep == "1" :
|
||||||
return True
|
return True
|
||||||
else :
|
else if rep == "0":
|
||||||
return False
|
return False
|
||||||
|
else :
|
||||||
|
return rep
|
||||||
|
|
||||||
|
def ipCamera(self)
|
||||||
|
return self.loadValue("camera")
|
||||||
|
|
||||||
|
def portServ(self)
|
||||||
|
return self.loadValue("port")
|
||||||
|
8
m/log.py
Normal file
8
m/log.py
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
import time
|
||||||
|
from datetime import datetime
|
||||||
|
|
||||||
|
class Log(object):
|
||||||
|
def enregDansLog(self,pLog,pMsg,pIP):
|
||||||
|
with open("m/fichier/log", "a") as dest :
|
||||||
|
d = datetime.now().strftime("%c")
|
||||||
|
dest.write("%s,%s,%s,%s\n" % (d,pLog,pMsg,pIP))
|
@ -1,7 +1,6 @@
|
|||||||
import time
|
|
||||||
import hashlib
|
import hashlib
|
||||||
import httplib
|
import httplib
|
||||||
from datetime import datetime
|
|
||||||
|
|
||||||
class Login(object):
|
class Login(object):
|
||||||
def verifLogin(self,pLog,pMdp):
|
def verifLogin(self,pLog,pMdp):
|
||||||
@ -16,11 +15,6 @@ class Login(object):
|
|||||||
source.close()
|
source.close()
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def enregDansLog(self,pLog,pMsg,pIP):
|
|
||||||
with open("m/fichier/log", "a") as dest :
|
|
||||||
d = datetime.now().strftime("%c")
|
|
||||||
dest.write("%s,%s,%s,%s\n" % (d,pLog,pMsg,pIP))
|
|
||||||
|
|
||||||
def connexion(self,pLog,pMdp):
|
def connexion(self,pLog,pMdp):
|
||||||
if self.verifLogin(pLog,pMdp) == True :
|
if self.verifLogin(pLog,pMdp) == True :
|
||||||
return True
|
return True
|
||||||
|
@ -14,11 +14,12 @@ from tornado.ioloop import PeriodicCallback
|
|||||||
|
|
||||||
from m.loadConf import *
|
from m.loadConf import *
|
||||||
from m.login import *
|
from m.login import *
|
||||||
|
from m.log import *
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
|
||||||
confAveug = LoadConf().estAveugle()
|
config = LoadConf()
|
||||||
ficLog = Login()
|
ficLog = Log()
|
||||||
|
|
||||||
class BaseHandler(tornado.web.RequestHandler):
|
class BaseHandler(tornado.web.RequestHandler):
|
||||||
def get_current_user(self):
|
def get_current_user(self):
|
||||||
@ -43,7 +44,7 @@ class MainHandler(BaseHandler):
|
|||||||
self.set_secure_cookie("auth", "yes")
|
self.set_secure_cookie("auth", "yes")
|
||||||
self.redirect("/video")
|
self.redirect("/video")
|
||||||
else:
|
else:
|
||||||
print "->An unauthorized user try to access"
|
print "->An unauthorized user try to access : " + self.request.remote_ip
|
||||||
self.redirect("/unauthorized")
|
self.redirect("/unauthorized")
|
||||||
|
|
||||||
class VideoHandler(BaseHandler):
|
class VideoHandler(BaseHandler):
|
||||||
@ -99,7 +100,7 @@ class WSocketHandler(BaseHandler,tornado.websocket.WebSocketHandler):
|
|||||||
else:
|
else:
|
||||||
print '->Send visual alarm unauthorized user'
|
print '->Send visual alarm unauthorized user'
|
||||||
print 'maison.request("GET", "micom/lamp.php?room=salon1&order=1")'
|
print 'maison.request("GET", "micom/lamp.php?room=salon1&order=1")'
|
||||||
print "->Unauthorized user access" + self.request.remote_ip
|
print "->Unauthorized user access : " + self.request.remote_ip
|
||||||
self.send_image()
|
self.send_image()
|
||||||
|
|
||||||
def on_message(self,mesg):
|
def on_message(self,mesg):
|
||||||
@ -120,7 +121,7 @@ class WSocketHandler(BaseHandler,tornado.websocket.WebSocketHandler):
|
|||||||
else:
|
else:
|
||||||
print '->Send visual alarm deconnection user'
|
print '->Send visual alarm deconnection user'
|
||||||
print 'maison.request("GET", "micom/lamp.php?room=salon1&order=0")'
|
print 'maison.request("GET", "micom/lamp.php?room=salon1&order=0")'
|
||||||
print"->"+iden+" Deconnection" + self.request.remote_ip
|
print"->"+iden+" Deconnection : " + self.request.remote_ip
|
||||||
|
|
||||||
|
|
||||||
def send_image(self) :
|
def send_image(self) :
|
||||||
@ -147,12 +148,31 @@ application = tornado.web.Application([
|
|||||||
cookie_secret="1213215656")
|
cookie_secret="1213215656")
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
print "->Loading configuration ... "
|
||||||
|
try :
|
||||||
|
confAveug = config.estAveugle
|
||||||
|
ipCamera = config.ipCamera
|
||||||
|
portServ = config.portServ
|
||||||
|
if confAveug == "error"
|
||||||
|
raise "Failed Load Blind Configuration"
|
||||||
|
if ipCamera == "error"
|
||||||
|
raise "Failed Load IP Camera Configuration"
|
||||||
|
if portServ == "error"
|
||||||
|
raise "Failed Load Port Server Configuration"
|
||||||
|
except Exception, e :
|
||||||
|
print "Configuration Loading Failed ! Check Conf File !"
|
||||||
|
print e
|
||||||
|
return 1
|
||||||
|
print "->Configuraion Server Load Successfully:"
|
||||||
if confAveug == True:
|
if confAveug == True:
|
||||||
print "->Blind unhabitant system configuration"
|
print " ->Blind unhabitant"
|
||||||
else :
|
else :
|
||||||
print "->Not blind unhabitant system configuration"
|
print " ->Not blind unhabitant"
|
||||||
|
print " ->Ip camera : " + ipCamera
|
||||||
|
print " ->Port Server : " + portServ
|
||||||
|
|
||||||
tornado.options.parse_command_line()
|
tornado.options.parse_command_line()
|
||||||
http_server = tornado.httpserver.HTTPServer(application)
|
http_server = tornado.httpserver.HTTPServer(application)
|
||||||
http_server.listen(80)
|
http_server.listen(80)
|
||||||
|
|
||||||
tornado.ioloop.IOLoop.instance().start()
|
tornado.ioloop.IOLoop.instance().start()
|
||||||
|
Reference in New Issue
Block a user