Pmodules_tools/pmodules_tools/pmodules_tools.py

65 lines
1.8 KiB
Python

import argparse
import sys
from datetime import date
from deps_status.check import deps_status_check, subprocess_cmd
from weekly_diff.check import weekly_check_diff
assert sys.version_info >= (
3,
7,
), "Python version is too low, please load a python >= 3.7"
def parse_args():
parser = argparse.ArgumentParser(
description="A python project to analyse Pmodules modules and their status changes."
)
parser.add_argument(
"-d",
"--deps-check",
action="store_true",
help="Check for module dependencies status and change their status accordingly.",
)
parser.add_argument(
"-w",
"--weekly-check",
action="store_true",
help="Report new, deleted or changed modules and print it to pmodules_changes.md.",
)
parser.add_argument(
"--select-module",
default="",
help="Select a subtype of module which should be checked for. Default is all.",
)
args = parser.parse_args()
return args
def main():
# Analyse CLI args
cli_args = parse_args()
# Global variables
Pmodules_db_path = "/afs/psi.ch/sys/spack-rhel7/test/"
Pmodules_states = ["deprecated", "stable", "unstable"]
# Main search to analyse
module_cmd = (
"module search -a " + cli_args.select_module + " --all-deps --no-header"
)
module_cmd_process = subprocess_cmd(module_cmd)
# Check for Pmodules addition, deletion or changes of state
if cli_args.weekly_check:
weekly_check_diff(module_cmd_process.stderr, Pmodules_db_path, Pmodules_states)
# Check for module dependencies status and change the main module status accordingly
if cli_args.deps_check:
deps_status_check(module_cmd_process)
if __name__ == "__main__":
main()