Skip to content

Commit

Permalink
fix: global interpreter was used in subprocess instead of venv
Browse files Browse the repository at this point in the history
  • Loading branch information
BartSte committed Apr 7, 2024
1 parent 44fda4e commit cb47fcd
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/khalorg/khal/helpers.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import logging
import sys
from datetime import date, datetime
from subprocess import STDOUT, CalledProcessError, check_output
from typing import Callable
Expand Down Expand Up @@ -56,6 +57,7 @@ def subprocess_callback(cmd: list) -> Callable:
callback function
"""

def callback(args: list) -> str:
return try_check_output([*cmd, *args]).decode()

Expand All @@ -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

Expand Down

0 comments on commit cb47fcd

Please sign in to comment.