Skip to content

Commit 1296e5b

Browse files
committed
check for darshan-runtime in PATH
1 parent 55cc218 commit 1296e5b

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

drishti/main.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import time
88
import json
99
import shlex
10+
import shutil
1011
import datetime
1112
import argparse
1213
import subprocess
@@ -242,6 +243,12 @@ def convert_bytes(bytes_number):
242243
return str(round(double_bytes, 2)) + ' ' + tags[i]
243244

244245

246+
def is_available(name):
247+
"""Check whether `name` is on PATH and marked as executable."""
248+
249+
return shutil.which(name) is not None
250+
251+
245252
def message(code, target, level, issue, recommendations=None, details=None):
246253
"""
247254
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):
306313
*messages
307314
)
308315

316+
309317
def check_log_version(file, log_version, library_version):
310318
use_file = file
311319

312320
if version.parse(log_version) < version.parse('3.4.0'):
321+
# Check if darshan-convert is installed and available in the PATH
322+
if not is_available('darshan-convert'):
323+
console.print(
324+
Panel(
325+
Padding(
326+
'Darshan file is using an old format and darshan-convert is not available in the PATH.',
327+
(1, 1)
328+
),
329+
title='{}WARNING'.format('[orange1]'),
330+
title_align='left'
331+
)
332+
)
333+
334+
sys.exit(os.EX_DATAERR)
335+
313336
use_file = os.path.basename(file.replace('.darshan', '.converted.darshan'))
314337

315338
console.print(

0 commit comments

Comments
 (0)