Example #1
0
def test_license_scontrol():
    """License: Compare scontrol values to PySlurm values."""
    all_licenses = pyslurm.licenses().get()
    test_license = all_licenses["matlab"]

    scontrol = subprocess.Popen(
        ["scontrol", "-ddo", "show", "license", "matlab"],
        stdout=subprocess.PIPE
    ).communicate()

    scontrol_stdout = scontrol[0].strip().decode("UTF-8", "replace").split()

    # Convert scontrol show license <license> into a dictionary of key value pairs.
    sctl = {}
    for item in scontrol_stdout:
        kv = item.split("=", 1)
        if kv[1] in ["None", "(null)"]:
            sctl.update({kv[0]: None})
        elif kv[1].isdigit():
            sctl.update({kv[0]: int(kv[1])})
        else:
            sctl.update({kv[0]: kv[1]})

    assert_equals("matlab", sctl.get("LicenseName"))
    assert_equals(test_license.get("total"), sctl.get("Total"))
    assert_equals(test_license.get("in_use"), sctl.get("Used"))
    assert_equals(test_license.get("available"), sctl.get("Free"))
Example #2
0
            print("{0:*^80}".format(""))
    else:

        print("No Licenses found !")


if __name__ == "__main__":

    import pyslurm as slurm
    import sys
    import time

    try:

        licenses = slurm.licenses()
        lic = licenses.get()
        old = licenses.lastUpdate()

        new = old
        display(lic)

        while 1:
            time.sleep(1)
            lic = licenses.get()
            new = licenses.lastUpdate()
            if new > old:
                old = new
                print("{0:*^80}".format(""))
                display(lic)
                print("{0:*^80}".format(""))
Example #3
0
				print "\t%-17s : %s" % (part_key, value[part_key])

			print "-" * 80
	else:
		
		print "No Licenses found !"


if __name__ == "__main__":

	import pyslurm
	import sys
	import time

	try:
		licenses = pyslurm.licenses()
		lic = licenses.get()
		old = licenses.lastUpdate()

		new = old
		display(lic)

		while 1:
			time.sleep(1)
			lic = licenses.get()
			new = licenses.lastUpdate()
			if new > old:
				old  = new
				print "*****************"
				display(lic)
				print "*****************"
Example #4
0
def test_get_license():
    """License: Test licenses().get() return type"""
    licenses = pyslurm.licenses().get()
    assert_true(isinstance(licenses, dict))