From 5600f1216d0afa1f7a06e5e93a78e8398ba924c1 Mon Sep 17 00:00:00 2001 From: sidya82 Date: Wed, 2 Apr 2014 19:51:51 +0200 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 | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/superTornado.py b/superTornado.py index 149bade..ef2271b 100644 --- a/superTornado.py +++ b/superTornado.py @@ -247,19 +247,28 @@ class WSocketHandler(BaseHandler,tornado.websocket.WebSocketHandler): Allow send the image in the websocket """ try : - temp = open("temp","w") - socket.setdefaulttimeout(5) - f = urlopen(GlobalVars.urlCamera) - isData = False - data = f.readline().rstrip('\r\n') - while(data != "--MOBOTIX_Fast_Serverpush--"): - data = f.readline().rstrip('\r\n') - if isData == True: - temp.write(data) - if data == "ENDSECTIONEVENT" : - isData = True - data = f.read() - encoded = base64.b64encode(data) + + with open("temp","w") as temp : + socket.setdefaulttimeout(5) + f = urlopen(GlobalVars.urlCamera) + temp.write(f.read()) + temp.close() + with open("temp","r") as temp : + with open("temp2","w") as dest : + isData = False + for ligne in temp + ligne.rstrip('\r\n') + if data ="--MOTOBIX_Fast_Serverpush" + 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() self.write_message(encoded) GlobalVars.log.printL( "->Image Data Send : " + self.request.remote_ip, lvl.INFO)