Skip to content

Commit

Permalink
use test-path to prevent unnecessary red output
Browse files Browse the repository at this point in the history
  • Loading branch information
th3w1zard1 committed Feb 18, 2024
1 parent 1554cc4 commit e85fa8e
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions install_python_venv.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ function Set-EnvironmentVariablesFromEnvFile {
}

function Get-Linux-Distro-Name {
$osInfo = Get-Content "/etc/os-release" -Raw
if (Test-Path "/etc/os-release") {
if (Test-Path "/etc/os-release" -ErrorAction SilentlyContinue) {
$osInfo = Get-Content "/etc/os-release" -Raw
if ($osInfo -match '\nID="?([^"\n]*)"?') {
$distroName = $Matches[1].Trim('"')
if ($distroName -eq "ol") {
Expand All @@ -116,7 +116,7 @@ function Get-Linux-Distro-Name {

function Get-Linux-Distro-Version {
$osInfo = Get-Content "/etc/os-release" -Raw
if (Test-Path "/etc/os-release") {
if (Test-Path "/etc/os-release" -ErrorAction SilentlyContinue) {
if ($osInfo -match '\nVERSION_ID="?([^"\n]*)"?') {
$distroVersion = $Matches[1].Trim('"')
return $distroVersion
Expand Down Expand Up @@ -283,11 +283,14 @@ function Get-Python-Version {
Param (
[string]$pythonPath
)
$global:pythonVersionOutput = & $pythonPath --version 2>&1
$global:pythonVersionString = $global:pythonVersionOutput -replace '^Python\s+'
$numericVersionString = $global:pythonVersionString -replace '(\d+\.\d+\.\d+).*', '$1'
$global:pythonVersion = [Version]$numericVersionString
return $global:pythonVersion
if (Test-Path $pythonPath -ErrorAction SilentlyContinue) {
$global:pythonVersionOutput = & $pythonPath --version 2>&1
$global:pythonVersionString = $global:pythonVersionOutput -replace '^Python\s+'
$numericVersionString = $global:pythonVersionString -replace '(\d+\.\d+\.\d+).*', '$1'
$global:pythonVersion = [Version]$numericVersionString
return $global:pythonVersion
}
return [Version]"0.0.0"
}

$minVersion = [Version]"3.8.0"
Expand Down

0 comments on commit e85fa8e

Please sign in to comment.