本文整理汇总了Python中web.application方法的典型用法代码示例。如果您正苦于以下问题:Python web.application方法的具体用法?Python web.application怎么用?Python web.application使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类web
的用法示例。
在下文中一共展示了web.application方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: POST
# 需要导入模块: import web [as 别名]
# 或者: from web import application [as 别名]
def POST(self):
"""
Get client key status.
/client/status
"""
# LDAP authentication
is_auth, message = tools.ldap_authentification(SERVER_OPTS)
if not is_auth:
return tools.response_render(message, http_code='401 Unauthorized')
payload, message = tools.data2map()
if message:
return tools.response_render(message, http_code='400 Bad Request')
if 'realname' in payload:
realname = unquote_plus(payload['realname'])
else:
return tools.response_render(
'Error: No realname option given.',
http_code='400 Bad Request')
return tools.response_render(
TOOLS.list_keys(realname=realname),
content_type='application/json')
示例2: GET
# 需要导入模块: import web [as 别名]
# 或者: from web import application [as 别名]
def GET(self, account=None, name=None):
"""
Retrieve a subscription.
HTTP Success:
200 OK
HTTP Error:
404 Not Found
500 Internal Error
406 Not Acceptable
:param account: The account name.
:param name: The subscription name.
"""
header('Content-Type', 'application/x-json-stream')
try:
for subscription in list_subscriptions(name=name, account=account):
yield dumps(subscription, cls=APIEncoder) + '\n'
except SubscriptionNotFound as error:
raise generate_http_error(404, 'SubscriptionNotFound', error.args[0])
except Exception as error:
raise InternalError(error)
示例3: GET
# 需要导入模块: import web [as 别名]
# 或者: from web import application [as 别名]
def GET(self, rse):
"""
List dataset replicas replicas.
HTTP Success:
200 OK
HTTP Error:
401 Unauthorized
406 Not Acceptable
500 InternalError
:returns: A dictionary containing all replicas on the RSE.
"""
header('Content-Type', 'application/x-json-stream')
try:
for row in list_datasets_per_rse(rse=rse):
yield dumps(row, cls=APIEncoder) + '\n'
except RucioException as error:
raise generate_http_error(500, error.__class__.__name__, error.args[0])
except Exception as error:
print(format_exc())
raise InternalError(error)
示例4: GET
# 需要导入模块: import web [as 别名]
# 或者: from web import application [as 别名]
def GET(self):
"""
Retrieve all exceptions.
HTTP Success:
200 OK
HTTP Error:
404 Not Found
406 Not Acceptable
500 Internal Error
"""
header('Content-Type', 'application/x-json-stream')
try:
for exception in list_exceptions():
yield dumps(exception, cls=APIEncoder) + '\n'
except LifetimeExceptionNotFound as error:
raise generate_http_error(404, 'LifetimeExceptionNotFound', error.args[0])
except RucioException as error:
raise generate_http_error(500, error.__class__.__name__, error.args[0])
except Exception as error:
raise InternalError(error)
示例5: GET
# 需要导入模块: import web [as 别名]
# 或者: from web import application [as 别名]
def GET(self, scope, name):
"""
List archive content keys.
HTTP Success:
200 Success
HTTP Error:
406 Not Acceptable
"""
header('Content-Type', 'application/x-json-stream')
try:
for file in list_archive_content(scope=scope, name=name):
yield dumps(file) + '\n'
except Exception as error:
print(format_exc())
raise InternalError(error)
示例6: GET
# 需要导入模块: import web [as 别名]
# 或者: from web import application [as 别名]
def GET(self, scope, name):
""" List all parents of a data identifier.
HTTP Success:
200 OK
HTTP Error:
401 Unauthorized
406 Not Acceptable
500 InternalError
:returns: A list of dictionary containing all dataset information.
"""
header('Content-Type', 'application/x-json-stream')
try:
for dataset in list_parent_dids(scope=scope, name=name):
yield render_json(**dataset) + "\n"
except DataIdentifierNotFound as error:
raise generate_http_error(404, 'DataIdentifierNotFound', error.args[0])
except RucioException as error:
raise generate_http_error(500, error.__class__.__name__, error.args[0])
except Exception as error:
print(format_exc())
raise InternalError(error)
示例7: GET
# 需要导入模块: import web [as 别名]
# 或者: from web import application [as 别名]
def GET(self):
"""
List all heartbeats.
HTTP Success:
200 OK
HTTP Error:
401 Unauthorized
406 Not Acceptable
"""
header('Content-Type', 'application/json')
return json.dumps(list_heartbeats(issuer=ctx.env.get('issuer')),
cls=APIEncoder)
示例8: GET
# 需要导入模块: import web [as 别名]
# 或者: from web import application [as 别名]
def GET(self, rule_id):
""" get locks for a given rule_id.
HTTP Success:
200 OK
HTTP Error:
404 Not Found
406 Not Acceptable
500 InternalError
:returns: JSON dict containing informations about the requested user.
"""
header('Content-Type', 'application/x-json-stream')
try:
locks = get_replica_locks_for_rule_id(rule_id)
except RucioException as error:
raise generate_http_error(500, error.__class__.__name__, error.args[0])
except Exception as error:
raise InternalError(error)
for lock in locks:
yield dumps(lock, cls=APIEncoder) + '\n'
示例9: GET
# 需要导入模块: import web [as 别名]
# 或者: from web import application [as 别名]
def GET(self):
"""
Return ca.
"""
return tools.response_render(
open(SERVER_OPTS['ca'] + '.pub', 'rb'),
content_type='application/octet-stream')