當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。