systemtools
Module with useful functions for getting system information
Authors:
- Jens Timmerman (Ghent University)
- Ward Poelmans (Ghent University)
SystemToolsException
¶
Bases: Exception
raised when systemtools fails
check_easybuild_deps(modtool)
¶
Check presence and version of required and optional EasyBuild dependencies, and report back to terminal.
check_linked_shared_libs(path, required_patterns=None, banned_patterns=None)
¶
Check for (lack of) patterns in linked shared libraries for binary/library at specified path. Uses 'ldd' on Linux and 'otool -L' on macOS to determine linked shared libraries.
Returns True or False for dynamically linked binaries and shared libraries to indicate whether all patterns match and antipatterns don't match.
Returns None if given path is not a dynamically linked binary or library.
check_os_dependency(dep)
¶
Check if dependency is available from OS.
check_python_version()
¶
Check currently used Python version.
det_parallelism(par=None, maxpar=None)
¶
Determine level of parallelism that should be used. Default: educated guess based on # cores and 'ulimit -u' setting: min(# cores, ((ulimit -u) - 15) // 6)
det_pypkg_version(pkg_name, imported_pkg, import_name=None)
¶
Determine version of a Python package.
det_terminal_size()
¶
Determine the current size of the terminal window.
RETURNS | DESCRIPTION |
---|---|
tuple with terminal width and height |
find_library_path(lib_filename)
¶
Search library by file name in the system Return absolute path to existing libraries
PARAMETER | DESCRIPTION |
---|---|
lib_filename |
name of library file
|
get_avail_core_count()
¶
Returns the number of available CPUs, according to cgroups and taskssets limits
get_core_count()
¶
NO LONGER SUPPORTED: use get_avail_core_count() instead
get_cpu_arch_name()
¶
Determine CPU architecture name via archspec (if available).
get_cpu_architecture()
¶
Try to detect the CPU architecture
RETURNS | DESCRIPTION |
---|---|
a value from the CPU_ARCHITECTURES list |
get_cpu_family()
¶
Determine CPU family.
RETURNS | DESCRIPTION |
---|---|
a value from the CPU_FAMILIES list |
get_cpu_features()
¶
Get list of CPU features
get_cpu_model()
¶
Determine CPU model, e.g., Intel(R) Core(TM) i5-2540M CPU @ 2.60GHz
get_cpu_speed()
¶
Returns the (maximum) cpu speed in MHz, as a float value. In case of throttling, the highest cpu speed is returns.
get_cpu_vendor()
¶
Try to detect the CPU vendor
RETURNS | DESCRIPTION |
---|---|
a value from the CPU_VENDORS list |
get_gcc_version()
¶
Process gcc --version
and return the GCC version.
get_glibc_version()
¶
Find the version of glibc used on this system
get_gpu_info()
¶
Get the GPU info
get_kernel_name()
¶
NO LONGER SUPPORTED: use get_os_type() instead
get_linked_libs_raw(path)
¶
Get raw output from command that reports linked libraries for dynamically linked executables/libraries, or None for other types of files.
get_os_name()
¶
Determine system name, e.g., 'redhat' (generic), 'centos', 'debian', 'fedora', 'suse', 'ubuntu', 'red hat enterprise linux server', 'SL' (Scientific Linux), 'opensuse', ...
get_os_type()
¶
Determine system type, e.g., 'Linux', 'Darwin', 'Java'.
get_os_version()
¶
Determine system version.
get_platform_name(withversion=False)
¶
Try and determine platform name e.g., x86_64-unknown-linux, x86_64-apple-darwin
get_shared_lib_ext()
¶
Determine extention for shared libraries
Linux: 'so', Darwin: 'dylib'
get_system_info()
¶
Return a dictionary with system information.
get_tool_version(tool, version_option='--version', ignore_ec=False)
¶
Get output of running version option for specific command line tool. Output is returned as a single-line string (newlines are replaced by '; ').
get_total_memory()
¶
Try to ascertain this node's total memory
RETURNS | DESCRIPTION |
---|---|
total memory as an integer, specifically a number of megabytes |
locate_solib(libobj)
¶
Return absolute path to loaded library using dlinfo Based on https://stackoverflow.com/a/35683698
PARAMETER | DESCRIPTION |
---|---|
libobj |
ctypes CDLL object
|
pick_dep_version(dep_version)
¶
Pick the correct dependency version to use for this system. Input can either be: * a string value (or None) * a dict with options to choose from
Return value is the version to use or False to skip this dependency.
pick_system_specific_value(description, options_or_value, allow_none=False)
¶
Pick an entry for the current system when the input has multiple options
PARAMETER | DESCRIPTION |
---|---|
description |
Descriptive string about the value to be retrieved. Used for logging.
|
options_or_value |
Either a dictionary with options to choose from or a value of any other type
|
allow_none |
When True and no matching arch key was found, return None instead of an error
DEFAULT:
|
sched_getaffinity()
¶
Determine list of available cores for current process.
use_group(group_name)
¶
Use group with specified name.