diff --git a/jellyfin_accounts/__init__.py b/jellyfin_accounts/__init__.py index 41af903..ad66164 100755 --- a/jellyfin_accounts/__init__.py +++ b/jellyfin_accounts/__init__.py @@ -72,7 +72,7 @@ else: # Temp config so logger knows whether to use debug mode or not temp_config = configparser.RawConfigParser() -temp_config.read(config_path) +temp_config.read(str(config_path.resolve())) def create_log(name): diff --git a/jellyfin_accounts/web_api.py b/jellyfin_accounts/web_api.py index 55f1e1b..6c1cfdb 100644 --- a/jellyfin_accounts/web_api.py +++ b/jellyfin_accounts/web_api.py @@ -441,7 +441,7 @@ def modifyConfig(): temp_config = configparser.RawConfigParser( comment_prefixes="/", allow_no_value=True ) - temp_config.read(config_path) + temp_config.read(str(config_path.resolve())) for section in data: if section in temp_config and 'restart-program' not in section: for item in data[section]: diff --git a/mail/generate.py b/mail/generate.py index 825c16e..7009275 100755 --- a/mail/generate.py +++ b/mail/generate.py @@ -1,13 +1,22 @@ import subprocess import shutil +import os from pathlib import Path def runcmd(cmd): + if os.name == "nt": + return subprocess.check_output(cmd, shell=True) proc = subprocess.Popen(cmd.split(), stdout=subprocess.PIPE) return proc.communicate() local_path = Path(__file__).resolve().parent -node_bin = local_path.parent / 'node_modules' / '.bin' +node_bin = Path(runcmd("npm bin")[0].decode('utf-8').rstrip()) +print(f"assuming npm bin directory \"{node_bin}\". Is this correct?") +if input("[yY/nN]: ").lower() == "n": + node_bin = local_path.parent / 'node_modules' / '.bin' + print(f"this? \"{node_bin}\"") + if input("[yY/nN]: ").lower() == "n": + node_bin = input("input bin directory: ") for mjml in [f for f in local_path.iterdir() if f.is_file() and 'mjml' in f.suffix]: print(f'Compiling {mjml.name}') diff --git a/scss/compile.py b/scss/compile.py index c57b4de..ad0deab 100755 --- a/scss/compile.py +++ b/scss/compile.py @@ -2,14 +2,23 @@ import sass import subprocess import shutil +import os from pathlib import Path def runcmd(cmd): + if os.name == "nt": + return subprocess.check_output(cmd, shell=True) proc = subprocess.Popen(cmd.split(), stdout=subprocess.PIPE) return proc.communicate() local_path = Path(__file__).resolve().parent -node_bin = local_path.parent / 'node_modules' / '.bin' +node_bin = Path(runcmd("npm bin")[0].decode('utf-8').rstrip()) +print(f"assuming npm bin directory \"{node_bin}\". Is this correct?") +if input("[yY/nN]: ").lower() == "n": + node_bin = local_path.parent / 'node_modules' / '.bin' + print(f"this? \"{node_bin}\"") + if input("[yY/nN]: ").lower() == "n": + node_bin = input("input bin directory: ") for bsv in [d for d in local_path.iterdir() if 'bs' in d.name]: scss = bsv / f'{bsv.name}-jf.scss' diff --git a/scss/get_node_deps.py b/scss/get_node_deps.py index a048e6b..c6dd92d 100644 --- a/scss/get_node_deps.py +++ b/scss/get_node_deps.py @@ -1,14 +1,22 @@ #!/usr/bin/env python3 import subprocess +import os from pathlib import Path + def runcmd(cmd): + if os.name == "nt": + return subprocess.check_output(cmd, shell=True) proc = subprocess.Popen(cmd.split(), stdout=subprocess.PIPE) return proc.communicate() + print('Installing npm packages') +if os.name == "nt": + print("Note: npm on windows installs all packages in the root directory, so things might get ugly.") + root_path = Path(__file__).parents[1] runcmd(f'npm install --prefix {root_path}')