def execute_command(self): """ Execute the shell command. """ stderr = "" role_count = 0 for role in utils.roles_dict(self.roles_path): self.command = self.command.replace("%role_name", role) (_, err) = utils.capture_shell("cd {0} && {1}".format( os.path.join(self.roles_path, role), self.command)) stderr = err role_count += 1 utils.exit_if_no_roles(role_count, self.roles_path) if len(stderr) > 0: ui.error(c.MESSAGES["run_error"], stderr[:-1]) else: if not self.config["options_quiet"]: ui.ok( c.MESSAGES["run_success"].replace("%role_count", str(role_count)), self.options.command)
def execute_command(self): """ Execute the shell command. """ stderr = "" role_count = 0 for role in utils.roles_dict(self.roles_path): self.command = self.command.replace("%role_name", role) (_, err) = utils.capture_shell("cd {0} && {1}". format(os.path.join( self.roles_path, role), self.command)) stderr = err role_count += 1 utils.exit_if_no_roles(role_count, self.roles_path) if len(stderr) > 0: ui.error(c.MESSAGES["run_error"], stderr[:-1]) else: if not self.config["options_quiet"]: ui.ok(c.MESSAGES["run_success"].replace( "%role_count", str(role_count)), self.options.command)
def __init__(self, args, options, config, gendoc=False, genmeta=False, export=False): self.roles_path = args[0] self.options = options self.config = config self.gendoc = gendoc self.genmeta = genmeta self.export = export # set the readme output format self.readme_format = c.ALLOWED_GENDOC_FORMATS[self.options.docformat] self.roles = utils.roles_dict(self.roles_path, "") if self.options.limit: self.limit_roles() utils.exit_if_no_roles(len(self.roles.keys()), self.roles_path) self.regex_facts = re.compile(r"set_fact:\w+") self.paths = {} # default values for the role report self.defaults = "" self.dependencies = [] self.all_files = [] self.yaml_files = [] # only load and validate the readme when generating docs if self.gendoc: # only change the format if it is different than the default if not self.options.format == self.readme_format: self.readme_format = self.options.format extend_path = self.config["options_readme_template"] if self.readme_format == "rst": readme_source = c.README_RST_TEMPLATE_PATH else: readme_source = c.README_MD_TEMPLATE_PATH self.readme_template = utils.template(readme_source, extend_path, self.readme_format) self.report = { "totals": { "roles": 0, "dependencies": 0, "defaults": 0, "facts": 0, "files": 0, "lines": 0, }, "state": { "ok_role": 0, "skipped_role": 0, "changed_role": 0, "missing_readme_role": 0, "missing_meta_role": 0, }, "roles": {}, "stats": { "longest_role_name_length": len(max(self.roles, key=len)), } } self.scan_roles() if self.export: self.export_roles()
def __init__(self, args, options, config, gendoc=False, genmeta=False, export=False): self.roles_path = args[0] self.options = options self.config = config self.gendoc = gendoc self.genmeta = genmeta self.export = export # set the readme output format self.readme_format = c.ALLOWED_GENDOC_FORMATS[0] self.roles = utils.roles_dict(self.roles_path, "") if self.options.limit: self.limit_roles() utils.exit_if_no_roles(len(self.roles.keys()), self.roles_path) self.regex_facts = re.compile(r"set_fact:\w+") self.paths = {} # default values for the role report self.defaults = "" self.dependencies = [] self.all_files = [] self.yaml_files = [] # only load and validate the readme when generating docs if self.gendoc: # only change the format if it is different than the default if not self.options.format == self.readme_format: self.readme_format = self.options.format extend_path = self.config["options_readme_template"] if self.readme_format == "rst": readme_source = c.README_RST_TEMPLATE_PATH else: readme_source = c.README_MD_TEMPLATE_PATH self.readme_template = utils.template(readme_source, extend_path, self.readme_format) self.report = { "totals": { "roles": 0, "dependencies": 0, "defaults": 0, "facts": 0, "files": 0, "lines": 0, }, "state": { "ok_role": 0, "skipped_role": 0, "changed_role": 0, "missing_readme_role": 0, "missing_meta_role": 0, }, "roles": {}, "stats": { "longest_role_name_length": len(max(self.roles, key=len)), } } self.scan_roles() if self.export: self.export_roles()