示例#1
0
    def on_response(response):
        if response.error:
            logging.error(
                'failed to check timelapse movie status for remote camera %(id)s on %(url)s: %(msg)s'
                % {
                    'id': camera_id,
                    'url': pretty_camera_url(local_config),
                    'msg': utils.pretty_http_error(response)
                })

            return callback(error=utils.pretty_http_error(response))

        try:
            response = json.loads(response.body)

        except Exception as e:
            logging.error(
                'failed to decode json answer from %(url)s: %(msg)s' % {
                    'url': pretty_camera_url(local_config),
                    'msg': unicode(e)
                })

            return callback(error=unicode(e))

        callback(response)
示例#2
0
    def on_response(response):
        if response.error:
            logging.error(
                "failed to make timelapse movie for group %(group)s of remote camera %(id)s with rate %(framerate)s/%(int)s on %(url)s: %(msg)s"
                % {
                    "group": group,
                    "id": camera_id,
                    "url": pretty_camera_url(local_config),
                    "int": interval,
                    "framerate": framerate,
                    "msg": utils.pretty_http_error(response),
                }
            )

            return callback(error=utils.pretty_http_error(response))

        try:
            response = json.loads(response.body)

        except Exception as e:
            logging.error(
                "failed to decode json answer from %(url)s: %(msg)s"
                % {"url": pretty_camera_url(local_config), "msg": unicode(e)}
            )

            return callback(error=unicode(e))

        callback(response)
示例#3
0
 def on_response(response):
     def make_camera_response(c):
         return {
             'id': c['id'],
             'name': c['name']
         }
     
     if response.error:
         logging.error('failed to list remote cameras on %(url)s: %(msg)s' % {
                 'url': pretty_camera_url(local_config, camera=False),
                 'msg': utils.pretty_http_error(response)})
         
         return callback(error=utils.pretty_http_error(response))
     
     try:
         response = json.loads(response.body)
         
     except Exception as e:
         logging.error('failed to decode json answer from %(url)s: %(msg)s' % {
                 'url': pretty_camera_url(local_config, camera=False),
                 'msg': unicode(e)})
         
         return callback(error=unicode(e))
     
     cameras = response['cameras']
     
     # filter out simple mjpeg cameras
     cameras = [make_camera_response(c) for c in cameras
             if c['proto'] != 'mjpeg' and c.get('enabled')]
     
     callback(cameras)
示例#4
0
    def on_response(response):
        if response.error:
            logging.error(
                'failed to prepare zip file for group %(group)s of remote camera %(id)s on %(url)s: %(msg)s'
                % {
                    'group': group,
                    'id': camera_id,
                    'url': pretty_camera_url(local_config),
                    'msg': utils.pretty_http_error(response)
                })

            return callback(error=utils.pretty_http_error(response))

        try:
            key = json.loads(response.body)['key']

        except Exception as e:
            logging.error(
                'failed to decode json answer from %(url)s: %(msg)s' % {
                    'url': pretty_camera_url(local_config),
                    'msg': unicode(e)
                })

            return callback(error=unicode(e))

        callback({'key': key})
示例#5
0
    def on_response(response):
        if response.error:
            logging.error(
                'failed to make timelapse movie for group %(group)s of remote camera %(id)s with rate %(framerate)s/%(int)s on %(url)s: %(msg)s'
                % {
                    'group': group,
                    'id': camera_id,
                    'url': pretty_camera_url(local_config),
                    'int': interval,
                    'framerate': framerate,
                    'msg': utils.pretty_http_error(response)
                })

            return callback(error=utils.pretty_http_error(response))

        try:
            response = json.loads(response.body)

        except Exception as e:
            logging.error(
                'failed to decode json answer from %(url)s: %(msg)s' % {
                    'url': pretty_camera_url(local_config),
                    'msg': unicode(e)
                })

            return callback(error=unicode(e))

        callback(response)
示例#6
0
 def on_response(response):
     def make_camera_response(c):
         return {
             'id': c['id'],
             'name': c['name']
         }
     
     if response.error:
         logging.error('failed to list remote cameras on %(url)s: %(msg)s' % {
                 'url': pretty_camera_url(local_config, camera=False),
                 'msg': utils.pretty_http_error(response)})
         
         return callback(error=utils.pretty_http_error(response))
     
     try:
         response = json.loads(response.body)
         
     except Exception as e:
         logging.error('failed to decode json answer from %(url)s: %(msg)s' % {
                 'url': pretty_camera_url(local_config, camera=False),
                 'msg': unicode(e)})
         
         return callback(error=unicode(e))
     
     cameras = response['cameras']
     
     # filter out simple mjpeg cameras
     cameras = [make_camera_response(c) for c in cameras
             if c['proto'] != 'mjpeg' and c.get('enabled')]
     
     callback(cameras)
示例#7
0
    def on_response(response):
        def make_camera_response(c):
            return {"id": c["id"], "name": c["name"]}

        if response.error:
            logging.error(
                "failed to list remote cameras on %(url)s: %(msg)s"
                % {"url": pretty_camera_url(local_config, camera=False), "msg": utils.pretty_http_error(response)}
            )

            return callback(error=utils.pretty_http_error(response))

        try:
            response = json.loads(response.body)

        except Exception as e:
            logging.error(
                "failed to decode json answer from %(url)s: %(msg)s"
                % {"url": pretty_camera_url(local_config, camera=False), "msg": unicode(e)}
            )

            return callback(error=unicode(e))

        cameras = response["cameras"]

        # filter out simple mjpeg cameras
        cameras = [make_camera_response(c) for c in cameras if c["proto"] != "mjpeg" and c.get("enabled")]

        callback(cameras)
示例#8
0
    def on_response(response):
        if response.error:
            logging.error(
                "failed to prepare zip file for group %(group)s of remote camera %(id)s on %(url)s: %(msg)s"
                % {
                    "group": group,
                    "id": camera_id,
                    "url": pretty_camera_url(local_config),
                    "msg": utils.pretty_http_error(response),
                }
            )

            return callback(error=utils.pretty_http_error(response))

        try:
            key = json.loads(response.body)["key"]

        except Exception as e:
            logging.error(
                "failed to decode json answer from %(url)s: %(msg)s"
                % {"url": pretty_camera_url(local_config), "msg": unicode(e)}
            )

            return callback(error=unicode(e))

        callback({"key": key})
示例#9
0
 def on_response(response):
     if response.error:
         logging.error('failed to set preview for remote camera %(id)s on %(url)s: %(msg)s' % {
                 'id': camera_id,
                 'url': pretty_camera_url(local_config),
                 'msg': utils.pretty_http_error(response)})
     
         return callback(error=utils.pretty_http_error(response))
     
     callback()
示例#10
0
 def on_response(response):
     if response.error:
         logging.error('failed to set preview for remote camera %(id)s on %(url)s: %(msg)s' % {
                 'id': camera_id,
                 'url': pretty_camera_url(local_config),
                 'msg': utils.pretty_http_error(response)})
     
         return callback(error=utils.pretty_http_error(response))
     
     callback()
示例#11
0
    def on_response(response):
        if response.error:
            logging.error(
                "failed to set preview for remote camera %(id)s on %(url)s: %(msg)s"
                % {"id": camera_id, "url": pretty_camera_url(local_config), "msg": utils.pretty_http_error(response)}
            )

            return callback(error=utils.pretty_http_error(response))

        callback()
示例#12
0
 def on_response(response):
     if response.error:
         logging.error('failed to delete file %(filename)s of remote camera %(id)s on %(url)s: %(msg)s' % {
                 'filename': filename,
                 'id': camera_id,
                 'url': pretty_camera_url(local_config),
                 'msg': utils.pretty_http_error(response)})
         
         return callback(error=utils.pretty_http_error(response))
     
     callback()
示例#13
0
 def on_response(response):
     if response.error:
         logging.error('failed to delete group "%(group)s" of remote camera %(id)s on %(url)s: %(msg)s' % {
                 'group': group or 'ungrouped',
                 'id': camera_id,
                 'url': pretty_camera_url(local_config),
                 'msg': utils.pretty_http_error(response)})
         
         return callback(error=utils.pretty_http_error(response))
     
     callback()
示例#14
0
    def on_response(response):
        if response.error:
            logging.error('failed to execute action "%(action)s" of remote camera %(id)s on %(url)s: %(msg)s' % {
                    'action': action,
                    'id': camera_id,
                    'url': pretty_camera_url(local_config),
                    'msg': utils.pretty_http_error(response)})

            return callback(error=utils.pretty_http_error(response))
        
        callback()
示例#15
0
    def on_response(response):
        if response.error:
            logging.error('failed to execute action "%(action)s" of remote camera %(id)s on %(url)s: %(msg)s' % {
                    'action': action,
                    'id': camera_id,
                    'url': pretty_camera_url(local_config),
                    'msg': utils.pretty_http_error(response)})

            return callback(error=utils.pretty_http_error(response))
        
        callback()
示例#16
0
 def on_response(response):
     if response.error:
         logging.error('failed to delete group "%(group)s" of remote camera %(id)s on %(url)s: %(msg)s' % {
                 'group': group or 'ungrouped',
                 'id': camera_id,
                 'url': pretty_camera_url(local_config),
                 'msg': utils.pretty_http_error(response)})
         
         return callback(error=utils.pretty_http_error(response))
     
     callback()
示例#17
0
 def on_response(response):
     if response.error:
         logging.error('failed to delete file %(filename)s of remote camera %(id)s on %(url)s: %(msg)s' % {
                 'filename': filename,
                 'id': camera_id,
                 'url': pretty_camera_url(local_config),
                 'msg': utils.pretty_http_error(response)})
         
         return callback(error=utils.pretty_http_error(response))
     
     callback()
示例#18
0
    def on_response(response):
        if response.error:
            logging.error('failed to download timelapse movie for remote camera %(id)s on %(url)s: %(msg)s' % {
                    'id': camera_id,
                    'url': pretty_camera_url(local_config),
                    'msg': utils.pretty_http_error(response)})

            return callback(error=utils.pretty_http_error(response))

        callback({
            'data': response.body,
            'content_type': response.headers.get('Content-Type'),
            'content_disposition': response.headers.get('Content-Disposition')
        })
示例#19
0
    def on_response(response):
        if response.error:
            logging.error('failed to download timelapse movie for remote camera %(id)s on %(url)s: %(msg)s' % {
                    'id': camera_id,
                    'url': pretty_camera_url(local_config),
                    'msg': utils.pretty_http_error(response)})

            return callback(error=utils.pretty_http_error(response))

        callback({
            'data': response.body,
            'content_type': response.headers.get('Content-Type'),
            'content_disposition': response.headers.get('Content-Disposition')
        })
示例#20
0
    def on_response(response):
        if response.error:
            logging.error(
                "failed to get file preview for %(filename)s of remote camera %(id)s on %(url)s: %(msg)s"
                % {
                    "filename": filename,
                    "id": camera_id,
                    "url": pretty_camera_url(local_config),
                    "msg": utils.pretty_http_error(response),
                }
            )

            return callback(error=utils.pretty_http_error(response))

        callback(response.body)
示例#21
0
    def on_response(response):
        cookies = utils.parse_cookies(response.headers.get_list('Set-Cookie'))
        motion_detected = cookies.get('motion_detected_' + str(camera_id)) == 'true'
        fps = cookies.get('capture_fps_' + str(camera_id))
        fps = float(fps) if fps else 0

        if response.error:
            logging.error('failed to get current picture for remote camera %(id)s on %(url)s: %(msg)s' % {
                    'id': camera_id,
                    'url': pretty_camera_url(local_config),
                    'msg': utils.pretty_http_error(response)})
            
            return callback(error=utils.pretty_http_error(response))

        callback(motion_detected, fps, response.body)
示例#22
0
    def on_response(response):
        if response.error:
            logging.error(
                "failed to delete group %(group)s of remote camera %(id)s on %(url)s: %(msg)s"
                % {
                    "group": group,
                    "id": camera_id,
                    "url": pretty_camera_url(local_config),
                    "msg": utils.pretty_http_error(response),
                }
            )

            return callback(error=utils.pretty_http_error(response))

        callback()
示例#23
0
    def on_response(response):
        cookies = utils.parse_cookies(response.headers.get_list('Set-Cookie'))
        motion_detected = cookies.get('motion_detected_' + str(camera_id)) == 'true'
        capture_fps = cookies.get('capture_fps_' + str(camera_id))
        capture_fps = float(capture_fps) if capture_fps else 0
        monitor_info = cookies.get('monitor_info_' + str(camera_id))

        if response.error:
            logging.error('failed to get current picture for remote camera %(id)s on %(url)s: %(msg)s' % {
                    'id': camera_id,
                    'url': pretty_camera_url(local_config),
                    'msg': utils.pretty_http_error(response)})
            
            return callback(error=utils.pretty_http_error(response))

        callback(motion_detected, capture_fps, monitor_info, response.body)
示例#24
0
    def on_response(response):
        if response.error:
            logging.error(
                "failed to download timelapse movie for remote camera %(id)s on %(url)s: %(msg)s"
                % {"id": camera_id, "url": pretty_camera_url(local_config), "msg": utils.pretty_http_error(response)}
            )

            return callback(error=utils.pretty_http_error(response))

        callback(
            {
                "data": response.body,
                "content_type": response.headers.get("Content-Type"),
                "content_disposition": response.headers.get("Content-Disposition"),
            }
        )
示例#25
0
    def on_response(response):
        if response.error:
            logging.error('failed to take snapshot for camera with id %(id)s: %(msg)s' % {
                    'id': camera_id,
                    'msg': utils.pretty_http_error(response)})

        else:
            logging.debug('successfully took snapshot for camera with id %(id)s' % {'id': camera_id})
示例#26
0
    def on_response(response):
        if response.error:
            logging.error('failed to take snapshot for camera with id %(id)s: %(msg)s' % {
                    'id': camera_id,
                    'msg': utils.pretty_http_error(response)})

        else:
            logging.debug('successfully took snapshot for camera with id %(id)s' % {'id': camera_id})
示例#27
0
    def on_response(response):
        motion_detected = False
        
        cookies = response.headers.get('Set-Cookie')
        if cookies:
            cookies = cookies.split(';')
            cookies = [[i.strip() for i in c.split('=')] for c in cookies]
            cookies = dict([c for c in cookies if len(c) == 2])
            motion_detected = cookies.get('motion_detected_' + str(camera_id)) == 'true'
        
        if response.error:
            logging.error('failed to get current picture for remote camera %(id)s on %(url)s: %(msg)s' % {
                    'id': camera_id,
                    'url': pretty_camera_url(local_config),
                    'msg': utils.pretty_http_error(response)})
            
            return callback(error=utils.pretty_http_error(response))

        callback(motion_detected, response.body)
示例#28
0
    def on_response(response):
        motion_detected = False

        cookies = response.headers.get("Set-Cookie")
        if cookies:
            cookies = cookies.split(";")
            cookies = [[i.strip() for i in c.split("=")] for c in cookies]
            cookies = dict([c for c in cookies if len(c) == 2])
            motion_detected = cookies.get("motion_detected_" + str(camera_id)) == "true"

        if response.error:
            logging.error(
                "failed to get current picture for remote camera %(id)s on %(url)s: %(msg)s"
                % {"id": camera_id, "url": pretty_camera_url(local_config), "msg": utils.pretty_http_error(response)}
            )

            return callback(error=utils.pretty_http_error(response))

        callback(motion_detected, response.body)
示例#29
0
 def on_response(response):
     if response.error:
         logging.error('failed to %(what)s motion detection for camera with id %(id)s: %(msg)s' % {
                 'what': ['disable', 'enable'][enabled],
                 'id': camera_id,
                 'msg': utils.pretty_http_error(response)})
     
     else:
         logging.debug('successfully %(what)s motion detection for camera with id %(id)s' % {
                 'what': ['disabled', 'enabled'][enabled],
                 'id': camera_id})
示例#30
0
    def on_response(response):
        if response.error:
            return callback(error=utils.pretty_http_error(response))

        enabled = bool(response.body.lower().count('active'))
        
        logging.debug('motion detection is %(what)s for camera with id %(id)s' % {
                'what': ['disabled', 'enabled'][enabled],
                'id': camera_id})

        callback(enabled)
示例#31
0
    def on_response(response):
        if response.error:
            logging.error('failed to check timelapse movie status for remote camera %(id)s on %(url)s: %(msg)s' % {
                    'id': camera_id,
                    'url': pretty_camera_url(local_config),
                    'msg': utils.pretty_http_error(response)})

            return callback(error=utils.pretty_http_error(response))
        
        try:
            response = json.loads(response.body)

        except Exception as e:
            logging.error('failed to decode json answer from %(url)s: %(msg)s' % {
                    'url': pretty_camera_url(local_config),
                    'msg': unicode(e)})

            return callback(error=unicode(e))
        
        callback(response)
示例#32
0
    def on_response(response):
        if response.error:
            return callback(error=utils.pretty_http_error(response))

        enabled = bool(response.body.lower().count("active"))

        logging.debug(
            "motion detection is %(what)s for camera with id %(id)s"
            % {"what": ["disabled", "enabled"][enabled], "id": camera_id}
        )

        callback(enabled)
示例#33
0
    def on_response(response):
        if response.error:
            logging.error(
                "failed to %(what)s motion detection for camera with id %(id)s: %(msg)s"
                % {"what": ["disable", "enable"][enabled], "id": camera_id, "msg": utils.pretty_http_error(response)}
            )

        else:
            logging.debug(
                "successfully %(what)s motion detection for camera with id %(id)s"
                % {"what": ["disabled", "enabled"][enabled], "id": camera_id}
            )
示例#34
0
    def on_response(response):
        if response.error:
            logging.error('failed to prepare zip file for group "%(group)s" of remote camera %(id)s on %(url)s: %(msg)s' % {
                    'group': group or 'ungrouped',
                    'id': camera_id,
                    'url': pretty_camera_url(local_config),
                    'msg': utils.pretty_http_error(response)})

            return callback(error=utils.pretty_http_error(response))
        
        try:
            key = json.loads(response.body)['key']

        except Exception as e:
            logging.error('failed to decode json answer from %(url)s: %(msg)s' % {
                    'url': pretty_camera_url(local_config),
                    'msg': unicode(e)})

            return callback(error=unicode(e))

        callback({'key': key})
示例#35
0
    def on_response(response):
        if response.error:
            logging.error(
                "failed to get media list for remote camera %(id)s on %(url)s: %(msg)s"
                % {"id": camera_id, "url": pretty_camera_url(local_config), "msg": utils.pretty_http_error(response)}
            )

            return callback(error=utils.pretty_http_error(response))

        try:
            response = json.loads(response.body)

        except Exception as e:
            logging.error(
                "failed to decode json answer from %(url)s: %(msg)s"
                % {"url": pretty_camera_url(local_config), "msg": unicode(e)}
            )

            return callback(error=unicode(e))

        return callback(response)
示例#36
0
 def on_response(response):
     if response.error:
         logging.error('failed to get config for remote camera %(id)s on %(url)s: %(msg)s' % {
                 'id': camera_id,
                 'url': pretty_camera_url(local_config),
                 'msg': utils.pretty_http_error(response)})
         
         return callback(error=utils.pretty_http_error(response))
 
     try:
         response = json.loads(response.body)
     
     except Exception as e:
         logging.error('failed to decode json answer from %(url)s: %(msg)s' % {
                 'url': pretty_camera_url(local_config),
                 'msg': str(e)})
         
         return callback(error=str(e))
     
     response['host'] = host
     response['port'] = port
         
     callback(response)
示例#37
0
    def on_response(response):
        motion_detected = False

        cookies = response.headers.get('Set-Cookie')
        if cookies:
            cookies = cookies.split(';')
            cookies = [[i.strip() for i in c.split('=')] for c in cookies]
            cookies = dict([c for c in cookies if len(c) == 2])
            motion_detected = cookies.get('motion_detected_' +
                                          str(camera_id)) == 'true'

        if response.error:
            logging.error(
                'failed to get current picture for remote camera %(id)s on %(url)s: %(msg)s'
                % {
                    'id': camera_id,
                    'url': pretty_camera_url(local_config),
                    'msg': utils.pretty_http_error(response)
                })

            return callback(error=utils.pretty_http_error(response))

        callback(motion_detected, response.body)
示例#38
0
    def on_response(response):
        if response.error:
            logging.error('failed to make timelapse movie for group "%(group)s" of remote camera %(id)s with rate %(framerate)s/%(int)s on %(url)s: %(msg)s' % {
                    'group': group or 'ungrouped',
                    'id': camera_id,
                    'url': pretty_camera_url(local_config),
                    'int': interval,
                    'framerate': framerate,
                    'msg': utils.pretty_http_error(response)})

            return callback(error=utils.pretty_http_error(response))
        
        try:
            response = json.loads(response.body)

        except Exception as e:
            logging.error('failed to decode json answer from %(url)s: %(msg)s' % {
                    'url': pretty_camera_url(local_config),
                    'msg': unicode(e)})

            return callback(error=unicode(e))
        
        callback(response)