Added Windows support
I have added Windows support using PowerShell. I made a script that does effectively what the GNU awk and grep commands do but in PowerShell for Windows compatibility.
This commit is contained in:
1 parent
928e50e08f
commit
ddc402c48d
4 files changed
+21
-15
No files matched your search
+1
-1
@@ -36,4 +36,4 @@ VOICE="Matthew" # e.g. en_us_002
|
||||
TTsChoice="polly" # todo add docs
|
||||
|
||||
# IN-PROGRESS - not yet implemented
|
||||
STORYMODE="False"
|
||||
STORYMODE="False"
|
||||
+2
-1
@@ -170,4 +170,5 @@ reddit-bot-351418-5560ebc49cac.json
|
||||
/.idea
|
||||
*.pyc
|
||||
/video_creation/data/videos.json
|
||||
utils/envUpdate.py.old
|
||||
utils/envUpdate.py.old
|
||||
envVars.txt
|
||||
+9
-10
@@ -4,21 +4,16 @@ import tempfile
|
||||
import logging
|
||||
|
||||
from os import path
|
||||
from sys import platform
|
||||
from sys import platform, stderr
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
def envUpdate():
|
||||
if path.exists(".env.template"):
|
||||
if platform == "win32" or platform == "cygwin":
|
||||
envTemplate = subprocess.run(
|
||||
[r'C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe',
|
||||
r'.\envUpdateWin.ps1'],
|
||||
stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
|
||||
shell=True
|
||||
print("Updating .env is unsupported on Windows.")
|
||||
)
|
||||
return
|
||||
runPS('utils\envUpdateWin.ps1')
|
||||
f = open("envVars.txt", "rb")
|
||||
envTemplate = f.read()
|
||||
elif platform == "darwin" or platform == "linux":
|
||||
envTemplate = subprocess.check_output(
|
||||
"awk -F '=' 'NF {print $1}' .env.template | grep --regexp=^[a-zA-Z]",
|
||||
@@ -46,4 +41,8 @@ def envUpdate():
|
||||
log.error(
|
||||
f"[ERROR] The following environment variables are missing: {missing}.)"
|
||||
)
|
||||
exit(-1)
|
||||
exit(-1)
|
||||
|
||||
def runPS(cmd):
|
||||
completed = subprocess.run(["powershell", "-Command", cmd], capture_output=True)
|
||||
return completed
|
||||
@@ -1,3 +1,9 @@
|
||||
#$envVars = Get-Content '.\.env'
|
||||
#$envVars -split "="
|
||||
Write-Host 'Updating the env is unsupported on Windows.'
|
||||
$envFile = Get-Content ".\.env.template"
|
||||
|
||||
$envFile -split "=" | Where-Object {$_ -notmatch '\"'} | Set-Content ".\envVarsbefSpl.txt"
|
||||
Get-Content ".\envVarsbefSpl.txt" | Where-Object {$_ -notmatch '\#'} | Set-Content ".\envVarsN.txt"
|
||||
Get-Content ".\envVarsN.txt" | Where-Object {$_ -ne ''} | Set-Content ".\envVars.txt"
|
||||
Remove-Item ".\envVarsbefSpl.txt"
|
||||
Remove-Item ".\envVarsN.txt"
|
||||
|
||||
Write-Host $nowSplit
|
||||
Reference in new issue
Block a user