本文整理汇总了Python中tornado.web.MissingArgumentError方法的典型用法代码示例。如果您正苦于以下问题:Python web.MissingArgumentError方法的具体用法?Python web.MissingArgumentError怎么用?Python web.MissingArgumentError使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tornado.web
的用法示例。
在下文中一共展示了web.MissingArgumentError方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: exception_control
# 需要导入模块: from tornado import web [as 别名]
# 或者: from tornado.web import MissingArgumentError [as 别名]
def exception_control(func):
''' 异常控制装饰器
'''
@functools.wraps(func)
def wrapper(self):
''' 装饰函数
'''
try:
code, msg, body = E_SUCC, "OK", func(self)
except (MissingArgumentError, AssertionError) as ex:
code, msg, body = E_PARAM, str(ex), None
except tornado.web.HTTPError:
raise
except Exception as ex:
code, msg, body = E_INTER, str(ex), None
log_msg = self.request.uri \
if self.request.files else \
"%s %s" % (self.request.uri, self.request.body)
logging.error(log_msg, exc_info=True)
self.send_json(body, code, msg)
return wrapper
示例2: post
# 需要导入模块: from tornado import web [as 别名]
# 或者: from tornado.web import MissingArgumentError [as 别名]
def post(self, session_id):
try:
graph = self.get_argument('graph')
target = self.get_argument('target').split(',')
names = self.get_argument('names', default='').split(',')
compose = bool(int(self.get_argument('compose', '1')))
except web.MissingArgumentError as ex:
self.write(json.dumps(dict(msg=str(ex))))
raise web.HTTPError(400, reason='Argument missing')
try:
graph_key = tokenize(str(uuid.uuid4()))
self.web_api.submit_graph(session_id, graph, graph_key, target, names=names, compose=compose)
self.write(json.dumps(dict(graph_key=graph_key)))
except: # noqa: E722
self._dump_exception(sys.exc_info())
示例3: get
# 需要导入模块: from tornado import web [as 别名]
# 或者: from tornado.web import MissingArgumentError [as 别名]
def get(self):
try:
self.get_argument('foo')
self.write({})
except MissingArgumentError as e:
self.write({'arg_name': e.arg_name,
'log_message': e.log_message})
示例4: post
# 需要导入模块: from tornado import web [as 别名]
# 或者: from tornado.web import MissingArgumentError [as 别名]
def post(self, zapp_id):
"""Write the parameters in the description and start the ZApp."""
if self.current_user is None:
return
manifest_index = int(zapp_id.split('-')[-1])
zapp_id = "-".join(zapp_id.split('-')[:-1])
zapps = zapp_shop.zshop_read_manifest(zapp_id)
zapp = zapps[manifest_index]
exec_name = self.get_argument('exec_name')
if self.current_user.role.can_customize_resources:
app_descr = self._set_parameters(zapp.zoe_description, zapp.parameters)
else:
app_descr = zapp.zoe_description
if len(zapp.labels) > 0:
for service in app_descr['services']:
if 'labels' in service:
service['labels'].append(zapp.labels)
else:
service['labels'] = zapp.labels
try:
self.get_argument('download_json')
self.set_header('Content-Type', 'application/json')
self.set_header('Content-Disposition', 'attachment; filename={}.json'.format(zapp_id))
self.write(app_descr)
self.finish()
return
except MissingArgumentError:
try:
new_id = self.api_endpoint.execution_start(self.current_user, exec_name, app_descr)
except ZoeException as e:
self.error_page(e.message, 500)
return
self.redirect(self.reverse_url('execution_inspect', new_id))
示例5: _set_parameters
# 需要导入模块: from tornado import web [as 别名]
# 或者: from tornado.web import MissingArgumentError [as 别名]
def _set_parameters(self, app_descr, params):
for param in params:
argument_name = param.name + '-' + param.kind
if param.kind == 'environment':
for service in app_descr['services']:
for env in service['environment']:
if env[0] == param.name:
env[1] = self.get_argument(argument_name)
elif param.kind == 'command':
for service in app_descr['services']:
if service['name'] == param.name:
service['command'] = self.get_argument(argument_name)
break
elif param.kind == 'service_count':
for service in app_descr['services']:
if service['name'] == param.name:
service['total_count'] = int(self.get_argument(argument_name))
service['essential_count'] = int(self.get_argument(argument_name))
else:
log.warning('Unknown parameter kind: {}, ignoring...'.format(param.kind))
for service in app_descr['services']:
argument_name = service['name'] + '-resource_memory_min'
try:
self.get_argument(argument_name)
except MissingArgumentError:
pass
else:
if float(self.get_argument(argument_name)) >= get_conf().max_memory_limit:
val = int(get_conf().max_memory_limit * (1024 ** 3))
else:
val = int(float(self.get_argument(argument_name)) * (1024 ** 3))
service["resources"]["memory"]["min"] = val
argument_name = service['name'] + '-resource_cores_min'
try:
self.get_argument(argument_name)
except MissingArgumentError:
pass
else:
if float(self.get_argument(argument_name)) >= get_conf().max_core_limit:
val = get_conf().max_core_limit
else:
val = float(self.get_argument(argument_name))
service["resources"]["cores"]["min"] = val
return app_descr