Skip to content

Commit

Permalink
fix: when running khalorg from a venv, the global khal executable is …
Browse files Browse the repository at this point in the history
…sometimes used instead of the venv its khal executable.
  • Loading branch information
BartSte committed Apr 15, 2024
1 parent 7d11369 commit 510327d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
7 changes: 5 additions & 2 deletions src/khalorg/khal/calendar.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import logging
from os.path import dirname, join
import sys
from datetime import date, datetime
from typing import Callable, Iterable, TypedDict, Union

Expand Down Expand Up @@ -84,8 +86,9 @@ def __init__(self, name: str):
"""
path_config: Union[str, None] = find_configuration_file()

new_item_args: list = ["python3", "-m", "khal", "new"]
list_args: list = ["python3", "-m", "khal", "list", "-df", ""]
khal_bin: str = join(dirname(sys.executable), 'khal')
new_item_args: list = [khal_bin, "new"]
list_args: list = [khal_bin, "list", "-df", ""]

self._collection: CalendarCollection
self._new_item: Callable = subprocess_callback(new_item_args)
Expand Down
3 changes: 1 addition & 2 deletions src/khalorg/khal/helpers.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import logging
import sys
from datetime import date, datetime
from subprocess import STDOUT, CalledProcessError, check_output
from typing import Callable
Expand Down Expand Up @@ -72,7 +71,7 @@ def callback(args: list) -> str:

def try_check_output(args: list) -> bytes:
try:
return check_output(args, stderr=STDOUT, executable=sys.executable)
return check_output(args, stderr=STDOUT)
except CalledProcessError as error:
error_message: str = (
f"The following arguments were sent to khal:\n\n{' '.join(args)}"
Expand Down

0 comments on commit 510327d

Please sign in to comment.