Esempio n. 1
0
 def connectionTimeout(self):
     '''Called after X seconds after the http stream is closed'''
     if len(MultiPartStream.getClients(self.target)):
         return
     log.msg("No more clients, closing link")
     CameraFactory.disconnect(self.target)
     del self
Esempio n. 2
0
 def connectionTimeout(self):
     '''Called after X seconds after the http stream is closed'''
     if len(MultiPartStream.getClients(self.target)):
         return
     log.msg("No more clients, closing link")
     CameraFactory.disconnect(self.target)
     del self
Esempio n. 3
0
 def render_POST(self, request):
     try:
         request.setHeader('Content-Type', 'application/json')
         request.setHeader('Cache-Control', 'no-cache')
         request.setHeader('Connection', 'close')
         address = request.args["address"][0]
         if CameraFactory.isConnected(address):
             CameraFactory.disconnect(address)
             return json.dumps({"result": "disconnected"})
         else:
             CameraFactory.connect(address)
             return json.dumps({"result": "connecting"})
     except Exception, err:
         request.setHeader('Content-Type', 'text/html')
         request.setHeader('Cache-Control', 'no-cache')
         request.setHeader('Connection', 'close')
         request.setResponseCode(500, str(err))
         return "<html><h1>ERROR:</h1>\n<pre>%s</pre></html>" % (traceback.format_exc())
Esempio n. 4
0
 def render_GET(self, request):
     try:
         request.setHeader('Content-Type', 'application/json')
         request.setHeader('Cache-Control', 'no-cache')
         request.setHeader('Connection', 'close')
         if len(request.postpath) > 0 and len(request.postpath[0])>0:
             address=request.postpath[0].replace("_", ":")
             if not CameraFactory.isConnected(address):
                 return json.dumps({"result": "Not Connected"})
             CameraFactory.disconnect(address)
             return json.dumps({"result": "Disconnected"})
         return json.dumps({"result": "No Address"})
     except Exception, err:
         request.setHeader('Content-Type', 'text/html')
         request.setHeader('Cache-Control', 'no-cache')
         request.setHeader('Connection', 'close')
         request.setResponseCode(500, str(err))
         return "<html><h1>ERROR:</h1>\n<pre>%s</pre></html>" % (traceback.format_exc())
Esempio n. 5
0
 def render_POST(self, request):
     try:
         request.setHeader('Content-Type', 'application/json')
         request.setHeader('Cache-Control', 'no-cache')
         request.setHeader('Connection', 'close')
         address = request.args["address"][0]
         if CameraFactory.isConnected(address):
             CameraFactory.disconnect(address)
             return json.dumps({"result": "disconnected"})
         else:
             CameraFactory.connect(address)
             return json.dumps({"result": "connecting"})
     except Exception, err:
         request.setHeader('Content-Type', 'text/html')
         request.setHeader('Cache-Control', 'no-cache')
         request.setHeader('Connection', 'close')
         request.setResponseCode(500, str(err))
         return "<html><h1>ERROR:</h1>\n<pre>%s</pre></html>" % (
             traceback.format_exc())
Esempio n. 6
0
 def render_GET(self, request):
     try:
         request.setHeader('Content-Type', 'application/json')
         request.setHeader('Cache-Control', 'no-cache')
         request.setHeader('Connection', 'close')
         if len(request.postpath) > 0 and len(request.postpath[0]) > 0:
             address = request.postpath[0].replace("_", ":")
             if not CameraFactory.isConnected(address):
                 return json.dumps({"result": "Not Connected"})
             CameraFactory.disconnect(address)
             return json.dumps({"result": "Disconnected"})
         return json.dumps({"result": "No Address"})
     except Exception, err:
         request.setHeader('Content-Type', 'text/html')
         request.setHeader('Cache-Control', 'no-cache')
         request.setHeader('Connection', 'close')
         request.setResponseCode(500, str(err))
         return "<html><h1>ERROR:</h1>\n<pre>%s</pre></html>" % (
             traceback.format_exc())
Esempio n. 7
0
 def cleanup(self, address):
     CameraFactory.disconnect(address)
     CameraFactory.removeListener(address, self)
     self.request.finish()
Esempio n. 8
0
 def cleanup(self, address):
     CameraFactory.disconnect(address)
     CameraFactory.removeListener(address, self)
     self.request.finish()