Exemplo n.º 1
0
    def test_module(self):
        ret = subprocess.run(
            "module --version",
            shell=True,
            stdout=subprocess.PIPE,
            stderr=subprocess.STDOUT,
        )
        print(ret.stdout)

        mod_names = ["lmod"]
        a = Module(mod_names, debug=True)
        print(a.get_command())
        print(a.test_modules())
        assert 0 == a.test_modules()

        b = Module(mod_names, force=True)
        assert 0 == b.test_modules()

        c = Module(mod_names, debug=True)
        assert 0 == c.test_modules()

        d = Module(mod_names, purge=True)
        d.get_command()

        e = Module("lmod settarg", debug=True)
        e.get_command()
Exemplo n.º 2
0
import os, sys

sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))

from lmod.module import Module

mod_names = ["GCCcore", "Python"]

a = Module(mod_names)
module_cmds = a.get_command()
rc = a.test_modules()

if rc == 0:
    print(f"The following modules:  {mod_names} were loaded successfully")
    print("\n")
    print(f"Command Executed: {module_cmds}")

# passing a module name ``invalid`` this is expected to fail during test
bad_names = ["GCCcore", "invalid"]
b = Module(bad_names)

print(f"Failed to load modules: {bad_names}")
print(f"Command Executed: {b.get_command()}")
print(f"return code: {b.test_modules()}")

# disable purge when loading modules
c = Module(mod_names, purge=False)
print(c.get_command())

# force purge modules
d = Module(mod_names, purge=True, force=True)