potential fixes for windows

hopefully fixes scss and email generation on windows by fixing runcmd()
and (optionally) reading npm bin location from the 'npm bin' command.
also, config path is cast to string before being passed to configparser.
This commit is contained in:
Harvey Tindall 2020-08-04 01:29:29 +01:00
parent d5609f3870
commit a38045cefb
Signed by: hrfee
GPG Key ID: BBC65952848FB1A2
5 changed files with 30 additions and 4 deletions

View File

@ -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):

View File

@ -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]:

View File

@ -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}')

View File

@ -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'

View File

@ -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}')