From 1296e5bf07f7cd26a744083263e8a50dedec634c Mon Sep 17 00:00:00 2001 From: Jean Luca Bez Date: Thu, 4 May 2023 10:08:02 -0700 Subject: [PATCH] check for darshan-runtime in PATH --- drishti/main.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/drishti/main.py b/drishti/main.py index ad3e02f..3211dbf 100644 --- a/drishti/main.py +++ b/drishti/main.py @@ -7,6 +7,7 @@ import time import json import shlex +import shutil import datetime import argparse import subprocess @@ -242,6 +243,12 @@ def convert_bytes(bytes_number): return str(round(double_bytes, 2)) + ' ' + tags[i] +def is_available(name): + """Check whether `name` is on PATH and marked as executable.""" + + return shutil.which(name) is not None + + def message(code, target, level, issue, recommendations=None, details=None): """ Display the message on the screen with level, issue, and recommendation. @@ -306,10 +313,26 @@ def message(code, target, level, issue, recommendations=None, details=None): *messages ) + def check_log_version(file, log_version, library_version): use_file = file if version.parse(log_version) < version.parse('3.4.0'): + # Check if darshan-convert is installed and available in the PATH + if not is_available('darshan-convert'): + console.print( + Panel( + Padding( + 'Darshan file is using an old format and darshan-convert is not available in the PATH.', + (1, 1) + ), + title='{}WARNING'.format('[orange1]'), + title_align='left' + ) + ) + + sys.exit(os.EX_DATAERR) + use_file = os.path.basename(file.replace('.darshan', '.converted.darshan')) console.print(