Skip to content

Commit fa5cbe6

Browse files
Merge pull request #46 from geigerzaehler/which
Don’t execute external program to determine if it is available
2 parents 22c5b23 + a3c1157 commit fa5cbe6

File tree

2 files changed

+5
-10
lines changed

2 files changed

+5
-10
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
## Upcoming
44

5+
- Don’t run custom external programs with `-v` (e.g. `ffmpeg -v`) to determine
6+
whether they are available. (Fixes #43)
57
- Require Python >=3.9
68

79
## v0.14.1 2024-07-11

beetsplug/check.py

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
import os
1515
import re
16+
import shutil
1617
import sys
1718
from concurrent import futures
1819
from hashlib import sha256
@@ -510,16 +511,8 @@ def __init__(self, name, config):
510511
else:
511512
self.fixcmd = False
512513

513-
def available(self):
514-
try:
515-
with open(os.devnull, "wb") as devnull:
516-
check_call(
517-
[self.cmdline.split(" ")[0], "-v"], stdout=devnull, stderr=devnull
518-
)
519-
except OSError:
520-
return False
521-
else:
522-
return True
514+
def available(self) -> bool:
515+
return shutil.which(self.cmdline.split(" ")[0]) is not None
523516

524517
@classmethod
525518
def fixer(cls, item):

0 commit comments

Comments
 (0)