Skip to content

Commit 510327d

Browse files
committed
fix: when running khalorg from a venv, the global khal executable is sometimes used instead of the venv its khal executable.
1 parent 7d11369 commit 510327d

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/khalorg/khal/calendar.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import logging
2+
from os.path import dirname, join
3+
import sys
24
from datetime import date, datetime
35
from typing import Callable, Iterable, TypedDict, Union
46

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

87-
new_item_args: list = ["python3", "-m", "khal", "new"]
88-
list_args: list = ["python3", "-m", "khal", "list", "-df", ""]
89+
khal_bin: str = join(dirname(sys.executable), 'khal')
90+
new_item_args: list = [khal_bin, "new"]
91+
list_args: list = [khal_bin, "list", "-df", ""]
8992

9093
self._collection: CalendarCollection
9194
self._new_item: Callable = subprocess_callback(new_item_args)

src/khalorg/khal/helpers.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import logging
2-
import sys
32
from datetime import date, datetime
43
from subprocess import STDOUT, CalledProcessError, check_output
54
from typing import Callable
@@ -72,7 +71,7 @@ def callback(args: list) -> str:
7271

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

0 commit comments

Comments
 (0)