Python tornado.web.MissingArgumentError() Examples
The following are 9
code examples of tornado.web.MissingArgumentError().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
tornado.web
, or try the search function
.
Example #1
Source File: apihandlers.py From mars with Apache License 2.0 | 6 votes |
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())
Example #2
Source File: base.py From RobotAIEngine with Apache License 2.0 | 6 votes |
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
Example #3
Source File: web_test.py From tornado-zh with MIT License | 5 votes |
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})
Example #4
Source File: web_test.py From tornado-zh with MIT License | 5 votes |
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})
Example #5
Source File: web_test.py From viewfinder with Apache License 2.0 | 5 votes |
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})
Example #6
Source File: web_test.py From viewfinder with Apache License 2.0 | 5 votes |
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})
Example #7
Source File: zapp_shop.py From zoe with Apache License 2.0 | 5 votes |
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))
Example #8
Source File: web_test.py From EventGhost with GNU General Public License v2.0 | 5 votes |
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})
Example #9
Source File: zapp_shop.py From zoe with Apache License 2.0 | 4 votes |
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