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)
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)
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)
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})
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)
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)
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})
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()
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()
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()
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()
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()
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') })
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)
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)
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()
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)
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"), } )
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})
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)
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)
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})
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)
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)
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)
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} )
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})
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)
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)
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)
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)