Abrir arquivos em texto Único
Abrir arquivos em texto Único
According to a document from 2025-12-30, o seu erro “O termo ‘C:\Program’ não é reconhecido…” vem de um detalhe bem específico no praxium.ps1: ele faz split por espaço no parâmetro -Python. Quando você passa C:\Program Files\Python310\python.exe, ele vira C:\Program + Files\... e quebra. Isso está explícito no trecho -split '\s+'.
Correção imediata (sem editar arquivo)
Em vez de passar o caminho completo, passe só python (sem espaço):
Set-Location C:\PRAXIUM\ACTIVE
.\praxium.ps1 start -Python "python"
.\praxium.ps1 status -Python "python"
Se o python do PATH estiver ok, isso já elimina o “C:\Program”.
Correção definitiva (editar o
praxium.ps1)
Você precisa mudar o parser do parâmetro -Python para não quebrar paths com espaço.
Abaixo está o arquivo inteiro do praxium.ps1 com a correção aplicada (única mudança: bloco “Parse do Python”). O resto eu mantive igual ao seu:
param(
[ValidateSet("start","stop","status","restart","tail")]
[string]$Action = "start",
# Aceita "python" ou "py -3" OU caminho completo com espaços
[string]$Python = "python",
[string[]]$ExtraArgs = @()
)
Set-StrictMode -Off
$ErrorActionPreference = "Stop"
function Write-Info($m){ Write-Host "[PRAXIUM] $m" -ForegroundColor Cyan }
function Write-Ok($m){ Write-Host "[PRAXIUM] $m" -ForegroundColor Green }
function Write-Warn($m){ Write-Host "[PRAXIUM] $m" -ForegroundColor Yellow }
function Write-Err($m){ Write-Host "[PRAXIUM] $m" -ForegroundColor Red }
# Root canônico do projeto
$ROOT = $PSScriptRoot
if (-not $ROOT) {
$inv = $MyInvocation.MyCommand.Path
if ($inv) { $ROOT = Split-Path -Parent $inv } else { $ROOT = (Get-Location).Path }
}
Set-Location $ROOT
# ------------------------------
# Parse do Python (robusto)
# - Se $Python for um caminho existente (mesmo com espaços), usa direto.
# - Caso contrário, permite "py -3" (split) e "python" simples.
# ------------------------------
$pyExe = $null
$pyPrefix = @()
if (Test-Path -LiteralPath $Python) {
$pyExe = $Python
$pyPrefix = @()
} else {
$pyParts = $Python -split '\s+'
$pyExe = $pyParts[0]
if ($pyParts.Count -gt 1) { $pyPrefix = $pyParts[1..($pyParts.Count-1)] }
}
# Paths
$RUNDIR = Join-Path $ROOT ".praxium\run"
$LOGDIR = Join-Path $ROOT ".praxium\logs"
$PIDFILE = Join-Path $RUNDIR "kernel.pid"
$LOCK = Join-Path $RUNDIR "kernel.lock"
$STDOUT = Join-Path $LOGDIR "kernel_stdout.log"
$STDERR = Join-Path $LOGDIR "kernel_stderr.log"
New-Item -ItemType Directory -Force $RUNDIR | Out-Null
New-Item -ItemType Directory -Force $LOGDIR | Out-Null
function Resolve-RunPy {
$candidates = @(
(Join-Path $ROOT "run.py"),
(Join-Path $ROOT "core\run.py"),
(Join-Path $ROOT "CORE\run.py"),
(Join-Path $ROOT "kernel\run.py"),
(Join-Path $ROOT "src\run.py")
) | Where-Object { Test-Path $_ }
if (-not $candidates -or @($candidates).Length -eq 0) {
$candidates = Get-ChildItem -Path $ROOT -Recurse -File -Filter "run.py" -ErrorAction SilentlyContinue |
Select-Object -ExpandProperty FullName
}
$arr = @($candidates)
if ($arr.Length -eq 0) { throw "run_py_not_found_anywhere" }
if ($arr.Length -gt 1) {
Write-Warn "Múltiplos run.py encontrados. Usando o primeiro:"
$arr | ForEach-Object { Write-Warn " - $_" }
}
return $arr[0]
}
function Get-RunningPid {
if (-not (Test-Path $PIDFILE)) { return $null }
$pidRaw = (Get-Content $PIDFILE -ErrorAction SilentlyContinue | Select-Object -First 1)
if (-not $pidRaw) { return $null }
$pidInt = ($pidRaw.ToString().Trim()) -as [int]
if (-not $pidInt) { return $null }
$p = Get-Process -Id $pidInt -ErrorAction SilentlyContinue
if ($p) { return $pidInt }
return $null
}
function Acquire-Lock {
if (Test-Path $LOCK) {
$running = Get-RunningPid
if (-not $running) {
Remove-Item $LOCK -Force -ErrorAction SilentlyContinue
Remove-Item $PIDFILE -Force -ErrorAction SilentlyContinue
}
}
if (Test-Path $LOCK) { throw "instance_lock_present:$LOCK" }
Set-Content -Path $LOCK -Value ("pid={0}`ntime={1}" -f $PID, (Get-Date).ToString("s")) -Encoding ASCII
}
function Release-Lock { Remove-Item $LOCK -Force -ErrorAction SilentlyContinue }
function Preflight {
Write-Info "Preflight..."
$RUNPY = Resolve-RunPy
& $pyExe @($pyPrefix + @("-m","py_compile",$RUNPY)) | Out-Null
Write-Ok "Entrypoint OK: $RUNPY"
return $RUNPY
}
function Start-Kernel {
$running = Get-RunningPid
if ($running) { Write-Ok "Kernel já está rodando (pid=$running)"; return }
Acquire-Lock
try {
$RUNPY = Preflight
$env:PRAXIUM_ROOT = $ROOT
$env:PYTHONUTF8 = "1"
$args = @() + $pyPrefix + @($RUNPY) + $ExtraArgs
Write-Info "Iniciando kernel..."
Write-Info "CMD: $pyExe $($args -join ' ')"
$p = Start-Process -FilePath $pyExe -ArgumentList $args -WorkingDirectory $ROOT `
-RedirectStandardOutput $STDOUT -RedirectStandardError $STDERR -WindowStyle Hidden -PassThru
Start-Sleep -Milliseconds 400
Set-Content -Path $PIDFILE -Value $p.Id -Encoding ASCII
Write-Ok "Kernel iniciado (pid=$($p.Id))"
}
finally { Release-Lock }
}
function Stop-Kernel {
$running = Get-RunningPid
if (-not $running) {
Write-Ok "Kernel não está rodando."
Remove-Item $PIDFILE -Force -ErrorAction SilentlyContinue
return
}
Write-Info "Parando kernel (pid=$running)..."
Stop-Process -Id $running -Force -ErrorAction SilentlyContinue
Remove-Item $PIDFILE -Force -ErrorAction SilentlyContinue
Remove-Item $LOCK -Force -ErrorAction SilentlyContinue
Write-Ok "Kernel parado."
}
function Status-Kernel {
$running = Get-RunningPid
if ($running) { Write-Ok "RUNNING pid=$running" } else { Write-Ok "STOPPED" }
if (Test-Path $STDERR) {
$tail = Get-Content $STDERR -Tail 20 -ErrorAction SilentlyContinue
if ($tail) { Write-Host "`n--- stderr (tail) ---" -ForegroundColor DarkYellow; $tail }
}
}
function Tail-Logs {
if (-not (Test-Path $STDOUT)) { New-Item -ItemType File -Force $STDOUT | Out-Null }
Write-Info "Tailing stdout: $STDOUT"
Get-Content $STDOUT -Wait
}
try {
switch ($Action) {
"start" { Start-Kernel }
"stop" { Stop-Kernel }
"status" { Status-Kernel }
"restart" { Stop-Kernel; Start-Sleep -Milliseconds 200; Start-Kernel }
"tail" { Tail-Logs }
}
} catch {
Write-Err $_.Exception.Message
exit 1
}
Esse bug é exatamente o motivo do “C:\Program”: o seu script original separa o $Python em partes por espaço.
Sequência de teste no PowerShell (depois de salvar o arquivo)
Set-Location C:\PRAXIUM\ACTIVE
$py = (Get-Command python).Source
Unblock-File .\praxium.ps1 -ErrorAction SilentlyContinue
& $py -m py_compile .\run.py
& $py -m py_compile .\prax_cli.py
.\praxium.ps1 stop -Python $py
.\praxium.ps1 start -Python $py
.\praxium.ps1 status -Python $py
& $py .\prax_cli.py ping --workspace WS_100_DEV --intent kernel_alive --timeout 30
# se ainda der ruim, veja o stderr:
Get-Content .\.praxium\logs\kernel_stderr.log -Tail 120
“Bloco de notas”: abrir
todos os arquivos
em
um texto único
Você consegue gerar um “master.txt” do projeto e abrir no Notepad.
⚠️ Aviso prático: se ficar enorme, o Notepad pode travar. Então eu filtro extensões e excluo pastas de saída/cache.
$root = "C:\PRAXIUM\ACTIVE"
$out = Join-Path $root "PRAXIUM_MASTER_EDIT.txt"
$includeExt = @(".py",".ps1",".json",".md",".txt",".yml",".yaml")
$skipParts = @("\.praxium\","\OUTPUT\","\DATAHUB\","\BACKUPS\","\ASSETS\","\__pycache__\")
$files = Get-ChildItem $root -Recurse -File | Where-Object {
$includeExt -contains $_.Extension.ToLower() -and
($skipParts | Where-Object { $_.FullName -like "*$_*" }).Count -eq 0
} | Sort-Object FullName
$sb = New-Object System.Text.StringBuilder
foreach($f in $files){
$rel = $f.FullName.Substring($root.Length).TrimStart('\')
[void]$sb.AppendLine("")
[void]$sb.AppendLine("==========================================================================================")
[void]$sb.AppendLine("FILE: $rel")
[void]$sb.AppendLine("FULL: $($f.FullName)")
[void]$sb.AppendLine("SIZE: $($f.Length)")
[void]$sb.AppendLine("LASTWRITE: $($f.LastWriteTime.ToString('s'))")
[void]$sb.AppendLine("--- BEGIN ---")
try {
$txt = Get-Content -LiteralPath $f.FullName -Raw -Encoding UTF8
} catch {
$txt = Get-Content -LiteralPath $f.FullName -Raw
}
[void]$sb.AppendLine($txt)
[void]$sb.AppendLine("--- END ---")
}
$sb.ToString() | Set-Content -LiteralPath $out -Encoding UTF8
notepad $out
Se você quiser “conferir e editar” sem sofrer com arquivo gigante: abre só os 3 críticos em abas do Notepad:
Set-Location C:\PRAXIUM\ACTIVE
notepad .\run.py .\prax_cli.py .\praxium.ps1
Se você executar o teste acima e o ping ainda não voltar, o próximo passo (sem enrolação) é: colar aqui o kernel_stderr.log (tail 120) e eu te devolvo o diagnóstico + patch do arquivo exato.
Comentários
Postar um comentário