Skip to content

Commit

Permalink
Move Push-Location into try block, add finally block
Browse files Browse the repository at this point in the history
  • Loading branch information
chidozieononiwu committed Mar 3, 2021
1 parent a14d969 commit 54c1fe1
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions eng/scripts/Language-Settings.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -13,31 +13,31 @@ function Get-AllPackageInfoFromRepo ($serviceDirectory)
{
$searchPath = "sdk/${serviceDirectory}/*/setup.py"
}
Push-Location $RepoRoot
$allSetupProps = $null

$allPkgPropLines = $null
try
{
Push-Location $RepoRoot
pip install packaging==20.4 -q -I
$allSetupProps = python "eng\scripts\get_package_properties.py" -s $searchPath
$allPkgPropLines = python "eng\scripts\get_package_properties.py" -s $searchPath
}
catch
{
# This is soft error and failure is expected for python metapackages
LogError "Failed to get all package properties"
}
Pop-Location
finally
{
Pop-Location
}

foreach ($line in $allSetupProps)
foreach ($line in $allPkgPropLines)
{
$setupInfo = ($line -Split ",").Trim("()")
if ($setupInfo.Count -gt 4)
{
continue
}
$packageName = $setupInfo[0].Trim("' ")
$packageVersion = $setupInfo[1].Trim("' ")
$isNewSdk = $setupInfo[2].Trim()
$setupPyDir = $setupInfo[3].Trim("' ")
$pkgInfo = ($line -Split ",").Trim("()' ")
$packageName = $pkgInfo[0]
$packageVersion = $pkgInfo[1]
$isNewSdk = $pkgInfo[2]
$setupPyDir = $pkgInfo[3]
$pkgDirectoryPath = Resolve-Path (Join-Path -Path $RepoRoot $setupPyDir)
$serviceDirectoryName = Split-Path (Split-Path -Path $pkgDirectoryPath -Parent) -Leaf
if ($packageName -match "mgmt")
Expand Down

0 comments on commit 54c1fe1

Please sign in to comment.