Skip to content

Commit 95bd45e

Browse files
committed
disable storing output of shell commands to temporary file in tools/modules.py and tools/systemtools.py
1 parent ca9186e commit 95bd45e

File tree

2 files changed

+24
-19
lines changed

2 files changed

+24
-19
lines changed

easybuild/tools/modules.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ def check_module_function(self, allow_mismatch=False, regex=None):
312312
output, exit_code = None, 1
313313
else:
314314
cmd = "type module"
315-
res = run_shell_cmd(cmd, fail_on_error=False, in_dry_run=False, hidden=True)
315+
res = run_shell_cmd(cmd, fail_on_error=False, in_dry_run=False, hidden=True, output_file=False)
316316
output, exit_code = res.output, res.exit_code
317317

318318
if regex is None:
@@ -821,7 +821,7 @@ def run_module(self, *args, **kwargs):
821821
cmd = ' '.join(cmd_list)
822822
# note: module commands are always run in dry mode, and are kept hidden in trace and dry run output
823823
res = run_shell_cmd(cmd_list, env=environ, fail_on_error=False, shell=False, split_stderr=True,
824-
hidden=True, in_dry_run=True)
824+
hidden=True, in_dry_run=True, output_file=False)
825825

826826
# stdout will contain python code (to change environment etc)
827827
# stderr will contain text (just like the normal module command)

easybuild/tools/systemtools.py

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ def get_avail_core_count():
273273
core_cnt = int(sum(sched_getaffinity()))
274274
else:
275275
# BSD-type systems
276-
res = run_shell_cmd('sysctl -n hw.ncpu', in_dry_run=True, hidden=True, with_hooks=False)
276+
res = run_shell_cmd('sysctl -n hw.ncpu', in_dry_run=True, hidden=True, with_hooks=False, output_file=False)
277277
try:
278278
if int(res.output) > 0:
279279
core_cnt = int(res.output)
@@ -310,7 +310,7 @@ def get_total_memory():
310310
elif os_type == DARWIN:
311311
cmd = "sysctl -n hw.memsize"
312312
_log.debug("Trying to determine total memory size on Darwin via cmd '%s'", cmd)
313-
res = run_shell_cmd(cmd, in_dry_run=True, hidden=True, with_hooks=False)
313+
res = run_shell_cmd(cmd, in_dry_run=True, hidden=True, with_hooks=False, output_file=False)
314314
if res.exit_code == 0:
315315
memtotal = int(res.output.strip()) // (1024**2)
316316

@@ -392,14 +392,15 @@ def get_cpu_vendor():
392392

393393
elif os_type == DARWIN:
394394
cmd = "sysctl -n machdep.cpu.vendor"
395-
res = run_shell_cmd(cmd, fail_on_error=False, in_dry_run=True, hidden=True, with_hooks=False)
395+
res = run_shell_cmd(cmd, fail_on_error=False, in_dry_run=True, hidden=True, with_hooks=False, output_file=False)
396396
out = res.output.strip()
397397
if res.exit_code == 0 and out in VENDOR_IDS:
398398
vendor = VENDOR_IDS[out]
399399
_log.debug("Determined CPU vendor on DARWIN as being '%s' via cmd '%s" % (vendor, cmd))
400400
else:
401401
cmd = "sysctl -n machdep.cpu.brand_string"
402-
res = run_shell_cmd(cmd, fail_on_error=False, in_dry_run=True, hidden=True, with_hooks=False)
402+
res = run_shell_cmd(cmd, fail_on_error=False, in_dry_run=True, hidden=True, with_hooks=False,
403+
output_file=False)
403404
out = res.output.strip().split(' ')[0]
404405
if res.exit_code == 0 and out in CPU_VENDORS:
405406
vendor = out
@@ -502,7 +503,7 @@ def get_cpu_model():
502503

503504
elif os_type == DARWIN:
504505
cmd = "sysctl -n machdep.cpu.brand_string"
505-
res = run_shell_cmd(cmd, in_dry_run=True, hidden=True, with_hooks=False)
506+
res = run_shell_cmd(cmd, in_dry_run=True, hidden=True, with_hooks=False, output_file=False)
506507
if res.exit_code == 0:
507508
model = res.output.strip()
508509
_log.debug("Determined CPU model on Darwin using cmd '%s': %s" % (cmd, model))
@@ -547,7 +548,7 @@ def get_cpu_speed():
547548
elif os_type == DARWIN:
548549
cmd = "sysctl -n hw.cpufrequency_max"
549550
_log.debug("Trying to determine CPU frequency on Darwin via cmd '%s'" % cmd)
550-
res = run_shell_cmd(cmd, in_dry_run=True, hidden=True, with_hooks=False)
551+
res = run_shell_cmd(cmd, in_dry_run=True, hidden=True, with_hooks=False, output_file=False)
551552
out = res.output.strip()
552553
cpu_freq = None
553554
if res.exit_code == 0 and out:
@@ -595,7 +596,8 @@ def get_cpu_features():
595596
for feature_set in ['extfeatures', 'features', 'leaf7_features']:
596597
cmd = "sysctl -n machdep.cpu.%s" % feature_set
597598
_log.debug("Trying to determine CPU features on Darwin via cmd '%s'", cmd)
598-
res = run_shell_cmd(cmd, in_dry_run=True, hidden=True, fail_on_error=False, with_hooks=False)
599+
res = run_shell_cmd(cmd, in_dry_run=True, hidden=True, fail_on_error=False, with_hooks=False,
600+
output_file=False)
599601
if res.exit_code == 0:
600602
cpu_feat.extend(res.output.strip().lower().split())
601603

@@ -622,7 +624,8 @@ def get_gpu_info():
622624
try:
623625
cmd = "nvidia-smi --query-gpu=gpu_name,driver_version --format=csv,noheader"
624626
_log.debug("Trying to determine NVIDIA GPU info on Linux via cmd '%s'", cmd)
625-
res = run_shell_cmd(cmd, fail_on_error=False, in_dry_run=True, hidden=True, with_hooks=False)
627+
res = run_shell_cmd(cmd, fail_on_error=False, in_dry_run=True, hidden=True, with_hooks=False,
628+
output_file=False)
626629
if res.exit_code == 0:
627630
for line in res.output.strip().split('\n'):
628631
nvidia_gpu_info = gpu_info.setdefault('NVIDIA', {})
@@ -640,13 +643,15 @@ def get_gpu_info():
640643
try:
641644
cmd = "rocm-smi --showdriverversion --csv"
642645
_log.debug("Trying to determine AMD GPU driver on Linux via cmd '%s'", cmd)
643-
res = run_shell_cmd(cmd, fail_on_error=False, in_dry_run=True, hidden=True, with_hooks=False)
646+
res = run_shell_cmd(cmd, fail_on_error=False, in_dry_run=True, hidden=True, with_hooks=False,
647+
output_file=False)
644648
if res.exit_code == 0:
645649
amd_driver = res.output.strip().split('\n')[1].split(',')[1]
646650

647651
cmd = "rocm-smi --showproductname --csv"
648652
_log.debug("Trying to determine AMD GPU info on Linux via cmd '%s'", cmd)
649-
res = run_shell_cmd(cmd, fail_on_error=False, in_dry_run=True, hidden=True, with_hooks=False)
653+
res = run_shell_cmd(cmd, fail_on_error=False, in_dry_run=True, hidden=True, with_hooks=False,
654+
output_file=False)
650655
if res.exit_code == 0:
651656
for line in res.output.strip().split('\n')[1:]:
652657
amd_card_series = line.split(',')[1]
@@ -865,7 +870,7 @@ def check_os_dependency(dep):
865870
pkg_cmd_flag.get(pkg_cmd),
866871
dep,
867872
])
868-
res = run_shell_cmd(cmd, fail_on_error=False, in_dry_run=True, hidden=True)
873+
res = run_shell_cmd(cmd, fail_on_error=False, in_dry_run=True, hidden=True, output_file=False)
869874
found = res.exit_code == 0
870875
if found:
871876
break
@@ -877,7 +882,7 @@ def check_os_dependency(dep):
877882
# try locate if it's available
878883
if not found and which('locate'):
879884
cmd = 'locate -c --regexp "/%s$"' % dep
880-
res = run_shell_cmd(cmd, fail_on_error=False, in_dry_run=True, hidden=True)
885+
res = run_shell_cmd(cmd, fail_on_error=False, in_dry_run=True, hidden=True, output_file=False)
881886
try:
882887
found = (res.exit_code == 0 and int(res.output.strip()) > 0)
883888
except ValueError:
@@ -893,7 +898,7 @@ def get_tool_version(tool, version_option='--version', ignore_ec=False):
893898
Output is returned as a single-line string (newlines are replaced by '; ').
894899
"""
895900
res = run_shell_cmd(' '.join([tool, version_option]), fail_on_error=False, in_dry_run=True,
896-
hidden=True, with_hooks=False)
901+
hidden=True, with_hooks=False, output_file=False)
897902
if not ignore_ec and res.exit_code:
898903
_log.warning("Failed to determine version of %s using '%s %s': %s" % (tool, tool, version_option, res.output))
899904
return UNKNOWN
@@ -905,7 +910,7 @@ def get_gcc_version():
905910
"""
906911
Process `gcc --version` and return the GCC version.
907912
"""
908-
res = run_shell_cmd('gcc --version', fail_on_error=False, in_dry_run=True, hidden=True)
913+
res = run_shell_cmd('gcc --version', fail_on_error=False, in_dry_run=True, hidden=True, output_file=False)
909914
gcc_ver = None
910915
if res.exit_code:
911916
_log.warning("Failed to determine the version of GCC: %s", res.output)
@@ -961,7 +966,7 @@ def get_linked_libs_raw(path):
961966
or None for other types of files.
962967
"""
963968

964-
res = run_shell_cmd("file %s" % path, fail_on_error=False, hidden=True)
969+
res = run_shell_cmd("file %s" % path, fail_on_error=False, hidden=True, output_file=False)
965970
if res.exit_code:
966971
fail_msg = "Failed to run 'file %s': %s" % (path, res.output)
967972
_log.warning(fail_msg)
@@ -996,7 +1001,7 @@ def get_linked_libs_raw(path):
9961001
# take into account that 'ldd' may fail for strange reasons,
9971002
# like printing 'not a dynamic executable' when not enough memory is available
9981003
# (see also https://bugzilla.redhat.com/show_bug.cgi?id=1817111)
999-
res = run_shell_cmd(linked_libs_cmd, fail_on_error=False, hidden=True)
1004+
res = run_shell_cmd(linked_libs_cmd, fail_on_error=False, hidden=True, output_file=False)
10001005
if res.exit_code == 0:
10011006
linked_libs_out = res.output
10021007
else:
@@ -1178,7 +1183,7 @@ def get_default_parallelism():
11781183
# No cache -> Calculate value from current system values
11791184
par = get_avail_core_count()
11801185
# determine max user processes via ulimit -u
1181-
res = run_shell_cmd("ulimit -u", in_dry_run=True, hidden=True)
1186+
res = run_shell_cmd("ulimit -u", in_dry_run=True, hidden=True, output_file=False)
11821187
try:
11831188
if res.output.startswith("unlimited"):
11841189
maxuserproc = 2 ** 32 - 1

0 commit comments

Comments
 (0)