Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use built-in shutil.which() instead of which(1) tool #20

Merged
merged 1 commit into from
Oct 26, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions k5test/realm.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,16 +68,13 @@ def _cfg_merge(cfg1, cfg2):


def _discover_path(name, default, paths):
stderr_out = subprocess.DEVNULL
try:
path = subprocess.check_output(["which", name], stderr=stderr_out).strip()
path = path.decode(sys.getfilesystemencoding() or sys.getdefaultencoding())
path = shutil.which(name)
if path is not None:
_LOG.debug(f"Using discovered path for {name} ({path})")
return path
except subprocess.CalledProcessError as e:
else:
path = paths.get(name, default)
_LOG.debug(f"Using default path for {name} ({path}): {e}")
return path
return path


class K5Realm(metaclass=abc.ABCMeta):
Expand Down