當前位置: 首頁>>代碼示例>>Python>>正文


Python inputs.boolean方法代碼示例

本文整理匯總了Python中flask_restful.inputs.boolean方法的典型用法代碼示例。如果您正苦於以下問題:Python inputs.boolean方法的具體用法?Python inputs.boolean怎麽用?Python inputs.boolean使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在flask_restful.inputs的用法示例。


在下文中一共展示了inputs.boolean方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: put

# 需要導入模塊: from flask_restful import inputs [as 別名]
# 或者: from flask_restful.inputs import boolean [as 別名]
def put(self, deployment_id, **kwargs):
        """
        Create a deployment
        """
        validate_inputs({'deployment_id': deployment_id})
        request_schema = self.create_request_schema()
        request_dict = get_json_and_verify_params(request_schema)
        blueprint_id = request_dict['blueprint_id']
        bypass_maintenance = is_bypass_maintenance_mode()
        args = get_args_and_verify_arguments(
            [Argument('private_resource', type=boolean,
                      default=False)]
        )
        deployment = get_resource_manager().create_deployment(
            blueprint_id,
            deployment_id,
            private_resource=args.private_resource,
            visibility=None,
            inputs=request_dict.get('inputs', {}),
            bypass_maintenance=bypass_maintenance,
            skip_plugins_validation=self.get_skip_plugin_validation_flag(
                request_dict)
        )
        return deployment, 201 
開發者ID:cloudify-cosmo,項目名稱:cloudify-manager,代碼行數:26,代碼來源:deployments.py

示例2: post

# 需要導入模塊: from flask_restful import inputs [as 別名]
# 或者: from flask_restful.inputs import boolean [as 別名]
def post(self, **kwargs):
        """
        Create provider context
        """
        request_dict = get_json_and_verify_params({'context', 'name'})
        args = get_args_and_verify_arguments(
            [Argument('update', type=boolean, default=False)]
        )
        update = args['update']
        context = dict(
            id=PROVIDER_CONTEXT_ID,
            name=request_dict['name'],
            context=request_dict['context']
        )

        status_code = 200 if update else 201

        try:
            get_resource_manager().update_provider_context(update, context)
            return dict(status='ok'), status_code
        except dsl_parser_utils.ResolverInstantiationError as ex:
            raise manager_exceptions.ResolverInstantiationError(str(ex)) 
開發者ID:cloudify-cosmo,項目名稱:cloudify-manager,代碼行數:24,代碼來源:provider_context.py

示例3: get_request_data

# 需要導入模塊: from flask_restful import inputs [as 別名]
# 或者: from flask_restful.inputs import boolean [as 別名]
def get_request_data() -> reqparse.Namespace:
    "Returns data about a new post request."

    parser = reqparse.RequestParser()
    parser.add_argument("subject", type=str)
    parser.add_argument("body", type=str, required=True)
    parser.add_argument("useslip", type=inputs.boolean)
    parser.add_argument("spoiler", type=inputs.boolean)

    if not on_captcha_cooldown():
        captcha_method = app.config.get("CAPTCHA_METHOD")
        if captcha_method == "RECAPTCHA":
            parser.add_argument("recaptcha-token", type=str, required=True)
        elif captcha_method == "CAPTCHOULI":
            parser.add_argument("captchouli-id", type=str, required=True)
            for i in range(9):
                # For each image square
                parser.add_argument(f"captchouli-{i}", type=str, default=False)

    return parser.parse_args() 
開發者ID:DangerOnTheRanger,項目名稱:maniwani,代碼行數:22,代碼來源:NewPost.py

示例4: __init__

# 需要導入模塊: from flask_restful import inputs [as 別名]
# 或者: from flask_restful.inputs import boolean [as 別名]
def __init__(self, **kwargs):
        self.restapi = kwargs['restapi']
        self.server = kwargs['server']
        self.fields = {
            'host': fields.String,
            'eui': fields.Integer,
            'name': fields.String,
            'enabled': fields.Boolean,
            'power': fields.Integer,
            'created': fields.DateTime(dt_format='iso8601'),
            'updated': fields.DateTime(dt_format='iso8601')
        }
        self.parser = reqparse.RequestParser(bundle_errors=True)
        self.parser.add_argument('host', type=str)
        self.parser.add_argument('eui', type=int)
        self.parser.add_argument('name', type=str)
        self.parser.add_argument('enabled', type=inputs.boolean)
        self.parser.add_argument('power', type=int)
        self.args = self.parser.parse_args() 
開發者ID:Fluent-networks,項目名稱:floranet,代碼行數:21,代碼來源:gateway.py

示例5: delete

# 需要導入模塊: from flask_restful import inputs [as 別名]
# 或者: from flask_restful.inputs import boolean [as 別名]
def delete(self, deployment_id, **kwargs):
        """
        Delete deployment by id
        """
        args = get_args_and_verify_arguments(
            [Argument('ignore_live_nodes', type=boolean,
                      default=False),
             Argument('delete_db_mode', type=boolean,
                      default=False),
             Argument('delete_logs', type=boolean,
                      default=False)]
        )

        bypass_maintenance = is_bypass_maintenance_mode()
        deployment = get_resource_manager().delete_deployment(
            deployment_id,
            bypass_maintenance,
            args.ignore_live_nodes,
            args.delete_db_mode,
            args.delete_logs)

        if args.delete_db_mode:
            # Delete deployment resources from file server
            deployment_folder = os.path.join(
                config.instance.file_server_root,
                FILE_SERVER_DEPLOYMENTS_FOLDER,
                utils.current_tenant.name,
                deployment.id)
            if os.path.exists(deployment_folder):
                shutil.rmtree(deployment_folder)
        return deployment, 200 
開發者ID:cloudify-cosmo,項目名稱:cloudify-manager,代碼行數:33,代碼來源:deployments.py

示例6: get

# 需要導入模塊: from flask_restful import inputs [as 別名]
# 或者: from flask_restful.inputs import boolean [as 別名]
def get(self, _include=None, **kwargs):
        """List executions"""
        args = get_args_and_verify_arguments(
            [Argument('deployment_id', required=False),
             Argument('include_system_workflows', type=boolean,
                      default=False)]
        )
        deployment_id_filter = ResourceManager.create_filters_dict(
            deployment_id=args.deployment_id)
        return get_resource_manager().list_executions(
            is_include_system_workflows=args.include_system_workflows,
            include=_include,
            filters=deployment_id_filter).items 
開發者ID:cloudify-cosmo,項目名稱:cloudify-manager,代碼行數:15,代碼來源:executions.py

示例7: delete

# 需要導入模塊: from flask_restful import inputs [as 別名]
# 或者: from flask_restful.inputs import boolean [as 別名]
def delete(self, blueprint_id, **kwargs):
        """
        Delete blueprint by id
        """
        query_args = get_args_and_verify_arguments(
            [Argument('force', type=boolean, default=False)])
        blueprint = get_resource_manager().delete_blueprint(
            blueprint_id,
            force=query_args.force)
        return blueprint, 200 
開發者ID:cloudify-cosmo,項目名稱:cloudify-manager,代碼行數:12,代碼來源:blueprints.py

示例8: put

# 需要導入模塊: from flask_restful import inputs [as 別名]
# 或者: from flask_restful.inputs import boolean [as 別名]
def put(self, deployment_id, **kwargs):
        """
        Create a deployment
        """
        rest_utils.validate_inputs({'deployment_id': deployment_id})
        request_schema = self.create_request_schema()
        request_dict = rest_utils.get_json_and_verify_params(request_schema)
        blueprint_id = request_dict['blueprint_id']
        bypass_maintenance = is_bypass_maintenance_mode()
        args = rest_utils.get_args_and_verify_arguments(
            [Argument('private_resource', type=boolean)]
        )
        visibility = rest_utils.get_visibility_parameter(
            optional=True,
            valid_values=VisibilityState.STATES
        )
        deployment = get_resource_manager().create_deployment(
            blueprint_id,
            deployment_id,
            inputs=request_dict.get('inputs', {}),
            bypass_maintenance=bypass_maintenance,
            private_resource=args.private_resource,
            visibility=visibility,
            skip_plugins_validation=self.get_skip_plugin_validation_flag(
                request_dict),
            site_name=_get_site_name(request_dict),
            runtime_only_evaluation=request_dict.get(
                'runtime_only_evaluation', False)
        )
        return deployment, 201 
開發者ID:cloudify-cosmo,項目名稱:cloudify-manager,代碼行數:32,代碼來源:deployments.py

示例9: _prepare_and_submit_blueprint

# 需要導入模塊: from flask_restful import inputs [as 別名]
# 或者: from flask_restful.inputs import boolean [as 別名]
def _prepare_and_submit_blueprint(cls,
                                      file_server_root,
                                      app_dir,
                                      blueprint_id,
                                      visibility):
        args = get_args_and_verify_arguments([
            Argument('private_resource', type=boolean),
            Argument('visibility'),
            Argument('application_file_name',
                     default='')])

        app_file_name = cls._extract_application_file(
            file_server_root, app_dir, args.application_file_name)

        # add to blueprints manager (will also dsl_parse it)
        try:
            blueprint = get_resource_manager().publish_blueprint(
                app_dir,
                app_file_name,
                file_server_root,
                blueprint_id,
                args.private_resource,
                visibility
            )

            # moving the app directory in the file server to be under a
            # directory named after the blueprint id
            tenant_dir = os.path.join(
                file_server_root,
                FILE_SERVER_BLUEPRINTS_FOLDER,
                current_tenant.name)
            mkdirs(tenant_dir)
            shutil.move(os.path.join(file_server_root, app_dir),
                        os.path.join(tenant_dir, blueprint.id))
            cls._process_plugins(file_server_root, blueprint.id)
            return blueprint
        except manager_exceptions.DslParseException as ex:
            shutil.rmtree(os.path.join(file_server_root, app_dir))
            raise manager_exceptions.InvalidBlueprintError(
                'Invalid blueprint - {0}'.format(ex)) 
開發者ID:cloudify-cosmo,項目名稱:cloudify-manager,代碼行數:42,代碼來源:upload_manager.py

示例10: post

# 需要導入模塊: from flask_restful import inputs [as 別名]
# 或者: from flask_restful.inputs import boolean [as 別名]
def post(self):
        """Creates new user account if provided valid arguments"""
        parser = reqparse.RequestParser()
        parser.add_argument('email', type=UserValidator.create('unique_email'), required=True)
        parser.add_argument('username', type=UserValidator.create('unique_username'))
        parser.add_argument('password', type=UserValidator.create('password'))
        parser.add_argument('remember', type=inputs.boolean, default=False)
        args = parser.parse_args()

        user_db = auth.create_user_db(
            auth_id=None,
            name='',
            username=args.username,
            email=args.email,
            verified=True if not config.CONFIG_DB.verify_email else False,
            password=args.password
        )
        user_db.put()

        if config.CONFIG_DB.verify_email:
            task.verify_user_email_notification(user_db)
            return make_empty_ok_response()

        # if users don't need to verify email, we automaticaly signin newly registered user
        auth.signin_user_db(user_db, remember=args.remember)
        return user_db.to_dict(include=User.get_private_properties()) 
開發者ID:madvas,項目名稱:gae-angular-material-starter,代碼行數:28,代碼來源:auth_api.py

示例11: parse_signin

# 需要導入模塊: from flask_restful import inputs [as 別名]
# 或者: from flask_restful.inputs import boolean [as 別名]
def parse_signin(func):
    """Parses credentials posted by client and loads appropriate user from datastore"""
    @functools.wraps(func)
    def decorated_function(*args, **kwargs): # pylint: disable=missing-docstring
        parser = reqparse.RequestParser()
        parser.add_argument('login', type=str, required=True)
        parser.add_argument('password', type=model.UserValidator.create('password'), required=True)
        parser.add_argument('remember', type=inputs.boolean, default=False)
        g.args = parser.parse_args()
        g.user_db = model.User.get_by_credentials(g.args.login, g.args.password)
        return func(*args, **kwargs)

    return decorated_function 
開發者ID:madvas,項目名稱:gae-angular-material-starter,代碼行數:15,代碼來源:decorators.py

示例12: save_request_params

# 需要導入模塊: from flask_restful import inputs [as 別名]
# 或者: from flask_restful.inputs import boolean [as 別名]
def save_request_params():
    """Function temporily saves 'remember' url parameter into users session.
    This is useful when we login via oauth, so redirects would wipe out our url parameters."""
    parser = reqparse.RequestParser()
    parser.add_argument('remember', type=inputs.boolean, default=False)
    args = parser.parse_args()
    flask.session['auth-params'] = {
        'remember': args.remember,
    } 
開發者ID:madvas,項目名稱:gae-angular-material-starter,代碼行數:11,代碼來源:auth.py

示例13: __init__

# 需要導入模塊: from flask_restful import inputs [as 別名]
# 或者: from flask_restful.inputs import boolean [as 別名]
def __init__(self, **kwargs):
        self.restapi = kwargs['restapi']
        self.server = kwargs['server']
        self.fields = {
            'deveui': fields.Integer,
            'name': fields.String,
            'devclass': fields.String,
            'enabled': fields.Boolean,
            'otaa': fields.Boolean,
            'devaddr': fields.Integer,
            'appeui': fields.Integer,
            'appskey': fields.Integer,
            'nwkskey': fields.Integer,
            'tx_datr': fields.String,
            'snr_average': fields.Float,
            'appname': fields.String,
            'latitude': fields.Float,
            'longitude': fields.Float,
            'created': fields.DateTime(dt_format='iso8601'),
            'updated': fields.DateTime(dt_format='iso8601')
        }
        self.parser = reqparse.RequestParser(bundle_errors=True)
        self.parser.add_argument('deveui', type=int)
        self.parser.add_argument('name', type=str)
        self.parser.add_argument('devclass', type=str)
        self.parser.add_argument('enabled', type=inputs.boolean)
        self.parser.add_argument('otaa', type=inputs.boolean)
        self.parser.add_argument('devaddr', type=int)
        self.parser.add_argument('appeui', type=int)
        self.parser.add_argument('nwkskey', type=int)
        self.parser.add_argument('appskey', type=int)
        self.parser.add_argument('appname', type=str)
        self.parser.add_argument('latitude', type=float)
        self.parser.add_argument('longitude', type=float)
        self.args = self.parser.parse_args() 
開發者ID:Fluent-networks,項目名稱:floranet,代碼行數:37,代碼來源:device.py

示例14: _prepare_and_process_doc

# 需要導入模塊: from flask_restful import inputs [as 別名]
# 或者: from flask_restful.inputs import boolean [as 別名]
def _prepare_and_process_doc(self,
                                 data_id,
                                 file_server_root,
                                 archive_target_path,
                                 **kwargs):

        # support previous implementation
        wagon_target_path = archive_target_path

        # handle the archive_target_path, which may be zip or wagon
        if not self._is_wagon_file(archive_target_path):
            if not zipfile.is_zipfile(archive_target_path):
                raise manager_exceptions.InvalidPluginError(
                    'input can be only a wagon or a zip file.')
            archive_name = unzip(archive_target_path,
                                 logger=current_app.logger)
            os.remove(archive_target_path)
            shutil.move(archive_name, archive_target_path)
            try:
                wagon_target_path, _ = \
                    self._verify_archive(archive_target_path)
            except RuntimeError as re:
                raise manager_exceptions.InvalidPluginError(re.message)

        args = get_args_and_verify_arguments([
            Argument('title'),
            Argument('private_resource', type=boolean),
            Argument('visibility')])

        visibility = kwargs.get(_VISIBILITY, None)
        new_plugin = self._create_plugin_from_archive(data_id,
                                                      args.title,
                                                      wagon_target_path,
                                                      args.private_resource,
                                                      visibility)
        filter_by_name = {'package_name': new_plugin.package_name}
        sm = get_resource_manager().sm
        plugins = sm.list(Plugin, filters=filter_by_name)

        for plugin in plugins:
            if plugin.archive_name == new_plugin.archive_name:
                raise manager_exceptions.ConflictError(
                    'a plugin archive by the name of {archive_name} already '
                    'exists for package with name {package_name} and version '
                    '{version}'.format(archive_name=new_plugin.archive_name,
                                       package_name=new_plugin.package_name,
                                       version=new_plugin.package_version))
            if is_plugin_installing(new_plugin, plugin):
                raise manager_exceptions.ConflictError(
                    'a plugin archive by the name of {archive_name} for '
                    'package with name {package_name} and version {version} '
                    'is currently being installed'.format(
                        archive_name=new_plugin.archive_name,
                        package_name=new_plugin.package_name,
                        version=new_plugin.package_version))
        dest_path = new_plugin.archive_name
        new_plugin.archive_name = '{0}{1}'.format(INSTALLING_PREFIX,
                                                  new_plugin.archive_name)
        sm.put(new_plugin)
        return new_plugin, dest_path 
開發者ID:cloudify-cosmo,項目名稱:cloudify-manager,代碼行數:62,代碼來源:upload_manager.py


注:本文中的flask_restful.inputs.boolean方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。