Skip to content

Commit b9bee6b

Browse files
committed
Use NXC_PATH instead of XDG env var and also initialize TMP folder when nxc folder exists
1 parent 07803cb commit b9bee6b

2 files changed

Lines changed: 11 additions & 19 deletions

File tree

nxc/first_run.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,12 @@
88

99

1010
def first_run_setup(logger=nxc_logger):
11-
if not exists(TMP_PATH):
12-
mkdir(TMP_PATH)
13-
1411
if not exists(NXC_PATH):
1512
logger.display("First time use detected")
1613
logger.display("Creating home directory structure")
1714
mkdir(NXC_PATH)
15+
if not exists(TMP_PATH):
16+
mkdir(TMP_PATH)
1817

1918
folders = (
2019
"logs",

nxc/paths.py

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,13 @@
1-
import os
2-
import sys
1+
from os.path import join, normpath, expanduser, dirname
2+
from os import environ, getenv
33
import nxc
44

5-
if "XDG_CONFIG_HOME" in os.environ: # noqa: SIM108
6-
NXC_PATH = os.path.join(os.getenv("XDG_CONFIG_HOME"), "nxc")
5+
if "NXC_PATH" in environ: # noqa: SIM108
6+
NXC_PATH = normpath(getenv("NXC_PATH"))
77
else:
8-
NXC_PATH = os.path.normpath(os.path.expanduser("~/.nxc"))
9-
10-
if os.name == "nt":
11-
TMP_PATH = os.getenv("LOCALAPPDATA") + "\\Temp\\nxc_hosted"
12-
elif hasattr(sys, "getandroidapilevel"):
13-
TMP_PATH = os.path.join("/data", "data", "com.termux", "files", "usr", "tmp", "nxc_hosted")
14-
else:
15-
TMP_PATH = os.path.join("/tmp", "nxc_hosted")
8+
NXC_PATH = normpath(expanduser("~/.nxc"))
169

17-
CERT_PATH = os.path.join(NXC_PATH, "nxc.pem")
18-
CONFIG_PATH = os.path.join(NXC_PATH, "nxc.conf")
19-
WORKSPACE_DIR = os.path.join(NXC_PATH, "workspaces")
20-
DATA_PATH = os.path.join(os.path.dirname(nxc.__file__), "data")
10+
TMP_PATH = join(NXC_PATH, "tmp")
11+
CONFIG_PATH = join(NXC_PATH, "nxc.conf")
12+
WORKSPACE_DIR = join(NXC_PATH, "workspaces")
13+
DATA_PATH = join(dirname(nxc.__file__), "data")

0 commit comments

Comments
 (0)