def _run_task(self): github_info = { 'github_owner': self.project_config.repo_owner, 'github_repo': self.project_config.repo_name, 'github_username': self.github_config.username, 'github_password': self.github_config.password, 'master_branch': self.project_config.project__git__default_branch, 'prefix_beta': self.project_config.project__git__prefix_beta, 'prefix_prod': self.project_config.project__git__prefix_release, } if process_bool_arg(self.options.get('publish', False)): generator_class = PublishingGithubReleaseNotesGenerator else: generator_class = GithubReleaseNotesGenerator generator = generator_class( github_info, self.options['tag'], self.options.get('last_tag'), process_bool_arg(self.options.get('link_pr', False)), self.get_repo().has_issues, ) release_notes = generator() self.logger.info('\n' + release_notes)
def _init_options(self, kwargs): super(UpdateDependencies, self)._init_options(kwargs) self.options["purge_on_delete"] = process_bool_arg( self.options.get("purge_on_delete", True)) self.options["include_beta"] = process_bool_arg( self.options.get("include_beta", False)) self.options["dependencies"] = ( self.options.get("dependencies") or self.project_config.project__dependencies) self.options["allow_newer"] = process_bool_arg( self.options.get("allow_newer", True)) self.options["allow_uninstalls"] = process_bool_arg( self.options.get("allow_uninstalls", False)) self.options["security_type"] = self.options.get( "security_type", "FULL") if self.options["security_type"] not in ("FULL", "NONE", "PUSH"): raise TaskOptionsError( f"Unsupported value for security_type: {self.options['security_type']}" ) if "ignore_dependencies" in self.options: if any("github" not in dep and "namespace" not in dep for dep in self.options["ignore_dependencies"]): raise TaskOptionsError( "An invalid dependency was specified for ignore_dependencies." ) if (self.org_config and self.options["include_beta"] and not self.org_config.scratch): self.logger.warning( "The `include_beta` option is enabled but this not a scratch org.\n" "Setting `include_beta` to False to avoid installing beta package versions in a persistent org." ) self.options["include_beta"] = False
def _process_namespace(self, src_zip): if self.options.get("namespace_tokenize"): src_zip = process_text_in_zipfile( src_zip, functools.partial( tokenize_namespace, namespace=self.options["namespace_tokenize"], logger=self.logger, ), ) if self.options.get("namespace_inject"): src_zip = process_text_in_zipfile( src_zip, functools.partial( inject_namespace, namespace=self.options["namespace_inject"], managed=not process_bool_arg( self.options.get("unmanaged", True)), namespaced_org=process_bool_arg( self.options.get("namespaced_org", False)), logger=self.logger, ), ) if self.options.get("namespace_strip"): src_zip = process_text_in_zipfile( src_zip, functools.partial( strip_namespace, namespace=self.options["namespace_strip"], logger=self.logger, ), ) return src_zip
def _init_options(self, kwargs): self.client_id = None self.client_secret = None kwargs["command"] = "force:mdapi:deploy --wait {}".format( self.deploy_wait) super(CreateConnectedApp, self)._init_options(kwargs) # Validate label if not re.match(r"^\w+$", self.options["label"]): raise TaskOptionsError( "label value must contain only alphanumeric or underscore characters" ) # Default email to the github service's email if configured if "email" not in self.options: try: github = self.project_config.keychain.get_service("github") except ServiceNotConfigured: raise TaskOptionsError( "Could not determine a default for option 'email'. Either configure the github service using 'cci service connect github' or provide a value for the 'email' option" ) self.options["email"] = github.email self.options["connect"] = process_bool_arg( self.options.get("connect") or False) self.options["overwrite"] = process_bool_arg( self.options.get("overwrite") or False)
def _init_options(self, kwargs): super(UpdateAdminProfile, self)._init_options(kwargs) if "package_xml" not in self.options: self.options["package_xml"] = os.path.join(CUMULUSCI_PATH, "cumulusci", "files", "admin_profile.xml") self.options["managed"] = process_bool_arg( self.options.get("managed", False)) self.options["namespaced_org"] = process_bool_arg( self.options.get("namespaced_org", False)) # For namespaced orgs, managed should always be True if self.options["namespaced_org"]: self.options["managed"] = True # Set up namespace prefix strings namespace_prefix = "{}__".format( self.project_config.project__package__namespace) self.namespace_prefixes = { "managed": namespace_prefix if self.options["managed"] else "", "namespaced_org": namespace_prefix if self.options["namespaced_org"] else "", } # Read in the package.xml file self.options["package_xml_path"] = self.options["package_xml"] with open(self.options["package_xml_path"], "r") as f: self.options["package_xml"] = f.read()
def _process_namespace(self, zipf): if self.options.get('namespace_tokenize'): self.logger.info( 'Tokenizing namespace prefix {}__'.format( self.options['namespace_tokenize'], ) ) zipf = zip_tokenize_namespace(zipf, self.options['namespace_tokenize'], logger=self.logger) if self.options.get('namespace_inject'): kwargs = {} kwargs['managed'] = not process_bool_arg(self.options.get('unmanaged', True)) kwargs['namespaced_org'] = process_bool_arg(self.options.get('namespaced_org', False)) kwargs['logger'] = self.logger if kwargs['managed']: self.logger.info( 'Replacing namespace tokens from metadata with namespace prefix {}__'.format( self.options['namespace_inject'], ) ) else: self.logger.info( 'Stripping namespace tokens from metadata for unmanaged deployment' ) zipf = zip_inject_namespace(zipf, self.options['namespace_inject'], **kwargs) if self.options.get('namespace_strip'): zipf = zip_strip_namespace(zipf, self.options['namespace_strip'], logger=self.logger) return zipf
def _run_task(self): github_info = { "github_owner": self.project_config.repo_owner, "github_repo": self.project_config.repo_name, "github_username": self.github_config.username, "github_password": self.github_config.password, "default_branch": self.project_config.project__git__default_branch, "prefix_beta": self.project_config.project__git__prefix_beta, "prefix_prod": self.project_config.project__git__prefix_release, } generator = GithubReleaseNotesGenerator( self.github, github_info, self.project_config.project__git__release_notes__parsers.values(), self.options["tag"], self.options.get("last_tag"), process_bool_arg(self.options.get("link_pr", False)), process_bool_arg(self.options.get("publish", False)), self.get_repo().has_issues, process_bool_arg(self.options.get("include_empty", False)), version_id=self.options.get("version_id"), ) release_notes = generator() self.logger.info("\n" + release_notes)
def _init_options(self, kwargs): super(UpdateProfile, self)._init_options(kwargs) self.options["managed"] = process_bool_arg(self.options.get("managed", False)) self.options["namespaced_org"] = process_bool_arg( self.options.get("namespaced_org", False) ) # For namespaced orgs, managed should always be True if self.options["namespaced_org"]: self.options["managed"] = True # Set up namespace prefix strings namespace_prefix = "{}__".format( self.project_config.project__package__namespace ) self.namespace_prefixes = { "managed": namespace_prefix if self.options["managed"] else "", "namespaced_org": namespace_prefix if self.options["namespaced_org"] else "", } self.profile_name = self.options.get("profile_name") or "Admin"
def _prepare_apex(self, apex): # Process namespace tokens namespace = self.project_config.project__package__namespace if "managed" in self.options: managed = process_bool_arg(self.options["managed"]) else: managed = ( bool(namespace) and namespace in self.org_config.installed_packages ) if "namespaced" in self.options: namespaced = process_bool_arg(self.options["namespaced"]) else: namespaced = bool(namespace) and namespace == self.org_config.namespace _, apex = inject_namespace( "", apex, namespace=namespace, managed=managed, namespaced_org=namespaced, ) # This is an extra token which is not handled by inject_namespace. apex = apex.replace( "%%%NAMESPACED_RT%%%", namespace + "." if namespaced else "" ) # Process optional parameter token replacement param1 = self.options.get("param1") or "" apex = apex.replace("%%%PARAM_1%%%", param1) param2 = self.options.get("param2") or "" apex = apex.replace("%%%PARAM_2%%%", param2) return apex
def _init_options(self, kwargs): super(RunApexTests, self)._init_options(kwargs) self.options["test_name_match"] = self.options.get( "test_name_match", self.project_config.project__test__name_match ) self.options["test_name_exclude"] = self.options.get( "test_name_exclude", self.project_config.project__test__name_exclude ) if self.options["test_name_exclude"] is None: self.options["test_name_exclude"] = "" self.options["namespace"] = self.options.get( "namespace", self.project_config.project__package__namespace ) self.options["junit_output"] = self.options.get( "junit_output", "test_results.xml" ) 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.verbose = process_bool_arg(self.options.get("verbose", False)) self.counts = {} if "required_org_code_coverage_percent" in self.options: try: self.code_coverage_level = int( str(self.options["required_org_code_coverage_percent"]).rstrip("%") ) except ValueError: raise TaskOptionsError( f"Invalid code coverage level {self.options['required_org_code_coverage_percent']}" ) else: self.code_coverage_level = None
def _init_options(self, kwargs): self.client_id = None self.client_secret = None kwargs["command"] = "force:mdapi:deploy --wait {}".format(self.deploy_wait) super(CreateConnectedApp, self)._init_options(kwargs) # Validate label if not re.match(r"^\w+$", self.options["label"]): raise TaskOptionsError( "label value must contain only alphanumeric or underscore characters" ) # Default email to the github service's email if configured if "email" not in self.options: try: github = self.project_config.keychain.get_service("github") except ServiceNotConfigured: raise TaskOptionsError( "Could not determine a default for option 'email'. Either configure the github service using 'cci service connect github' or provide a value for the 'email' option" ) self.options["email"] = github.email # Default to sfdx defaultdevhubusername if "username" not in self.options: self._set_default_username() self.options["command"] += " -u {}".format(self.options.get("username")) self.options["connect"] = process_bool_arg(self.options.get("connect", False)) self.options["overwrite"] = process_bool_arg( self.options.get("overwrite", False) )
def _init_options(self, kwargs): super(UpdateDependencies, self)._init_options(kwargs) self.options["purge_on_delete"] = process_bool_arg( self.options.get("purge_on_delete", True)) self.options["namespaced_org"] = process_bool_arg( self.options.get("namespaced_org", False)) self.options["include_beta"] = process_bool_arg( self.options.get("include_beta", False)) self.options["dependencies"] = ( self.options.get("dependencies") or self.project_config.project__dependencies) self.options["allow_newer"] = process_bool_arg( self.options.get("allow_newer", True)) self.options["allow_uninstalls"] = process_bool_arg( self.options.get("allow_uninstalls", False)) self.options["security_type"] = self.options.get( "security_type", "FULL") if self.options["security_type"] not in ("FULL", "NONE", "PUSH"): raise TaskOptionsError( f"Unsupported value for security_type: {self.options['security_type']}" ) if "ignore_dependencies" in self.options: if any("github" not in dep and "namespace" not in dep for dep in self.options["ignore_dependencies"]): raise TaskOptionsError( "An invalid dependency was specified for ignore_dependencies." )
def _process_namespace(self, zipf): if self.options.get("namespace_tokenize"): self.logger.info("Tokenizing namespace prefix {}__".format( self.options["namespace_tokenize"])) zipf = zip_tokenize_namespace(zipf, self.options["namespace_tokenize"], logger=self.logger) if self.options.get("namespace_inject"): kwargs = {} kwargs["managed"] = not process_bool_arg( self.options.get("unmanaged", True)) kwargs["namespaced_org"] = process_bool_arg( self.options.get("namespaced_org", False)) kwargs["logger"] = self.logger if kwargs["managed"]: self.logger.info( "Replacing namespace tokens from metadata with namespace prefix {}__" .format(self.options["namespace_inject"])) else: self.logger.info( "Stripping namespace tokens from metadata for unmanaged deployment" ) zipf = zip_inject_namespace(zipf, self.options["namespace_inject"], **kwargs) if self.options.get("namespace_strip"): zipf = zip_strip_namespace(zipf, self.options["namespace_strip"], logger=self.logger) return zipf
def _process_namespace(self, zipf): if self.options.get("namespace_inject"): managed = not process_bool_arg(self.options.get("unmanaged", True)) if managed: self.logger.info( "Replacing namespace tokens from metadata with namespace prefix {}__".format( self.options["namespace_inject"] ) ) else: self.logger.info( "Stripping namespace tokens from metadata for unmanaged deployment" ) zipf = process_text_in_zipfile( zipf, functools.partial( inject_namespace, namespace=self.options["namespace_inject"], managed=managed, namespaced_org=process_bool_arg( self.options.get("namespaced_org", False) ), logger=self.logger, ), ) if self.options.get("namespace_strip"): zipf = process_text_in_zipfile( zipf, functools.partial( strip_namespace, namespace=self.options["namespace_strip"], logger=self.logger, ), ) return zipf
def _init_options(self, kwargs): super(DeleteData, self)._init_options(kwargs) # Split and trim objects string into a list if not already a list self.options["objects"] = process_list_arg(self.options["objects"]) if not len(self.options["objects"]) or not self.options["objects"][0]: raise TaskOptionsError("At least one object must be specified.") self.options["where"] = self.options.get("where", None) if len(self.options["objects"]) > 1 and self.options["where"]: raise TaskOptionsError( "Criteria cannot be specified if more than one object is specified." ) self.options["hardDelete"] = process_bool_arg(self.options.get("hardDelete")) self.options["ignore_row_errors"] = process_bool_arg( self.options.get("ignore_row_errors") ) self.options["inject_namespaces"] = process_bool_arg( self.options.get("inject_namespaces", True) ) try: self.options["api"] = { "bulk": DataApi.BULK, "rest": DataApi.REST, "smart": DataApi.SMART, }[self.options.get("api", "smart").lower()] except KeyError: raise TaskOptionsError( f"{self.options['api']} is not a valid value for API (valid: bulk, rest, smart)" ) if self.options["hardDelete"] and self.options["api"] is DataApi.REST: raise TaskOptionsError("The hardDelete option requires Bulk API.")
def _init_options(self, kwargs): super(Robot, self)._init_options(kwargs) for option in ("test", "include", "exclude", "vars"): if option in self.options: self.options[option] = process_list_arg(self.options[option]) if "vars" not in self.options: self.options["vars"] = [] # Initialize options as a dict if "options" not in self.options: self.options["options"] = {} # There are potentially many robot options that are or could # be lists, but the only one we currently care about is the # listener option since we may need to append additional values # onto it. for option in ("listener",): if option in self.options["options"]: self.options["options"][option] = process_list_arg( self.options["options"][option] ) listeners = self.options["options"].setdefault("listener", []) if process_bool_arg(self.options.get("verbose")): listeners.append(KeywordLogger()) if process_bool_arg(self.options.get("debug")): listeners.append(DebugListener()) if process_bool_arg(self.options.get("pdb")): patch_statusreporter()
def _init_options(self, kwargs): super(LoadData, self)._init_options(kwargs) self.options["ignore_row_errors"] = process_bool_arg( self.options.get("ignore_row_errors", False)) 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.options["sql_path"] = os_friendly_path( self.options["sql_path"]) self.options["database_url"] = None else: raise TaskOptionsError( "You must set either the database_url or sql_path option.") self.reset_oids = self.options.get("reset_oids", True) self.bulk_mode = (self.options.get("bulk_mode") and self.options.get("bulk_mode").title()) if self.bulk_mode and self.bulk_mode not in ["Serial", "Parallel"]: raise TaskOptionsError( "bulk_mode must be either Serial or Parallel") self.options["inject_namespaces"] = process_bool_arg( self.options.get("inject_namespaces", True)) self.options["drop_missing_schema"] = process_bool_arg( self.options.get("drop_missing_schema", False))
def _init_options(self, kwargs): super(UninstallLocalNamespacedBundles, self)._init_options(kwargs) self.options["managed"] = process_bool_arg( self.options.get("managed", False)) if "namespace" not in self.options: self.options[ "namespace"] = self.project_config.project__package__namespace self.options["purge_on_delete"] = process_bool_arg( self.options.get("purge_on_delete", True))
def _init_options(self, kwargs): super(SetTDTMHandlerStatus, self)._init_options(kwargs) self.options["handlers"] = process_list_arg( self.options.get("handlers", [])) self.options["active"] = process_bool_arg( self.options.get("active", False)) self.options["restore"] = process_bool_arg( self.options.get("restore", False)) if self.options["restore"] and not self.options.get("restore_file"): raise TaskOptionsError("Restoring requires a restore file name")
def _init_options(self, kwargs): super(UpdateDependencies, self)._init_options(kwargs) self.options["purge_on_delete"] = process_bool_arg( self.options.get("purge_on_delete", True)) self.options["namespaced_org"] = process_bool_arg( self.options.get("namespaced_org", False)) self.options["include_beta"] = process_bool_arg( self.options.get("include_beta", False)) self.options["dependencies"] = ( self.options.get("dependencies") or self.project_config.project__dependencies)
def _init_options(self, kwargs): super(ReleaseReport, self)._init_options(kwargs) self.options["date_start"] = (parse_datetime( self.options["date_start"], self.DATE_FORMAT) if "date_start" in self.options else None) self.options["date_end"] = (parse_datetime(self.options["date_end"], self.DATE_FORMAT) if "date_end" in self.options else None) self.options["include_beta"] = process_bool_arg( self.options.get("include_beta", False)) self.options["print"] = process_bool_arg( self.options.get("print", False))
def _apply_namespace(self): # Process namespace tokens managed = process_bool_arg(self.options.get("managed", False)) namespaced = process_bool_arg(self.options.get("namespaced", False)) namespace = self.project_config.project__package__namespace namespace_prefix = "" if managed or namespaced: namespace_prefix = namespace + "__" self.object_name = self.object_name.replace("%%%NAMESPACE%%%", namespace_prefix) self.field_name = self.field_name.replace("%%%NAMESPACE%%%", namespace_prefix)
def _init_options(self, kwargs): super(ReleaseReport, self)._init_options(kwargs) self.options['date_start'] = parse_datetime( self.options['date_start'], self.DATE_FORMAT, ) if 'date_start' in self.options else None self.options['date_end'] = parse_datetime( self.options['date_end'], self.DATE_FORMAT, ) if 'date_end' in self.options else None self.options['include_beta'] = process_bool_arg( self.options.get('include_beta', False)) self.options['print'] = process_bool_arg( self.options.get('print', False))
def _init_options(self, kwargs): super(UpdateDependencies, self)._init_options(kwargs) self.options["purge_on_delete"] = process_bool_arg( self.options.get("purge_on_delete", True) ) self.options["namespaced_org"] = process_bool_arg( self.options.get("namespaced_org", False) ) self.options["include_beta"] = process_bool_arg( self.options.get("include_beta", False) ) self.options["dependencies"] = ( self.options.get("dependencies") or self.project_config.project__dependencies )
def _init_namespace_injection(self): namespace = (self.options.get("namespace_inject") or self.project_config.project__package__namespace) if "managed" in self.options: self.options["managed"] = process_bool_arg(self.options["managed"] or False) else: self.options["managed"] = (bool(namespace) and namespace in self.org_config.installed_packages) if "namespaced_org" in self.options: self.options["namespaced_org"] = process_bool_arg( self.options["namespaced_org"] or False) else: self.options["namespaced_org"] = (bool(namespace) and namespace == self.org_config.namespace)
def _init_options(self, kwargs): super(InstallPackageVersion, self)._init_options(kwargs) if "namespace" not in self.options: self.options["namespace"] = self.project_config.project__package__namespace if "name" not in self.options: self.options["name"] = ( self.project_config.project__package__name_managed or self.project_config.project__package__name or self.options["namespace"] ) if "retries" not in self.options: self.options["retries"] = 5 if "retry_interval" not in self.options: self.options["retry_interval"] = 5 if "retry_interval_add" not in self.options: self.options["retry_interval_add"] = 30 version = self.options.get("version") if version == "latest": self.options["version"] = self.project_config.get_latest_version() self.logger.info( "Installing latest release: {}".format(self.options["version"]) ) elif version == "latest_beta": self.options["version"] = self.project_config.get_latest_version(beta=True) self.logger.info( "Installing latest beta release: {}".format(self.options["version"]) ) elif version == "previous": self.options["version"] = self.project_config.get_previous_version() self.logger.info( "Installing previous release: {}".format(self.options["version"]) ) self.options["activateRSS"] = process_bool_arg(self.options.get("activateRSS"))
def _run_task(self): # args branch = self.options.get( "branch", self.project_config.project__apexdoc__branch ) if not branch: raise GithubException("Unable to determine branch name") local_dir = self.options.get("dir_local") if not local_dir: local_base_dir = ( self.project_config.project__apexdoc__dir if self.project_config.project__apexdoc__dir else self.project_config.repo_root ) local_dir = os.path.join(local_base_dir, "ApexDocumentation") repo_dir = self.options.get( "dir_repo", self.project_config.project__apexdoc__repo_dir ) dry_run = process_bool_arg(self.options.get("dry_run", False)) commit_message = self.options.get("commit_message", "Update Apex docs") # get API repo = self.get_repo() # commit author = { "name": self.github_config.username, "email": self.github_config.email, } commit_dir = CommitDir(repo, self.logger, author) commit_dir(local_dir, branch, repo_dir, commit_message, dry_run)
def _init_options(self, kwargs): super(RunApexTests, self)._init_options(kwargs) self.options["test_name_match"] = self.options.get( "test_name_match", self.project_config.project__test__name_match ) self.options["test_name_exclude"] = self.options.get( "test_name_exclude", self.project_config.project__test__name_exclude ) if self.options["test_name_exclude"] is None: self.options["test_name_exclude"] = "" self.options["namespace"] = self.options.get( "namespace", self.project_config.project__package__namespace ) self.options["retries"] = self.options.get("retries", 10) self.options["retry_interval"] = self.options.get("retry_interval", 5) self.options["retry_interval_add"] = self.options.get("retry_interval_add", 5) self.options["junit_output"] = self.options.get( "junit_output", "test_results.xml" ) self.options["json_output"] = self.options.get( "json_output", "test_results.json" ) self.options["managed"] = process_bool_arg(self.options.get("managed", False)) self.counts = {}
def _process_json(self, body): """Replace namespace tokens and randomize username domains.""" user_id = self.org_config.user_id body = body.replace("%%%USERID%%%", user_id) namespace = self.project_config.project__package__namespace if "managed" in self.options: managed = process_bool_arg(self.options["managed"]) else: managed = ( bool(namespace) and namespace in self.org_config.installed_packages ) _, body = inject_namespace( "composite", body, namespace=namespace, managed=managed, namespaced_org=self.options.get("namespaced", self.org_config.namespaced), ) if self.options.get("randomize_username", True): random_tld = "".join(random.choices(string.ascii_lowercase, k=4)) body = re.sub( r'("Username": .[\w-]+@[\w-]+\.)+[\w-]+', fr"\1{random_tld}", body ) return body
def _init_options(self, kwargs): super(UninstallPackagedIncremental, self)._init_options(kwargs) if "path" not in self.options: self.options["path"] = "src" self.options["purge_on_delete"] = process_bool_arg( self.options.get("purge_on_delete", True)) self.options["ignore"] = self.options.get("ignore") or {}
def _init_options(self, kwargs): super(SetTDTMHandlerStatus, self)._init_options(kwargs) self.options["handlers"] = process_list_arg( self.options.get("handlers", [])) self.options["active"] = process_bool_arg( self.options.get("active") or False) has_restore_file = (self.options.get("restore_file") is not False and self.options.get("restore_file") != "False") should_restore = process_bool_arg(self.options.get("restore", False)) if should_restore: if not has_restore_file: raise TaskOptionsError( "Restoring requires a restore file name") self.should_restore = True else: self.should_save = has_restore_file
def _init_options(self, kwargs): self.task_config.options["api_names"] = "dummy" super()._init_options(kwargs) self.options["overwrite"] = process_bool_arg( self.options.get("overwrite", False)) if (not isinstance(self.options.get("fields"), list) or len(self.options["fields"]) == 0): raise TaskOptionsError( "Please populate the fields field with a list of dictionaries containing at minimum one entry with an 'api_name' and 'help_text' keys" ) if not all(["api_name" in entry for entry in self.options["fields"]]): raise TaskOptionsError( "The 'api_name' key is required on all entry values.") if not all(["help_text" in entry for entry in self.options["fields"]]): raise TaskOptionsError( "The 'help_text' key is required on all entry values to declare what help text value to insert." ) self.api_name_list = defaultdict(list) for entry in process_list_arg(self.options["fields"]): try: obj, field = entry["api_name"].split(".") self.api_name_list[self._inject_namespace(obj)].append( (self._inject_namespace(field), entry["help_text"])) except ValueError: raise TaskOptionsError( f"api_name {entry} is not a valid Object.Field reference") self.api_names = set(self.api_name_list.keys())
def _init_options(self, kwargs): super(InstallPackageVersion, self)._init_options(kwargs) if "namespace" not in self.options: self.options["namespace"] = self.project_config.project__package__namespace if "name" not in self.options: self.options["name"] = ( self.project_config.project__package__name_managed or self.project_config.project__package__name or self.options["namespace"] ) if "retries" not in self.options: self.options["retries"] = 5 if "retry_interval" not in self.options: self.options["retry_interval"] = 5 if "retry_interval_add" not in self.options: self.options["retry_interval_add"] = 30 version = self.options.get("version") if version == "latest": self.options["version"] = self.project_config.get_latest_version() elif version == "latest_beta": self.options["version"] = self.project_config.get_latest_version(beta=True) elif version == "previous": self.options["version"] = self.project_config.get_previous_version() self.options["activateRSS"] = process_bool_arg(self.options.get("activateRSS")) self.options["security_type"] = self.options.get("security_type", "FULL") if self.options["security_type"] not in ("FULL", "NONE", "PUSH"): raise TaskOptionsError( f"Unsupported value for security_type: {self.options['security_type']}" )
def _run_command( self, env, command=None, output_handler=None, return_code_handler=None ): if not command: command = self.options["command"] interactive_mode = process_bool_arg(self.options["interactive"]) self.logger.info("Running command: %s", command) p = subprocess.Popen( command, stdout=sys.stdout if interactive_mode else subprocess.PIPE, stderr=sys.stderr if interactive_mode else subprocess.PIPE, stdin=sys.stdin if interactive_mode else subprocess.PIPE, bufsize=1, shell=True, env=env, cwd=self.options.get("dir"), ) if not interactive_mode: # Handle output lines if not output_handler: output_handler = self._process_output for line in iter(p.stdout.readline, b""): output_handler(line) p.stdout.close() p.wait() # Handle return code if not return_code_handler: return_code_handler = self._handle_returncode return_code_handler(p.returncode, p.stderr)
def _init_options(self, kwargs): super()._init_options(kwargs) self.options["managed"] = process_bool_arg( self.options.get("managed", False)) self.api_version = (self.options.get("api_version") or self.project_config.project__package__api_version)
def _init_options(self, kwargs): super(UninstallPackaged, self)._init_options(kwargs) if "package" not in self.options: self.options["package"] = self.project_config.project__package__name self.options["purge_on_delete"] = process_bool_arg( self.options.get("purge_on_delete", True) )
def _init_options(self, kwargs): super(ReleaseReport, self)._init_options(kwargs) self.options["date_start"] = ( parse_datetime(self.options["date_start"], self.DATE_FORMAT) if "date_start" in self.options else None ) self.options["date_end"] = ( parse_datetime(self.options["date_end"], self.DATE_FORMAT) if "date_end" in self.options else None ) self.options["include_beta"] = process_bool_arg( self.options.get("include_beta", False) ) self.options["print"] = process_bool_arg(self.options.get("print", False))
def _get_env(self): if process_bool_arg(self.options["pass_env"]): env = os.environ.copy() else: env = {} env.update(self.options["env"]) return env
def _init_options(self, kwargs): super(ListChanges, self)._init_options(kwargs) self.options["include"] = process_list_arg(self.options.get("include", [])) self.options["exclude"] = process_list_arg(self.options.get("exclude", [])) self.options["snapshot"] = process_bool_arg(self.options.get("snapshot", [])) self._exclude = self.options.get("exclude", []) self._exclude.extend(self.project_config.project__source__ignore or []) self._load_maxrevision()
def _process_meta_xml(self, zipf): if not process_bool_arg(self.options.get("clean_meta_xml", True)): return zipf self.logger.info( "Cleaning meta.xml files of packageVersion elements for deploy" ) zipf = zip_clean_metaxml(zipf, logger=self.logger) return zipf
def _init_options(self, kwargs): super(Robot, self)._init_options(kwargs) for option in ("test", "include", "exclude", "vars"): if option in self.options: self.options[option] = process_list_arg(self.options[option]) if "vars" not in self.options: self.options["vars"] = [] # Initialize options as a dict if "options" not in self.options: self.options["options"] = {} if process_bool_arg(self.options.get("verbose")): self.options["options"]["listener"] = KeywordLogger if process_bool_arg(self.options.get("pdb")): patch_statusreporter()
def _init_options(self, kwargs): super(UpdateAdminProfile, self)._init_options(kwargs) self.options['skip_record_types'] = process_bool_arg( self.options.get('skip_record_types', False) ) self.options['managed'] = process_bool_arg( self.options.get('managed', False) ) self.options['namespaced_org'] = process_bool_arg( self.options.get('namespaced_org', False) ) # For namespaced orgs, managed should always be True if self.options['namespaced_org']: self.options['managed'] = True # Set up namespace prefix strings namespace_prefix = '{}__'.format(self.project_config.project__package__namespace) self.namespace_prefix = namespace_prefix if self.options['managed'] else '' self.namespaced_org_prefix = namespace_prefix if self.options['namespaced_org'] else ''
def _init_options(self, kwargs): super(DeleteData, self)._init_options(kwargs) # Split and trim objects string into a list if not already a list if not isinstance(self.options["objects"], list): self.options["objects"] = [ obj.strip() for obj in self.options["objects"].split(",") ] self.options["hardDelete"] = process_bool_arg(self.options.get("hardDelete"))
def _process_namespace(self, src_zip): if self.options.get("namespace_tokenize"): src_zip = zip_tokenize_namespace( src_zip, self.options["namespace_tokenize"], logger=self.logger ) if self.options.get("namespace_inject"): kwargs = {} kwargs["managed"] = not process_bool_arg( self.options.get("unmanaged", True) ) kwargs["namespaced_org"] = process_bool_arg( self.options.get("namespaced_org", False) ) kwargs["logger"] = self.logger src_zip = zip_inject_namespace( src_zip, self.options["namespace_inject"], **kwargs ) if self.options.get("namespace_strip"): src_zip = zip_strip_namespace( src_zip, self.options["namespace_strip"], logger=self.logger ) return src_zip
def _process_namespace(self, zipf): if self.options.get("namespace_tokenize"): self.logger.info( "Tokenizing namespace prefix {}__".format( self.options["namespace_tokenize"] ) ) zipf = zip_tokenize_namespace( zipf, self.options["namespace_tokenize"], logger=self.logger ) if self.options.get("namespace_inject"): kwargs = {} kwargs["managed"] = not process_bool_arg( self.options.get("unmanaged", True) ) kwargs["namespaced_org"] = process_bool_arg( self.options.get("namespaced_org", False) ) kwargs["logger"] = self.logger if kwargs["managed"]: self.logger.info( "Replacing namespace tokens from metadata with namespace prefix {}__".format( self.options["namespace_inject"] ) ) else: self.logger.info( "Stripping namespace tokens from metadata for unmanaged deployment" ) zipf = zip_inject_namespace( zipf, self.options["namespace_inject"], **kwargs ) if self.options.get("namespace_strip"): zipf = zip_strip_namespace( zipf, self.options["namespace_strip"], logger=self.logger ) return zipf
def _run_task(self): github_info = { "github_owner": self.project_config.repo_owner, "github_repo": self.project_config.repo_name, "github_username": self.github_config.username, "github_password": self.github_config.password, "master_branch": self.project_config.project__git__default_branch, "prefix_beta": self.project_config.project__git__prefix_beta, "prefix_prod": self.project_config.project__git__prefix_release, } generator = GithubReleaseNotesGenerator( self.github, github_info, self.project_config.project__git__release_notes__parsers.values(), self.options["tag"], self.options.get("last_tag"), process_bool_arg(self.options.get("link_pr", False)), process_bool_arg(self.options.get("publish", False)), self.get_repo().has_issues, ) release_notes = generator() self.logger.info("\n" + release_notes)
def _init_options(self, kwargs): super(MergeBranch, self)._init_options(kwargs) if "commit" not in self.options: self.options["commit"] = self.project_config.repo_commit if "branch_prefix" not in self.options: self.options[ "branch_prefix" ] = self.project_config.project__git__prefix_feature if "source_branch" not in self.options: self.options[ "source_branch" ] = self.project_config.project__git__default_branch self.options["children_only"] = process_bool_arg( self.options.get("children_only", False) )
def _run_task(self): if not process_bool_arg(self.options.get('runAllApex', True)): #create CSV file and save list of changed files git_cmd = "touch changedFiles.txt | git status --porcelain | sed s/^...// > changedFiles.txt" p = Popen((git_cmd, os.getcwd()), stdout=PIPE, stderr=PIPE, shell=True) p.wait() with open('changedFiles.txt', 'r') as fr: # filter for specific file types filteredList = [] for line in fr: # if re.match(".+\.(cls|js|cmp)$", line): --> look at adding support for lightning components if re.match(".+\.(cls)$", line): filteredList.append(line) os.remove('changedFiles.txt') if not filteredList: self.logger.warn('No valid file changes in this diff.') return with open('filteredFiles.txt', 'w') as fw: fw.write(','.join(filteredList)) self.pmd_args.extend(['-filelist', 'filteredFiles.txt']) else: self.pmd_args.extend(['-d', self.options['path']]) pmd_out = None if self.options['output'] == 'html': pmd_out = open(self.options['htmlfilename'], 'w+') process = Popen(self.pmd_args, stdout=pmd_out, stderr=PIPE) _, stderr = process.communicate() returncode = process.returncode if os.path.isfile('filteredFiles.txt'): os.remove('filteredFiles.txt') if returncode: message = 'Return code: {}\nstderr: {}'.format(returncode, stderr) self.logger.error(message) raise CommandException(message)