How to use the cumulusci.core.exceptions.TaskOptionsError function in cumulusci

To help you get started, we’ve selected a few cumulusci examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github SFDO-Tooling / CumulusCI / cumulusci / tasks / apex / testrunner.py View on Github external
self.options["json_output"] = self.options.get(
            "json_output", "test_results.json"
        )

        self.options["managed"] = process_bool_arg(self.options.get("managed", False))

        self.options["retry_failures"] = process_list_arg(
            self.options.get("retry_failures", [])
        )
        compiled_res = []
        for regex in self.options["retry_failures"]:
            try:
                compiled_res.append(re.compile(regex))
            except re.error as e:
                raise TaskOptionsError(
                    "An invalid regular expression ({}) was provided ({})".format(
                        regex, e
                    )
                )
        self.options["retry_failures"] = compiled_res
        self.options["retry_always"] = process_bool_arg(
            self.options.get("retry_always", False)
        )

        self.counts = {}
github SFDO-Tooling / CumulusCI / cumulusci / tasks / apex / testrunner.py View on Github external
def _get_namespace_filter(self):
        if self.options["managed"]:
            namespace = self.options.get("namespace")
            if not namespace:
                raise TaskOptionsError(
                    "Running tests in managed mode but no namespace available."
                )
            namespace = "'{}'".format(namespace)
        else:
            namespace = "null"
        return namespace
github SFDO-Tooling / CumulusCI / cumulusci / tasks / connectedapp.py View on Github external
def _validate_connect_service(self):
        if not self.options["overwrite"]:
            try:
                self.project_config.keychain.get_service("connected_app")
            except ServiceNotConfigured:
                pass
            else:
                raise TaskOptionsError(
                    "The CumulusCI keychain already contains a connected_app service.  Set the 'overwrite' option to True to overwrite the existing service"
                )
github SFDO-Tooling / CumulusCI / cumulusci / tasks / salesforce / UpdateDependencies.py View on Github external
subdependencies = dependency.get("dependencies")
            if subdependencies:
                count_uninstall = len(self.uninstall_queue)
                self._process_dependencies(subdependencies)
                if count_uninstall != len(self.uninstall_queue):
                    dependency_uninstalled = True

            # Process namespace dependencies (managed packages)
            if "namespace" in dependency:
                self._process_namespace_dependency(dependency, dependency_uninstalled)
            else:
                # zip_url or repo dependency
                self.install_queue.append(dependency)

        if self.uninstall_queue and not self.options["allow_uninstalls"]:
            raise TaskOptionsError(
                "Updating dependencies would require uninstalling these packages "
                "but uninstalls are not enabled: {}".format(
                    ", ".join(dep["namespace"] for dep in self.uninstall_queue)
                )
github SFDO-Tooling / CumulusCI / cumulusci / tasks / bulkdata / data_generation / generate_from_yaml.py View on Github external
def _init_options(self, kwargs):
        super()._init_options(kwargs)
        self.yaml_file = os.path.abspath(self.options["generator_yaml"])
        if not os.path.exists(self.yaml_file):
            raise TaskOptionsError(f"Cannot find {self.yaml_file}")
        if "vars" in self.options:
            self.vars = process_list_of_pairs_dict_arg(self.options["vars"])
        else:
            self.vars = {}
        self.generate_mapping_file = self.options.get("generate_mapping_file")
        if self.generate_mapping_file:
            self.generate_mapping_file = os.path.abspath(self.generate_mapping_file)
github SFDO-Tooling / CumulusCI / cumulusci / tasks / bulkdata / extract.py View on Github external
def _init_options(self, kwargs):
        super(ExtractData, self)._init_options(kwargs)
        if self.options.get("database_url"):
            # prefer database_url if it's set
            self.options["sql_path"] = None
        elif self.options.get("sql_path"):
            self.logger.info("Using in-memory sqlite database")
            self.options["database_url"] = "sqlite://"
            self.options["sql_path"] = os_friendly_path(self.options["sql_path"])
        else:
            raise TaskOptionsError(
                "You must set either the database_url or sql_path option."
            )
github SFDO-Tooling / CumulusCI / cumulusci / tasks / connectedapp.py View on Github external
def _process_devhub_output(self, output):
        data = self._process_json_output(output)
        if "value" not in data["result"][0]:
            raise TaskOptionsError(
                "No sfdx config found for defaultdevhubusername.  Please use the sfdx force:config:set to set the defaultdevhubusername and run again"
            )
        self.options["username"] = data["result"][0]["value"]
github SFDO-Tooling / CumulusCI / cumulusci / tasks / bulkdata.py View on Github external
def _init_options(self, kwargs):
        super(QueryData, self)._init_options(kwargs)
        if self.options.get("sql_path"):
            if self.options.get("database_url"):
                raise TaskOptionsError(
                    "The database_url option is set dynamically with the sql_path option.  Please unset the database_url option."
                )
            self.logger.info("Using in-memory sqlite database")
            self.options["database_url"] = "sqlite://"
            self.options["sql_path"] = os_friendly_path(self.options["sql_path"])
github SFDO-Tooling / CumulusCI / cumulusci / tasks / salesforce.py View on Github external
def _validate_options(self):
        super(RetrieveReportsAndDashboards, self)._validate_options()
        if not 'report_folders' in self.options and not 'dashboard_folders' in self.options:
            raise TaskOptionsError('You must provide at least one folder name for either report_folders or dashboard_folders')
github SFDO-Tooling / CumulusCI / cumulusci / tasks / 2gp.py View on Github external
def _get_or_create_package(self, package_config):
        query = "SELECT Id FROM Package2 WHERE IsDeprecated = FALSE AND Name='{name}'".format(
            **package_config
        )
        if package_config.get("namespace"):
            query += " AND NamespacePrefix='{namespace}'".format(**package_config)
        else:
            query += " AND NamespacePrefix=null"
        res = self.tooling.query(query)
        if res["size"] > 1:
            raise TaskOptionsError(
                "Found {size} packages with the same name and namespace"
            )
        if res["size"] == 1:
            return res["records"][0]["Id"]

        self.logger.info("No existing package found, creating the package")
        Package2 = self._get_tooling_object("Package2")
        package = Package2.create(
            {
                "ContainerOptions": package_config["package_type"],
                "Name": package_config["name"],
                "NamespacePrefix": package_config["namespace"],
            }
        )
        return package["id"]