Exemplo n.º 1
0
    def addConfig(self, args):
        """
            Adds the given variable and value to the config addon.
        """
        app_name, deployment_name = self.parse_app_deployment_name(args.name)
        if not deployment_name:
            deployment_name = "default"
        if not args.variables:
            raise InputErrorException("NoVariablesGiven")

        args_variables, force = extract_flag_from_variables(args.variables, ("-f", "--force"), args.force_add)

        variables = parse_config_variables(args_variables, "add")

        try:
            self.api.update_addon(
                app_name, deployment_name, CONFIG_ADDON, CONFIG_ADDON, settings=variables, force=force
            )
        except GoneError:
            # Add addon if it didn't exist.
            self.api.create_addon(app_name, deployment_name, CONFIG_ADDON, variables)
        except ThrottledError as te:
            # Overwrite the variable if didn't force, but type Yes
            question = raw_input(
                "{0} Do you really want to overwrite it? "
                'Type "Yes" without the quotes to proceed: '.format(te.message)
            )
            if question.lower() == "yes":
                self.api.update_addon(
                    app_name, deployment_name, CONFIG_ADDON, CONFIG_ADDON, settings=variables, force=True
                )

        return True
Exemplo n.º 2
0
    def removeConfig(self, args):
        """
            Remove the given variable if it exists.
        """
        app_name, deployment_name = self.parse_app_deployment_name(args.name)
        if not deployment_name:
            deployment_name = "default"
        if not args.variables:
            raise InputErrorException("NoVariablesGiven")

        variables = parse_config_variables(args.variables, "remove")

        try:
            self.api.update_addon(app_name, deployment_name, CONFIG_ADDON, CONFIG_ADDON, settings=variables)
        except GoneError:
            raise InputErrorException("WrongAddon")

        return True
Exemplo n.º 3
0
Arquivo: app.py Projeto: vervas/cctrl
    def addConfig(self, args):
        """
            Adds the given variable and value to the config addon.
        """
        #noinspection PyTupleAssignmentBalance
        app_name, deployment_name = self.parse_app_deployment_name(args.name)
        if not deployment_name:
            raise InputErrorException('NoDeployment')
        if not args.variables:
            raise InputErrorException('NoVariablesGiven')

        variables = parse_config_variables(args.variables, 'add')
        force = args.force_add

        try:
            self.api.update_addon(
                app_name,
                deployment_name,
                'config.free',
                'config.free',
                settings=variables,
                force=force)
        except GoneError:
            # Add addon if it didn't exist.
            self.api.create_addon(app_name, deployment_name, 'config.free', variables)
        except ThrottledError as te:
            # Overwrite the variable if didn't force, but type Yes
            question = raw_input('{} Do you really want to overwrite it? ' \
                                    'Type "Yes" without the quotes to proceed: '.format(te.message))
            if question.lower() == 'yes':
                self.api.update_addon(
                    app_name,
                    deployment_name,
                    'config.free',
                    'config.free',
                    settings=variables,
                    force=True)

        return True
Exemplo n.º 4
0
Arquivo: app.py Projeto: vervas/cctrl
    def removeConfig(self, args):
        """
            Remove the given variable if it exists.
        """
        #noinspection PyTupleAssignmentBalance
        app_name, deployment_name = self.parse_app_deployment_name(args.name)
        if not deployment_name:
            raise InputErrorException('NoDeployment')
        if not args.variables:
            raise InputErrorException('NoVariablesGiven')

        variables = parse_config_variables(args.variables, 'remove')

        try:
            self.api.update_addon(
                app_name,
                deployment_name,
                'config.free',
                'config.free',
                settings=variables)
        except GoneError:
            raise InputErrorException('WrongAddon')

        return True