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

Commit

Permalink
33231: running the cmd inside of a try except clause
Browse files Browse the repository at this point in the history
  • Loading branch information
seblabbe committed Jan 26, 2022
1 parent 97d550d commit 767fb8e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/sage/features/ffmpeg.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,11 @@ def is_functional(self):
# Running the commands and reporting any issue encountered
from subprocess import run
for cmd in commands:
result = run(cmd, cwd=base, capture_output=True, text=True)
try:
result = run(cmd, cwd=base, capture_output=True, text=True)
except OSError as e:
return FeatureTestResult(self, False, reason='Running command "{}" '
'raised an OSError "{}" '.format(' '.join(cmd), e))

# If an error occurred, return False
if result.returncode:
Expand Down
7 changes: 6 additions & 1 deletion src/sage/features/imagemagick.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,12 @@ def is_functional(self):
from subprocess import run
cmd = ['convert', '-dispose', 'Background', '-delay', '20',
'-loop', '0', filename_png, filename_gif]
result = run(cmd, cwd=base, capture_output=True, text=True)

try:
result = run(cmd, cwd=base, capture_output=True, text=True)
except OSError as e:
return FeatureTestResult(self, False, reason='Running command "{}" '
'raised an OSError "{}" '.format(' '.join(cmd), e))

# If an error occurred, return False
if result.returncode:
Expand Down

0 comments on commit 767fb8e

Please sign in to comment.