当前位置: 首页>>代码示例>>Python>>正文


Python web.MissingArgumentError方法代码示例

本文整理汇总了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 
开发者ID:JK-River,项目名称:RobotAIEngine,代码行数:23,代码来源:base.py

示例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()) 
开发者ID:mars-project,项目名称:mars,代码行数:18,代码来源:apihandlers.py

示例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}) 
开发者ID:tao12345666333,项目名称:tornado-zh,代码行数:9,代码来源:web_test.py

示例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)) 
开发者ID:DistributedSystemsGroup,项目名称:zoe,代码行数:41,代码来源:zapp_shop.py

示例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 
开发者ID:DistributedSystemsGroup,项目名称:zoe,代码行数:49,代码来源:zapp_shop.py


注:本文中的tornado.web.MissingArgumentError方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。