modifié: superTornado.py

This commit is contained in:
sidya82 2014-04-02 19:51:51 +02:00
parent bb01e28ab0
commit 5600f1216d
1 changed files with 22 additions and 13 deletions

View File

@ -247,19 +247,28 @@ class WSocketHandler(BaseHandler,tornado.websocket.WebSocketHandler):
Allow send the image in the websocket Allow send the image in the websocket
""" """
try : try :
temp = open("temp","w")
socket.setdefaulttimeout(5) with open("temp","w") as temp :
f = urlopen(GlobalVars.urlCamera) socket.setdefaulttimeout(5)
isData = False f = urlopen(GlobalVars.urlCamera)
data = f.readline().rstrip('\r\n') temp.write(f.read())
while(data != "--MOBOTIX_Fast_Serverpush--"): temp.close()
data = f.readline().rstrip('\r\n') with open("temp","r") as temp :
if isData == True: with open("temp2","w") as dest :
temp.write(data) isData = False
if data == "ENDSECTIONEVENT" : for ligne in temp
isData = True ligne.rstrip('\r\n')
data = f.read() if data ="--MOTOBIX_Fast_Serverpush"
encoded = base64.b64encode(data) isData = False
if isData == True:
dest.write(data+"\n")
if data == "ENDSECTIONEVENT" :
isData = True
data = f.read()
temp.close()
dest.close()
with open("temp2","r") as data :
encoded = base64.b64encode(data.read())
f.close() f.close()
self.write_message(encoded) self.write_message(encoded)
GlobalVars.log.printL( "->Image Data Send : " + self.request.remote_ip, lvl.INFO) GlobalVars.log.printL( "->Image Data Send : " + self.request.remote_ip, lvl.INFO)