Python tornado.web 模块,MissingArgumentError() 实例源码

我们从Python开源项目中,提取了以下23个代码示例,用于说明如何使用tornado.web.MissingArgumentError()

项目:globibot    作者:best-coloc-ever    | 项目源码 | 文件源码
def with_query_parameters(*parameter_names):

    def wrapped(method):

        @wraps(method)
        def call(self, *args, **kwargs):
            try:
                for param in parameter_names:
                    kwargs[param] = self.get_query_argument(param)

                return method(self, *args, **kwargs)
            except MissingArgumentError:
                self.set_status(HTTPStatus.BAD_REQUEST)

        return call

    return wrapped
项目:globibot    作者:best-coloc-ever    | 项目源码 | 文件源码
def with_body_arguments(*parameter_names):

    def wrapped(method):

        @wraps(method)
        def call(self, *args, **kwargs):
            try:
                for param in parameter_names:
                    kwargs[param] = self.get_body_argument(param)

                return method(self, *args, **kwargs)
            except MissingArgumentError:
                self.set_status(HTTPStatus.BAD_REQUEST)

        return call

    return wrapped
项目:RobotAIEngine    作者:JK-River    | 项目源码 | 文件源码
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
项目:mlc    作者:valiro21    | 项目源码 | 文件源码
def view_output(self):
        """
        Returns the output_file of testcase
        specified in GET request
        """

        try:
            id = int(self.get_argument('id'))
            session = self.acquire_sql_session()
            testcase = TestcaseRepository.get_by_id(session, id)

        except MissingArgumentError:
            raise HTTPError(404, 'No id specified')

        except SQLAlchemyError:
            raise HTTPError(500, 'Database error, could not find specified id')

        except:
            raise HTTPError(500, 'Shit happened')

        # Sends the actual file data
        self.write(testcase.output_file)
        session.close()
项目:noc-orchestrator    作者:DirceuSilvaLabs    | 项目源码 | 文件源码
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})
项目:noc-orchestrator    作者:DirceuSilvaLabs    | 项目源码 | 文件源码
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})
项目:noc-orchestrator    作者:DirceuSilvaLabs    | 项目源码 | 文件源码
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})
项目:calm    作者:bagrat    | 项目源码 | 文件源码
def _get_query_args(self, handler_def):
        """Retreives the values for query arguments."""
        query_args = {}
        for qarg in handler_def.query_args:
            try:
                query_args[qarg.name] = self.get_query_argument(qarg.name)
            except MissingArgumentError:
                if not qarg.required:
                    continue

                raise BadRequestError(
                    "Missing required query argument '{}'".format(qarg.name)
                )

        return query_args
项目:query-srv    作者:openpermissions    | 项目源码 | 文件源码
def get(self, repository_id=None, entity_type=None, entity_id=None):
        if repository_id is None:
            try:
                hub_key = self.get_query_argument('hub_key')
            except MissingArgumentError:
                raise HTTPError(400, 'hub_key parameter is required')

            try:
                parts = parse_hub_key(hub_key)
            except ValueError:
                raise HTTPError(404, 'Invalid hub key')

            if parts['schema_version'] == 's0':
                raise HTTPError(404, 'Only hub keys matching '
                                'schema >= s1 are supported')
        else:
            parts = {
                'repository_id': repository_id,
                'entity_type': entity_type,
                'entity_id': entity_id
            }

        try:
            entity = yield get_entity(parts['repository_id'],
                                      parts['entity_type'],
                                      parts['entity_id'])
        except httpclient.HTTPError, e:
            raise HTTPError(e.code, e.message)

        if not entity:
            raise HTTPError(404, 'Not found')

        self.finish({'status': 200, 'data': entity})
项目:My-Web-Server-Framework-With-Python2.7    作者:syjsu    | 项目源码 | 文件源码
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})
项目:annotated-py-tornado    作者:hhstore    | 项目源码 | 文件源码
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})
项目:annotated-py-tornado    作者:hhstore    | 项目源码 | 文件源码
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})
项目:annotated-py-tornado    作者:hhstore    | 项目源码 | 文件源码
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})
项目:projects-2017-2    作者:ncss    | 项目源码 | 文件源码
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})
项目:aweasome_learning    作者:Knight-ZXW    | 项目源码 | 文件源码
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})
项目:zenchmarks    作者:squeaky-pl    | 项目源码 | 文件源码
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})
项目:browser_vuln_check    作者:lcatro    | 项目源码 | 文件源码
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})
项目:PyQYT    作者:collinsctk    | 项目源码 | 文件源码
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})
项目:mlc    作者:valiro21    | 项目源码 | 文件源码
def view_input(self):
        """
        Returns the input_file of testcase
        specified in GET request
        """

        try:
            id = int(self.get_argument('id'))
            session = self.acquire_sql_session()
            try:
                testcase = TestcaseRepository.get_by_id(session, id)
            except SQLAlchemyError:
                raise HTTPError(400, 'Testcase with specified '
                                     'id does not exist.')

        except MissingArgumentError:
            raise HTTPError(404, 'No id specified.')
        except HTTPError:
            raise
        except SQLAlchemyError:
            raise HTTPError(500, 'Database error, could not '
                                 'find specified id.')
        except:
            raise HTTPError(500, 'Unexpected error')

        # Sends the actual file data
        self.write(testcase.input_file)
        session.close()
项目:mlc    作者:valiro21    | 项目源码 | 文件源码
def edit_dataset(self):
        """
        Renders the page for editing a dataset.
        """

        try:
            id = int(self.get_argument('id'))
            session = self.acquire_sql_session()

            try:
                dataset = DatasetRepository.get_by_id(session, id)
            except:
                raise HTTPError(404, 'Specified id doesn\'t exist')

        except MissingArgumentError:
            raise HTTPError(404, 'No id specified')
        except SQLAlchemyError:
            raise HTTPError(500, 'Database error occured.')
        except HTTPError:
            raise
        except:
            raise HTTPError(500, 'Unexpected error occured')

        self.render('dataset_edit.html',
                    dataset=dataset)
        session.close()
项目:ProgrameFacil    作者:Gpzim98    | 项目源码 | 文件源码
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})
项目:ProgrameFacil    作者:Gpzim98    | 项目源码 | 文件源码
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})
项目:mlc    作者:valiro21    | 项目源码 | 文件源码
def delete_testcase(self):
        """
        Deletes testcase specified by id from POST request
        """

        try:
            session = self.acquire_sql_session()
        except:
            raise HTTPError(500, 'Could not acquire database session.')

        try:
            # Get argument from request
            id = int(self.get_argument('id'))

            try:
                # Try to delete the testcase
                TestcaseRepository.delete_by_id(session, id)
            except SQLAlchemyError:
                traceback.print_exc()
                raise HTTPError(400, 'Testcase with specified id '
                                     'does not exist.')
            session.commit()

        except MissingArgumentError as e:
            traceback.print_exc()
            self.set_status(400)
            self.write('Id not specified in request.')
            return

        except SQLAlchemyError as e:
            traceback.print_exc()
            self.set_status(500)
            self.write('Databse error occured.')
            return

        except HTTPError:
            raise

        except:
            traceback.print_exc()
            self.set_status(500)
            self.write('Unexpected error occured.')
            return

        finally:
            session.close()

        self.write('Success!')