From cb47fcd9bca01bfbb8d41b4dd2f7af82b3f081cf Mon Sep 17 00:00:00 2001 From: barts Date: Sun, 7 Apr 2024 11:20:46 +0200 Subject: [PATCH] fix: global interpreter was used in subprocess instead of venv --- src/khalorg/khal/helpers.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/khalorg/khal/helpers.py b/src/khalorg/khal/helpers.py index 00ae0a9..d6a616a 100644 --- a/src/khalorg/khal/helpers.py +++ b/src/khalorg/khal/helpers.py @@ -1,4 +1,5 @@ import logging +import sys from datetime import date, datetime from subprocess import STDOUT, CalledProcessError, check_output from typing import Callable @@ -56,6 +57,7 @@ def subprocess_callback(cmd: list) -> Callable: callback function """ + def callback(args: list) -> str: return try_check_output([*cmd, *args]).decode() @@ -64,12 +66,13 @@ def callback(args: list) -> str: def try_check_output(args: list) -> bytes: try: - return check_output(args, stderr=STDOUT) + return check_output(args, stderr=STDOUT, executable=sys.executable) except CalledProcessError as error: error_message: str = ( f"The following arguments were sent to khal:\n\n{' '.join(args)}" "\n\nNext, the following error was received from khal:\n\n" - f"{error.output.decode()}\n\n") + f"{error.output.decode()}\n\n" + ) logging.critical(error_message) raise Exception(error_message) from error