Loading tools/builder/builder.py +9 −9 Original line number Diff line number Diff line Loading @@ -106,7 +106,7 @@ def get_description(job_path): Returns: (string): Full README file """ logging.info(f"Parsing readme for job {job_path}") logging.info("Parsing readme for job %s", job_path) try: with open(job_path + "/" + JOB_DESCRIPTION_FILE) as readme_file: return readme_file.read() Loading Loading @@ -134,7 +134,7 @@ def get_changelogs(job_path, job_name): "url": R2DEVOPS_URL + job_name + JOBS_EXTENSION } changelogs = [] logging.info(f"Parsing changelogs for job {job_name}") logging.info("Parsing changelogs for job %s", job_name) try: for version in versions: with open(job_path + "/" + JOB_CHANGELOG_DIR + "/" + version + MARKDOWN_EXTENSION) as changelog_file: Loading @@ -160,7 +160,7 @@ def get_license(license_name, copyright_holder): Returns: license_content (string): content of the license """ logging.info(f"Getting licence {license_name}") logging.info("Getting licence %s", license_name) try: env = Environment(loader=FileSystemLoader(BUILDER_DIR + "/" + TEMPLATE_DIR + "/" + TEMPLATE_LICENSE_DIR)) template = env.get_template(license_name + MARKDOWN_EXTENSION + ".j2") Loading Loading @@ -195,7 +195,7 @@ def get_screenshots(job_path, job_name): List of all screenshots name for the job """ logging.info(f"Getting screenshots for job {job_name}") logging.info("Getting screenshots for job %s", job_name) # Create screenshots folder in docs for the job makedirs(MKDOCS_DIR+"/"+MKDOCS_DIR_JOBS_IMAGES+"/"+job_name+"/"+SCREENSHOTS_DIR,0o777,True) Loading Loading @@ -223,7 +223,7 @@ def get_user(code_owner): response = requests.request("GET", url) logging.info(f"Getting user link for {code_owner}") logging.info("Getting user link for %s", code_owner) try: if response.status_code == 200: return response.json()[0] Loading Loading @@ -253,7 +253,7 @@ def get_job_raw_content(job_name): yaml Raw content of the job """ logging.info(f"Parsing content of the job {job_name}") logging.info("Parsing content of the job %s", job_name) try: with open("{}/{job}/{job}{}".format(JOBS_DIR, JOBS_EXTENSION, job=job_name), 'r') as job: Loading Loading @@ -285,7 +285,7 @@ def get_linked_issues(job_name, opened=True): str Url to create a new issue for the job """ logging.info(f"Getting list of linked issues for job {job_name}") logging.info(f"Getting list of linked issues for job %s", job_name) linked_issues = [] base_url = f"{GITLAB_API_URL}/projects/{quote(PROJECT_NAME, safe='')}/issues" url = f"{base_url}?labels={JOBS_SCOPE_LABEL}{job_name}" Loading Loading @@ -387,7 +387,7 @@ def add_placeholder(): placeholder_path = MKDOCS_DIR + "/" + JOBS_DIR + "/" + stage_key if len(listdir(placeholder_path)) == 1: # There is only the .pages file, so mkdocs will break logging.info(f"Creading a placeholder file for the stage {stage_key}") logging.info("Creading a placeholder file for the stage %s", stage_key) with open(placeholder_path + "/" + MKDOCS_PLACEHOLDER_FILE, "w+") as file_handle: env = Environment(loader=FileSystemLoader(BUILDER_DIR + "/" + TEMPLATE_DIR)) template = env.get_template(TEMPLATE_PLACEHOLDER) Loading Loading @@ -418,7 +418,7 @@ def main(): add_placeholder() # Using jinja2 with a template to create the index logging.info(f"Creating index of jobs") logging.info("Creating index of jobs") env = Environment(loader=FileSystemLoader(BUILDER_DIR + "/" + TEMPLATE_DIR)) template = env.get_template(TEMPLATE_INDEX) index_content = template.render(index=index) Loading tools/job_customs/job_customs.py +3 −3 Original line number Diff line number Diff line Loading @@ -62,7 +62,7 @@ if __name__ == "__main__": return_code = EXIT_SUCCESS for job in os.listdir(JOBS_DIR): logging.info(f"Getting the script for job {job}") logging.info("Getting the script for job %s", job) data = {} with open(f"{JOBS_DIR}/{job}/{job}.{JOBS_EXTENSION}", 'r') as file: Loading @@ -74,13 +74,13 @@ if __name__ == "__main__": if script in data[job].keys(): for line in data[job][script]: if any(re.match(pattern, line) for pattern in patterns): logging.error(f"Code modification discovered in script of job {job}") logging.error("Code modification discovered in script of job %s", job) return_code = EXIT_FAILURE elif "extends" in data[job].keys(): if script in data[data[job]['extends']].keys(): for line in data[data[job]['extends']][script]: if any(re.match(pattern, line) for pattern in patterns): logging.error(f"Code modification discovered in script of job {job}") logging.error("Code modification discovered in script of job %s", job) return_code = EXIT_FAILURE # If the extended job isn't in the file, it produce a KeyError except KeyError : Loading tools/job_image/job_image.py +2 −2 Original line number Diff line number Diff line Loading @@ -54,10 +54,10 @@ if __name__ == "__main__": ) if args.job is None: logging.error(f"No argument provided") logging.error("No argument provided") sys.exit(EXIT_FAILURE) logging.info(f"Getting the image for job {args.job}") logging.info("Getting the image for job %s", args.job) data = {} with open(f"{JOBS_DIR}/{args.job}/{args.job}.{JOBS_EXTENSION}", 'r') as file: Loading tools/job_labels/job_labels.py +5 −5 Original line number Diff line number Diff line Loading @@ -49,7 +49,7 @@ def get_labels(project_name, with_counts=False, include_ancestor_groups=True, se } base_label_url = f"{BASE_API_URL}/projects/{quote(project_name, safe='')}" + "/labels" url = f"{base_label_url}?{urlencode(payload)}" logging.info(f"Getting the list of issues from the project {project_name} filtered by {search}") logging.info("Getting the list of issues from the project %s filtered by %s", project_name, search) return (requests.get(url, headers=headers)) def create_label(project_name, label_name, label_color=LABEL_COLOR): Loading Loading @@ -79,7 +79,7 @@ def create_label(project_name, label_name, label_color=LABEL_COLOR): "description": f"Issues related to {label_name}" } url = f"{BASE_API_URL}/projects/{quote(project_name, safe='')}/labels" logging.info(f"Creating a label {label_name} for the project {project_name}") logging.info("Creating a label %s for the project %s", label_name, project_name) return (requests.post(url, headers=headers, data=payload)) def delete_label(project_name, label_name): Loading @@ -101,7 +101,7 @@ def delete_label(project_name, label_name): 'PRIVATE-TOKEN': JOB_TOKEN } url = f"{BASE_API_URL}/projects/{quote(project_name, safe='')}/labels/{label_name}" logging.info(f"Deleting a label {label_name} for the project {project_name}") logging.info("Deleting a label %s for the project %s", label_name, project_name) return (requests.delete(url, headers=headers)) if __name__ == "__main__": Loading Loading @@ -131,9 +131,9 @@ if __name__ == "__main__": label = get_labels(PROJECT_NAME, search=job_label) if "Unauthorized" not in label.text: if label.json(): logging.info(f"Label {job} exist") logging.info("Label %s exist", job) else: logging.info(f"Label {job} does not exist, creating one now") logging.info("Label %s does not exist, creating one now", job) create_label(PROJECT_NAME, job_label) else: logging.error("Not Authorized, verify the API_TOKEN environment variable in the gitlab project") Loading tools/job_structure/job_structure.py +9 −9 Original line number Diff line number Diff line Loading @@ -36,14 +36,14 @@ def check_job_yaml(job): template_content = yaml.load(template_yml, Loader=yaml.FullLoader) job_content = yaml.load(job_yml, Loader=yaml.FullLoader) logging.info(f"Checking the content of {JOB_YAML} in job {job}") logging.info("Checking the content of %s in job %s", JOB_YAML, job) diff = set(template_content.keys()) - set(job_content.keys()) if len(diff) > 0: for item in diff: logging.error(f"Key {item} in {JOB_YAML} of job {job} is missing") logging.error("Key %s in %s of job %s is missing", item, JOB_YAML, job) ret = EXIT_FAILURE else: logging.info(f"{JOB_YAML} for job {job} is complete") logging.info("%s for job %s is complete", JOB_YAML, job) return ret def check_directory_structure(template_structure, job): Loading Loading @@ -75,24 +75,24 @@ def check_directory_structure(template_structure, job): job_structure = [obj[obj.find('/') + 1:] for obj in job_structure] # Check if file/directory is empty logging.info(f"Checking empty file/directory in job structure of job {job}") logging.info("Checking empty file/directory in job structure of job %s", job) for item in job_structure: if os.path.isfile(item): if os.path.getsize(item) == 0: logging.error(f"File {item} for job {job} is empty") logging.error("File %s for job %s is empty", item, job) elif os.path.isdir(item): if len(os.listdir(item)) == 0: logging.error(f"Directory {item} for job {job} is empty") logging.error("Directory %s for job %s is empty", item, job) ret = EXIT_SUCCESS if len(set(template_structure_tmp).intersection(job_structure)) != len(template_structure_tmp): # Not every file and directories in template_structure_tmp matched the job structure logging.error(f"Job structure of {job} does not match the template:") logging.error("Job structure of %s does not match the template:", job) for item in set(template_structure_tmp) - set(template_structure_tmp).intersection(job_structure): logging.error(f"\tFile/directory missing: {item}") logging.error("\tFile/directory missing: %s", item) ret = EXIT_FAILURE else: logging.info(f"Job structure of {job} matches the template") logging.info("Job structure of %s matches the template", job) return ret Loading Loading
tools/builder/builder.py +9 −9 Original line number Diff line number Diff line Loading @@ -106,7 +106,7 @@ def get_description(job_path): Returns: (string): Full README file """ logging.info(f"Parsing readme for job {job_path}") logging.info("Parsing readme for job %s", job_path) try: with open(job_path + "/" + JOB_DESCRIPTION_FILE) as readme_file: return readme_file.read() Loading Loading @@ -134,7 +134,7 @@ def get_changelogs(job_path, job_name): "url": R2DEVOPS_URL + job_name + JOBS_EXTENSION } changelogs = [] logging.info(f"Parsing changelogs for job {job_name}") logging.info("Parsing changelogs for job %s", job_name) try: for version in versions: with open(job_path + "/" + JOB_CHANGELOG_DIR + "/" + version + MARKDOWN_EXTENSION) as changelog_file: Loading @@ -160,7 +160,7 @@ def get_license(license_name, copyright_holder): Returns: license_content (string): content of the license """ logging.info(f"Getting licence {license_name}") logging.info("Getting licence %s", license_name) try: env = Environment(loader=FileSystemLoader(BUILDER_DIR + "/" + TEMPLATE_DIR + "/" + TEMPLATE_LICENSE_DIR)) template = env.get_template(license_name + MARKDOWN_EXTENSION + ".j2") Loading Loading @@ -195,7 +195,7 @@ def get_screenshots(job_path, job_name): List of all screenshots name for the job """ logging.info(f"Getting screenshots for job {job_name}") logging.info("Getting screenshots for job %s", job_name) # Create screenshots folder in docs for the job makedirs(MKDOCS_DIR+"/"+MKDOCS_DIR_JOBS_IMAGES+"/"+job_name+"/"+SCREENSHOTS_DIR,0o777,True) Loading Loading @@ -223,7 +223,7 @@ def get_user(code_owner): response = requests.request("GET", url) logging.info(f"Getting user link for {code_owner}") logging.info("Getting user link for %s", code_owner) try: if response.status_code == 200: return response.json()[0] Loading Loading @@ -253,7 +253,7 @@ def get_job_raw_content(job_name): yaml Raw content of the job """ logging.info(f"Parsing content of the job {job_name}") logging.info("Parsing content of the job %s", job_name) try: with open("{}/{job}/{job}{}".format(JOBS_DIR, JOBS_EXTENSION, job=job_name), 'r') as job: Loading Loading @@ -285,7 +285,7 @@ def get_linked_issues(job_name, opened=True): str Url to create a new issue for the job """ logging.info(f"Getting list of linked issues for job {job_name}") logging.info(f"Getting list of linked issues for job %s", job_name) linked_issues = [] base_url = f"{GITLAB_API_URL}/projects/{quote(PROJECT_NAME, safe='')}/issues" url = f"{base_url}?labels={JOBS_SCOPE_LABEL}{job_name}" Loading Loading @@ -387,7 +387,7 @@ def add_placeholder(): placeholder_path = MKDOCS_DIR + "/" + JOBS_DIR + "/" + stage_key if len(listdir(placeholder_path)) == 1: # There is only the .pages file, so mkdocs will break logging.info(f"Creading a placeholder file for the stage {stage_key}") logging.info("Creading a placeholder file for the stage %s", stage_key) with open(placeholder_path + "/" + MKDOCS_PLACEHOLDER_FILE, "w+") as file_handle: env = Environment(loader=FileSystemLoader(BUILDER_DIR + "/" + TEMPLATE_DIR)) template = env.get_template(TEMPLATE_PLACEHOLDER) Loading Loading @@ -418,7 +418,7 @@ def main(): add_placeholder() # Using jinja2 with a template to create the index logging.info(f"Creating index of jobs") logging.info("Creating index of jobs") env = Environment(loader=FileSystemLoader(BUILDER_DIR + "/" + TEMPLATE_DIR)) template = env.get_template(TEMPLATE_INDEX) index_content = template.render(index=index) Loading
tools/job_customs/job_customs.py +3 −3 Original line number Diff line number Diff line Loading @@ -62,7 +62,7 @@ if __name__ == "__main__": return_code = EXIT_SUCCESS for job in os.listdir(JOBS_DIR): logging.info(f"Getting the script for job {job}") logging.info("Getting the script for job %s", job) data = {} with open(f"{JOBS_DIR}/{job}/{job}.{JOBS_EXTENSION}", 'r') as file: Loading @@ -74,13 +74,13 @@ if __name__ == "__main__": if script in data[job].keys(): for line in data[job][script]: if any(re.match(pattern, line) for pattern in patterns): logging.error(f"Code modification discovered in script of job {job}") logging.error("Code modification discovered in script of job %s", job) return_code = EXIT_FAILURE elif "extends" in data[job].keys(): if script in data[data[job]['extends']].keys(): for line in data[data[job]['extends']][script]: if any(re.match(pattern, line) for pattern in patterns): logging.error(f"Code modification discovered in script of job {job}") logging.error("Code modification discovered in script of job %s", job) return_code = EXIT_FAILURE # If the extended job isn't in the file, it produce a KeyError except KeyError : Loading
tools/job_image/job_image.py +2 −2 Original line number Diff line number Diff line Loading @@ -54,10 +54,10 @@ if __name__ == "__main__": ) if args.job is None: logging.error(f"No argument provided") logging.error("No argument provided") sys.exit(EXIT_FAILURE) logging.info(f"Getting the image for job {args.job}") logging.info("Getting the image for job %s", args.job) data = {} with open(f"{JOBS_DIR}/{args.job}/{args.job}.{JOBS_EXTENSION}", 'r') as file: Loading
tools/job_labels/job_labels.py +5 −5 Original line number Diff line number Diff line Loading @@ -49,7 +49,7 @@ def get_labels(project_name, with_counts=False, include_ancestor_groups=True, se } base_label_url = f"{BASE_API_URL}/projects/{quote(project_name, safe='')}" + "/labels" url = f"{base_label_url}?{urlencode(payload)}" logging.info(f"Getting the list of issues from the project {project_name} filtered by {search}") logging.info("Getting the list of issues from the project %s filtered by %s", project_name, search) return (requests.get(url, headers=headers)) def create_label(project_name, label_name, label_color=LABEL_COLOR): Loading Loading @@ -79,7 +79,7 @@ def create_label(project_name, label_name, label_color=LABEL_COLOR): "description": f"Issues related to {label_name}" } url = f"{BASE_API_URL}/projects/{quote(project_name, safe='')}/labels" logging.info(f"Creating a label {label_name} for the project {project_name}") logging.info("Creating a label %s for the project %s", label_name, project_name) return (requests.post(url, headers=headers, data=payload)) def delete_label(project_name, label_name): Loading @@ -101,7 +101,7 @@ def delete_label(project_name, label_name): 'PRIVATE-TOKEN': JOB_TOKEN } url = f"{BASE_API_URL}/projects/{quote(project_name, safe='')}/labels/{label_name}" logging.info(f"Deleting a label {label_name} for the project {project_name}") logging.info("Deleting a label %s for the project %s", label_name, project_name) return (requests.delete(url, headers=headers)) if __name__ == "__main__": Loading Loading @@ -131,9 +131,9 @@ if __name__ == "__main__": label = get_labels(PROJECT_NAME, search=job_label) if "Unauthorized" not in label.text: if label.json(): logging.info(f"Label {job} exist") logging.info("Label %s exist", job) else: logging.info(f"Label {job} does not exist, creating one now") logging.info("Label %s does not exist, creating one now", job) create_label(PROJECT_NAME, job_label) else: logging.error("Not Authorized, verify the API_TOKEN environment variable in the gitlab project") Loading
tools/job_structure/job_structure.py +9 −9 Original line number Diff line number Diff line Loading @@ -36,14 +36,14 @@ def check_job_yaml(job): template_content = yaml.load(template_yml, Loader=yaml.FullLoader) job_content = yaml.load(job_yml, Loader=yaml.FullLoader) logging.info(f"Checking the content of {JOB_YAML} in job {job}") logging.info("Checking the content of %s in job %s", JOB_YAML, job) diff = set(template_content.keys()) - set(job_content.keys()) if len(diff) > 0: for item in diff: logging.error(f"Key {item} in {JOB_YAML} of job {job} is missing") logging.error("Key %s in %s of job %s is missing", item, JOB_YAML, job) ret = EXIT_FAILURE else: logging.info(f"{JOB_YAML} for job {job} is complete") logging.info("%s for job %s is complete", JOB_YAML, job) return ret def check_directory_structure(template_structure, job): Loading Loading @@ -75,24 +75,24 @@ def check_directory_structure(template_structure, job): job_structure = [obj[obj.find('/') + 1:] for obj in job_structure] # Check if file/directory is empty logging.info(f"Checking empty file/directory in job structure of job {job}") logging.info("Checking empty file/directory in job structure of job %s", job) for item in job_structure: if os.path.isfile(item): if os.path.getsize(item) == 0: logging.error(f"File {item} for job {job} is empty") logging.error("File %s for job %s is empty", item, job) elif os.path.isdir(item): if len(os.listdir(item)) == 0: logging.error(f"Directory {item} for job {job} is empty") logging.error("Directory %s for job %s is empty", item, job) ret = EXIT_SUCCESS if len(set(template_structure_tmp).intersection(job_structure)) != len(template_structure_tmp): # Not every file and directories in template_structure_tmp matched the job structure logging.error(f"Job structure of {job} does not match the template:") logging.error("Job structure of %s does not match the template:", job) for item in set(template_structure_tmp) - set(template_structure_tmp).intersection(job_structure): logging.error(f"\tFile/directory missing: {item}") logging.error("\tFile/directory missing: %s", item) ret = EXIT_FAILURE else: logging.info(f"Job structure of {job} matches the template") logging.info("Job structure of %s matches the template", job) return ret Loading