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.
pull/553/head
owengaspard 3 years ago
parent 928e50e08f
commit ddc402c48d

1
.gitignore vendored

@ -171,3 +171,4 @@ reddit-bot-351418-5560ebc49cac.json
*.pyc
/video_creation/data/videos.json
utils/envUpdate.py.old
envVars.txt

@ -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]",
@ -47,3 +42,7 @@ def envUpdate():
f"[ERROR] The following environment variables are missing: {missing}.)"
)
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
Loading…
Cancel
Save