fixed #553
parent
09ba69c5bc
commit
76bff1a02d
@ -1,19 +0,0 @@
|
|||||||
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
|
|
||||||
// https://github.com/microsoft/vscode-dev-containers/tree/v0.238.0/containers/docker-existing-dockerfile
|
|
||||||
{
|
|
||||||
"name": "Existing Dockerfile",
|
|
||||||
|
|
||||||
// Sets the run context to one level up instead of the .devcontainer folder.
|
|
||||||
"context": "..",
|
|
||||||
|
|
||||||
// Update the 'dockerFile' property if you aren't using the standard 'Dockerfile' filename.
|
|
||||||
"dockerFile": "../Dockerfile",
|
|
||||||
|
|
||||||
// Add the IDs of extensions you want installed when the container is created.
|
|
||||||
"extensions": [
|
|
||||||
"ms-python.python"
|
|
||||||
],
|
|
||||||
|
|
||||||
// Install OS dependencies
|
|
||||||
"postCreateCommand": "apt-get update && apt -qq install -y sox && apt-get install -y libsox-fmt-all"
|
|
||||||
}
|
|
@ -1,13 +0,0 @@
|
|||||||
{
|
|
||||||
"version": "0.2.0",
|
|
||||||
"configurations": [
|
|
||||||
{
|
|
||||||
"name": "Python: Main.py",
|
|
||||||
"type": "python",
|
|
||||||
"request": "launch",
|
|
||||||
"program": "${workspaceFolder}/main.py",
|
|
||||||
"console": "integratedTerminal",
|
|
||||||
"justMyCode": true
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
@ -0,0 +1,62 @@
|
|||||||
|
import os
|
||||||
|
import subprocess
|
||||||
|
import tempfile
|
||||||
|
from os import path
|
||||||
|
from sys import platform
|
||||||
|
|
||||||
|
ACCEPTABLE_TO_BE_LEFT_BLANK = ['RANDOM_THREAD', 'TIMES_TO_RUN']
|
||||||
|
|
||||||
|
|
||||||
|
def envUpdate():
|
||||||
|
if path.exists(".env.template"): # if .env.template exists and .env does not exist
|
||||||
|
if platform == "win32" or platform == "cygwin":
|
||||||
|
runPS('utils/scripts/FileGrabber.ps1')
|
||||||
|
with open(".\\video_creation\\data\\envvars.txt", "rb") as f:
|
||||||
|
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]",
|
||||||
|
shell=True, )
|
||||||
|
else:
|
||||||
|
raise OSError("Unsupported platform")
|
||||||
|
elif path.exists(".env"):
|
||||||
|
if platform == "win32" or platform == "cygwin":
|
||||||
|
runPS('utils/scripts/FileGrabberenv.ps1')
|
||||||
|
with open(".\\video_creation\\data\\envvars.txt", "rb") as f:
|
||||||
|
envTemplate = f.read()
|
||||||
|
elif platform == "darwin" or platform == "linux":
|
||||||
|
envTemplate = subprocess.check_output("awk -F '=' 'NF {print $1}' .env | grep --regexp=^[a-zA-Z]",
|
||||||
|
shell=True, )
|
||||||
|
else:
|
||||||
|
raise OSError("Unsupported platform")
|
||||||
|
else:
|
||||||
|
raise FileNotFoundError("No .env or .env.template file found")
|
||||||
|
tempEnv = tempfile.TemporaryFile()
|
||||||
|
tempEnv.write(envTemplate)
|
||||||
|
tempEnv.seek(0)
|
||||||
|
envVars = tempEnv.readlines()
|
||||||
|
|
||||||
|
|
||||||
|
missing = []
|
||||||
|
isMissingEnvs = False
|
||||||
|
for env in envVars:
|
||||||
|
try:
|
||||||
|
env = env.decode("utf-8").strip()
|
||||||
|
except AttributeError:
|
||||||
|
env = env.strip()
|
||||||
|
|
||||||
|
if env not in os.environ:
|
||||||
|
if str(env) in ACCEPTABLE_TO_BE_LEFT_BLANK:
|
||||||
|
continue
|
||||||
|
isMissingEnvs = True
|
||||||
|
missing.append(env)
|
||||||
|
|
||||||
|
if isMissingEnvs:
|
||||||
|
printstr = ''
|
||||||
|
[printstr + str(var) for var in missing]
|
||||||
|
print(f"The following environment variables are missing: {printstr}. Please add them to the .env file.")
|
||||||
|
exit(-1)
|
||||||
|
|
||||||
|
|
||||||
|
def runPS(cmd):
|
||||||
|
completed = subprocess.run(["powershell", "-Command", cmd], capture_output=True)
|
||||||
|
return completed
|
@ -1,48 +0,0 @@
|
|||||||
import os
|
|
||||||
import subprocess
|
|
||||||
import tempfile
|
|
||||||
import logging
|
|
||||||
|
|
||||||
from os import path
|
|
||||||
from sys import platform, stderr
|
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
|
||||||
|
|
||||||
def envUpdate():
|
|
||||||
if path.exists(".env.template"):
|
|
||||||
if platform == "win32" or platform == "cygwin":
|
|
||||||
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]",
|
|
||||||
shell=True,
|
|
||||||
)
|
|
||||||
return
|
|
||||||
tempEnv = tempfile.TemporaryFile()
|
|
||||||
tempEnv.write(envTemplate)
|
|
||||||
tempEnv.seek(0)
|
|
||||||
envVars = tempEnv.readlines()
|
|
||||||
|
|
||||||
missing = []
|
|
||||||
isMissingEnvs = False
|
|
||||||
for env in envVars:
|
|
||||||
try:
|
|
||||||
env = env.decode("utf-8").strip()
|
|
||||||
except AttributeError:
|
|
||||||
env = env.strip()
|
|
||||||
|
|
||||||
if env not in os.environ:
|
|
||||||
isMissingEnvs = True
|
|
||||||
missing.append(env)
|
|
||||||
|
|
||||||
if isMissingEnvs:
|
|
||||||
log.error(
|
|
||||||
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
|
|
@ -0,0 +1,9 @@
|
|||||||
|
$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 ".\video_creation\data\envvars.txt"
|
||||||
|
Remove-Item ".\envVarsbefSpl.txt"
|
||||||
|
Remove-Item ".\envVarsN.txt"
|
||||||
|
|
||||||
|
Write-Host $nowSplit
|
@ -1,8 +1,8 @@
|
|||||||
$envFile = Get-Content ".\.env.template"
|
$envFile = Get-Content ".\.env"
|
||||||
|
|
||||||
$envFile -split "=" | Where-Object {$_ -notmatch '\"'} | Set-Content ".\envVarsbefSpl.txt"
|
$envFile -split "=" | Where-Object {$_ -notmatch '\"'} | Set-Content ".\envVarsbefSpl.txt"
|
||||||
Get-Content ".\envVarsbefSpl.txt" | Where-Object {$_ -notmatch '\#'} | Set-Content ".\envVarsN.txt"
|
Get-Content ".\envVarsbefSpl.txt" | Where-Object {$_ -notmatch '\#'} | Set-Content ".\envVarsN.txt"
|
||||||
Get-Content ".\envVarsN.txt" | Where-Object {$_ -ne ''} | Set-Content ".\envVars.txt"
|
Get-Content ".\envVarsN.txt" | Where-Object {$_ -ne ''} | Set-Content ".\video_creation\data\envvars.txt"
|
||||||
Remove-Item ".\envVarsbefSpl.txt"
|
Remove-Item ".\envVarsbefSpl.txt"
|
||||||
Remove-Item ".\envVarsN.txt"
|
Remove-Item ".\envVarsN.txt"
|
||||||
|
|
@ -1,2 +0,0 @@
|
|||||||
videos.json
|
|
||||||
#todo add videos on github
|
|
Loading…
Reference in new issue