本文整理汇总了Python中utils.pretty_http_error函数的典型用法代码示例。如果您正苦于以下问题:Python pretty_http_error函数的具体用法?Python pretty_http_error怎么用?Python pretty_http_error使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pretty_http_error函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: on_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)
示例2: on_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)
示例3: on_response
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()
示例4: on_response
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})
示例5: on_response
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})
示例6: on_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)