Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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 = {}
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
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"
)
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)
)
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)
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."
)
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"]
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"])
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')
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"]