yet more scripts

This commit is contained in:
Ondrej Samohel 2021-09-02 23:31:34 +02:00
parent e7e9f461ee
commit 757af0d36e
No known key found for this signature in database
GPG key ID: 02376E18990A97C6
5 changed files with 54 additions and 64 deletions

View file

@ -11,6 +11,13 @@ PS> .\run_mongo.ps1
#>
$current_dir = Get-Location
$script_dir = Split-Path -Path $MyInvocation.MyCommand.Definition -Parent
$openpype_root = (Get-Item $script_dir).parent.FullName
# Install PSWriteColor to support colorized output to terminal
$env:PSModulePath = $env:PSModulePath + ";$($openpype_root)\vendor\powershell"
$art = @"
. . .. . ..
@ -43,8 +50,7 @@ function Exit-WithCode($exitcode) {
function Find-Mongo ($preferred_version) {
$defaultPath = "C:\Program Files\MongoDB\Server"
Write-Host ">>> " -NoNewLine -ForegroundColor Green
Write-Host "Detecting MongoDB ... " -NoNewline
Write-Color -Text ">>> ", "Detecting MongoDB ... " -Color Geen, Gray -NoNewline
if (-not (Get-Command "mongod" -ErrorAction SilentlyContinue)) {
if(Test-Path "$($defaultPath)\*\bin\mongod.exe" -PathType Leaf) {
# we have mongo server installed on standard Windows location
@ -52,17 +58,14 @@ function Find-Mongo ($preferred_version) {
# $preferred_version.
$mongoVersions = Get-ChildItem -Directory 'C:\Program Files\MongoDB\Server' | Sort-Object -Property {$_.Name -as [int]}
if(Test-Path "$($mongoVersions[-1])\bin\mongod.exe" -PathType Leaf) {
Write-Host "OK" -ForegroundColor Green
Write-Color -Text "OK" -Color Green
$use_version = $mongoVersions[-1]
foreach ($v in $mongoVersions) {
Write-Host " - found [ " -NoNewline
Write-Host $v -NoNewLine -ForegroundColor Cyan
Write-Host " ]" -NoNewLine
Write-Color -Text " - found [ ", $v, " ]" - Color Cyan, White, Cyan -NoNewLine
$version = Split-Path $v -Leaf
if ($preferred_version -eq $version) {
Write-Host " *" -ForegroundColor Green
Write-Color -Text " *" -Color Green
$use_version = $v
} else {
Write-Host ""
@ -104,9 +107,6 @@ function Find-Mongo ($preferred_version) {
#>
}
$script_dir = Split-Path -Path $MyInvocation.MyCommand.Definition -Parent
$openpype_root = (Get-Item $script_dir).parent.FullName
# mongodb port
$port = 2707

View file

@ -35,6 +35,9 @@ $current_dir = Get-Location
$script_dir = Split-Path -Path $MyInvocation.MyCommand.Definition -Parent
$openpype_root = (Get-Item $script_dir).parent.FullName
# Install PSWriteColor to support colorized output to terminal
$env:PSModulePath = $env:PSModulePath + ";$($openpype_root)\vendor\powershell"
$env:_INSIDE_OPENPYPE_TOOL = "1"
# make sure Poetry is in PATH
@ -45,15 +48,13 @@ $env:PATH = "$($env:PATH);$($env:POETRY_HOME)\bin"
Set-Location -Path $openpype_root
Write-Host ">>> " -NoNewline -ForegroundColor Green
Write-Host "Reading Poetry ... " -NoNewline
Write-Color -Text ">>> ", "Reading Poetry ... " -Color Green, Gray -NoNewline
if (-not (Test-Path -PathType Container -Path "$($env:POETRY_HOME)\bin")) {
Write-Host "NOT FOUND" -ForegroundColor Yellow
Write-Host "*** " -NoNewline -ForegroundColor Yellow
Write-Host "We need to install Poetry create virtual env first ..."
& "$openpype_root\tools\create_env.ps1"
Write-Color -Text "NOT FOUND" -Color Yellow
Install-Poetry
Write-Color -Text "INSTALLED" -Color Cyan
} else {
Write-Host "OK" -ForegroundColor Green
Write-Color -Text "OK" -Color Green
}
& "$env:POETRY_HOME\bin\poetry" run python "$($openpype_root)\start.py" projectmanager

View file

@ -15,6 +15,9 @@ $current_dir = Get-Location
$script_dir = Split-Path -Path $MyInvocation.MyCommand.Definition -Parent
$openpype_root = (Get-Item $script_dir).parent.FullName
# Install PSWriteColor to support colorized output to terminal
$env:PSModulePath = $env:PSModulePath + ";$($openpype_root)\vendor\powershell"
$env:_INSIDE_OPENPYPE_TOOL = "1"
# make sure Poetry is in PATH
@ -25,15 +28,13 @@ $env:PATH = "$($env:PATH);$($env:POETRY_HOME)\bin"
Set-Location -Path $openpype_root
Write-Host ">>> " -NoNewline -ForegroundColor Green
Write-Host "Reading Poetry ... " -NoNewline
Write-Color -Text ">>> ", "Reading Poetry ... " -Color Green, Gray -NoNewline
if (-not (Test-Path -PathType Container -Path "$($env:POETRY_HOME)\bin")) {
Write-Host "NOT FOUND" -ForegroundColor Yellow
Write-Host "*** " -NoNewline -ForegroundColor Yellow
Write-Host "We need to install Poetry create virtual env first ..."
& "$openpype_root\tools\create_env.ps1"
Write-Color -Text "NOT FOUND" -Color Yellow
Install-Poetry
Write-Color -Text "INSTALLED" -Color Cyan
} else {
Write-Host "OK" -ForegroundColor Green
Write-Color -Text "OK" -Color Green
}
& "$env:POETRY_HOME\bin\poetry" run python "$($openpype_root)\start.py" settings --dev

View file

@ -11,6 +11,13 @@ PS> .\run_test.ps1
#>
$current_dir = Get-Location
$script_dir = Split-Path -Path $MyInvocation.MyCommand.Definition -Parent
$openpype_root = (Get-Item $script_dir).parent.FullName
# Install PSWriteColor to support colorized output to terminal
$env:PSModulePath = $env:PSModulePath + ";$($openpype_root)\vendor\powershell"
function Exit-WithCode($exitcode) {
# Only exit this host process if it's a child of another PowerShell parent process...
$parentPID = (Get-CimInstance -ClassName Win32_Process -Filter "ProcessId=$PID" | Select-Object -Property ParentProcessId).ParentProcessId
@ -22,10 +29,8 @@ function Exit-WithCode($exitcode) {
function Show-PSWarning() {
if ($PSVersionTable.PSVersion.Major -lt 7) {
Write-Host "!!! " -NoNewline -ForegroundColor Red
Write-Host "You are using old version of PowerShell. $($PSVersionTable.PSVersion.Major).$($PSVersionTable.PSVersion.Minor)"
Write-Host "Please update to at least 7.0 - " -NoNewline -ForegroundColor Gray
Write-Host "https://github.com/PowerShell/PowerShell/releases" -ForegroundColor White
Write-Color -Text "!!! ", "You are using old version of PowerShell - ", "$($PSVersionTable.PSVersion.Major).$($PSVersionTable.PSVersion.Minor)" -Color Red, Yellow, White
Write-Color -Text " Please update to at least 7.0 - ", "https://github.com/PowerShell/PowerShell/releases" -Color Yellow, White
Exit-WithCode 1
}
}
@ -53,10 +58,6 @@ Write-Host $art -ForegroundColor DarkGreen
# Enable if PS 7.x is needed.
# Show-PSWarning
$current_dir = Get-Location
$script_dir = Split-Path -Path $MyInvocation.MyCommand.Definition -Parent
$openpype_root = (Get-Item $script_dir).parent.FullName
$env:_INSIDE_OPENPYPE_TOOL = "1"
if (-not (Test-Path 'env:POETRY_HOME')) {
@ -69,46 +70,32 @@ $version_file = Get-Content -Path "$($openpype_root)\openpype\version.py"
$result = [regex]::Matches($version_file, '__version__ = "(?<version>\d+\.\d+.\d+.*)"')
$openpype_version = $result[0].Groups['version'].Value
if (-not $openpype_version) {
Write-Host "!!! " -ForegroundColor yellow -NoNewline
Write-Host "Cannot determine OpenPype version."
Write-Color -Text "!!! ", "Cannot determine OpenPype version." -Color Yellow, Gray
Exit-WithCode 1
}
Write-Host ">>> " -NoNewline -ForegroundColor green
Write-Host "OpenPype [ " -NoNewline -ForegroundColor white
Write-host $openpype_version -NoNewline -ForegroundColor green
Write-Host " ] ..." -ForegroundColor white
Write-Color -Text ">>> ", "OpenPype [ ", $openpype_version, " ]" -Color Green, White, Cyan, White
Write-Host ">>> " -NoNewline -ForegroundColor Green
Write-Host "Reading Poetry ... " -NoNewline
Write-Color -Text ">>> ", "Reading Poetry ... " -Color Green, Gray -NoNewline
if (-not (Test-Path -PathType Container -Path "$($env:POETRY_HOME)\bin")) {
Write-Host "NOT FOUND" -ForegroundColor Yellow
Write-Host "*** " -NoNewline -ForegroundColor Yellow
Write-Host "We need to install Poetry create virtual env first ..."
Write-Color -Text "NOT FOUND" -Color Yellow
Write-Color -Text "*** ", "We need to install Poetry create virtual env first ..." -Color Yellow, Gray
& "$openpype_root\tools\create_env.ps1"
} else {
Write-Host "OK" -ForegroundColor Green
Write-Color -Text "OK" -Color Green
}
Write-Host ">>> " -NoNewline -ForegroundColor green
Write-Host "Cleaning cache files ... " -NoNewline
Write-Color -Text ">>> ", "Cleaning cache files ... " -Color Green, Gray -NoNewline
Get-ChildItem $openpype_root -Filter "*.pyc" -Force -Recurse | Where-Object { $_.FullName -inotmatch 'build' } | Remove-Item -Force
Get-ChildItem $openpype_root -Filter "*.pyo" -Force -Recurse | Where-Object { $_.FullName -inotmatch 'build' } | Remove-Item -Force
Get-ChildItem $openpype_root -Filter "__pycache__" -Force -Recurse | Where-Object { $_.FullName -inotmatch 'build' } | Remove-Item -Force -Recurse
Write-Host "OK" -ForegroundColor green
Write-Color -Text "OK" -Color green
Write-Host ">>> " -NoNewline -ForegroundColor green
Write-Host "Testing OpenPype ..."
Write-Color -Text ">>> ", "Testing OpenPype ..." -Color Green, White
$original_pythonpath = $env:PYTHONPATH
$env:PYTHONPATH="$($openpype_root);$($env:PYTHONPATH)"
& "$env:POETRY_HOME\bin\poetry" run pytest -x --capture=sys --print -W ignore::DeprecationWarning "$($openpype_root)/tests"
$env:PYTHONPATH = $original_pythonpath
Write-Host ">>> " -NoNewline -ForegroundColor green
Write-Host "restoring current directory"
Write-Color -Text ">>> ", "Restoring current directory" -Color Green, Gray
Set-Location -Path $current_dir

View file

@ -14,6 +14,9 @@ $current_dir = Get-Location
$script_dir = Split-Path -Path $MyInvocation.MyCommand.Definition -Parent
$openpype_root = (Get-Item $script_dir).parent.FullName
# Install PSWriteColor to support colorized output to terminal
$env:PSModulePath = $env:PSModulePath + ";$($openpype_root)\vendor\powershell"
$env:_INSIDE_OPENPYPE_TOOL = "1"
# make sure Poetry is in PATH
@ -24,15 +27,13 @@ $env:PATH = "$($env:PATH);$($env:POETRY_HOME)\bin"
Set-Location -Path $openpype_root
Write-Host ">>> " -NoNewline -ForegroundColor Green
Write-Host "Reading Poetry ... " -NoNewline
Write-Color -Text ">>> ", "Reading Poetry ... " -Color Green, Gray -NoNewline
if (-not (Test-Path -PathType Container -Path "$($env:POETRY_HOME)\bin")) {
Write-Host "NOT FOUND" -ForegroundColor Yellow
Write-Host "*** " -NoNewline -ForegroundColor Yellow
Write-Host "We need to install Poetry create virtual env first ..."
Write-Color -Text "NOT FOUND" -Color Yellow
Write-Color -Text "*** ", "We need to install Poetry create virtual env first ..." -Color Yellow, Gray
& "$openpype_root\tools\create_env.ps1"
} else {
Write-Host "OK" -ForegroundColor Green
Write-Color -Text "OK" -Color Green
}
& "$($env:POETRY_HOME)\bin\poetry" run python "$($openpype_root)\start.py" tray --debug