예제 #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
파일: remote.py 프로젝트: garyni/motioneye
 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
파일: remote.py 프로젝트: garyni/motioneye
 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
파일: remote.py 프로젝트: garyni/motioneye
 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
파일: remote.py 프로젝트: garyni/motioneye
 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
파일: remote.py 프로젝트: garyni/motioneye
    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
파일: remote.py 프로젝트: garyni/motioneye
    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
파일: remote.py 프로젝트: garyni/motioneye
    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
파일: remote.py 프로젝트: garyni/motioneye
    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
파일: remote.py 프로젝트: garyni/motioneye
    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)