Skip to content

Commit 08fe6aa

Browse files
committed
fix: CLI path in windows
1 parent 9efe284 commit 08fe6aa

File tree

2 files changed

+30
-9
lines changed

2 files changed

+30
-9
lines changed

jupyterlab_wakatime/handlers.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,9 @@
77

88
from jupyter_server.base.handlers import APIHandler
99
from jupyter_server.utils import url_path_join
10-
from jupyterlab._version import __version__ as jlab_version
1110
import tornado
1211

13-
from ._version import __version__ as extension_version
14-
15-
HOME_FOLDER = os.path.realpath(
16-
os.environ.get("WAKATIME_HOME") or os.path.expanduser("~")
17-
)
18-
RESOURCES_FOLDER = os.path.join(HOME_FOLDER, ".wakatime")
19-
WAKATIME_CLI = os.path.join(RESOURCES_FOLDER, "wakatime-cli")
20-
USER_AGENT = f"jupyterlab/{jlab_version} jupyterlab-wakatime/{extension_version}"
12+
from .wakatime import USER_AGENT, WAKATIME_CLI
2113

2214

2315
class RequestData(TypedDict):

jupyterlab_wakatime/wakatime.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import os
2+
import platform
3+
4+
from jupyterlab._version import __version__ as jlab_version
5+
6+
from ._version import __version__ as extension_version
7+
8+
9+
def get_os_name():
10+
name = platform.system().lower()
11+
if (
12+
name.startswith("cygwin")
13+
or name.startswith("mingw")
14+
or name.startswith("msys")
15+
):
16+
return "windows"
17+
if name == "linux" and "ANDROID_DATA" in os.environ:
18+
return "android"
19+
return name
20+
21+
22+
USER_AGENT = f"jupyterlab/{jlab_version} jupyterlab-wakatime/{extension_version}"
23+
HOME_FOLDER = os.path.realpath(
24+
os.environ.get("WAKATIME_HOME") or os.path.expanduser("~")
25+
)
26+
RESOURCES_FOLDER = os.path.join(HOME_FOLDER, ".wakatime")
27+
WAKATIME_CLI = os.path.join(RESOURCES_FOLDER, "wakatime-cli")
28+
if get_os_name() == "windows":
29+
WAKATIME_CLI += ".exe"

0 commit comments

Comments
 (0)