Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
33231: add try except clause to catch OSError during run
Browse files Browse the repository at this point in the history
  • Loading branch information
seblabbe committed Jan 27, 2022
1 parent 0fe547b commit f42ade0
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/sage/features/lrs.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,12 @@ def is_functional(self):
with open(tf_name, 'w') as tf:
tf.write("V-representation\nbegin\n 1 1 rational\n 1 \nend\nvolume")
command = ['lrs', tf_name]
result = subprocess.run(command, capture_output=True, text=True)
try:
result = subprocess.run(command, capture_output=True, text=True)
except OSError as e:
return FeatureTestResult(self, False, reason='Running command "{}" '
'raised an OSError "{}" '.format(' '.join(command), e))

if result.returncode:
return FeatureTestResult(self, False,
reason="Call to `{command}` failed with exit code {result.returncode}.".format(command=" ".join(command), result=result))
Expand All @@ -67,7 +72,11 @@ def is_functional(self):
with open(tf_name, 'w') as tf:
tf.write("1 1\n \n 0\n \n 0\n")
command = ['lrsnash', tf_name]
result = subprocess.run(command, capture_output=True, text=True)
try:
result = subprocess.run(command, capture_output=True, text=True)
except OSError as e:
return FeatureTestResult(self, False, reason='Running command "{}" '
'raised an OSError "{}" '.format(' '.join(command), e))
if result.returncode:
return FeatureTestResult(self, False, reason='Running command "{}" '
'returned non-zero exit status "{}" with stderr '
Expand Down

0 comments on commit f42ade0

Please sign in to comment.