Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions src/manage/pathutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,17 @@ def _eq(x, y):
return x == y or x.casefold() == y.casefold()


def _splitroot(path):
try:
return os.path.splitroot(path)
except AttributeError:
import ntpath
drive, rest = ntpath.splitdrive(path)
if rest.startswith('\\') or rest.startswith('/'):
return drive, rest[0], rest[1:]
return drive, '', rest


class PurePath:
def __init__(self, *parts):
total = ""
Expand All @@ -28,7 +39,7 @@ def __init__(self, *parts):
total += "\\" + p
else:
total += p
drive, root, tail = os.path.splitroot(total)
drive, root, tail = _splitroot(total)
parent, _, name = tail.rpartition("\\")
self._parent = drive + root + parent
self.name = name
Expand Down Expand Up @@ -72,7 +83,7 @@ def parent(self):

@property
def parts(self):
drive, root, tail = os.path.splitroot(self._p)
drive, root, tail = _splitroot(self._p)
bits = []
if drive or root:
bits.append(drive + root)
Expand Down Expand Up @@ -120,7 +131,7 @@ def relative_to(self, base):
return type(self)("\\".join(parts[len(base):]))

def as_uri(self):
drive, root, tail = os.path.splitroot(self._p)
drive, root, tail = _splitroot(self._p)
if drive[1:2] == ":" and root:
return "file:///" + self._p.replace("\\", "/")
if drive[:2] == "\\\\":
Expand Down
10 changes: 9 additions & 1 deletion src/manage/urlutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,15 @@ def _powershell_urlretrieve(request):
$url = $env:PYMANAGER_URL
$outfile = $env:PYMANAGER_OUTFILE
$method = $env:PYMANAGER_METHOD
$headers = ConvertFrom-Json $env:PYMANAGER_HEADERS
$headersObj = ConvertFrom-Json $env:PYMANAGER_HEADERS
$headers = @{}
if ($headersObj -ne $null) {
$headersObj.PSObject.Properties | ForEach-Object {
$name = $_.Name
$value = $_.Value
$headers[$name] = if ($value -eq $null) { "" } else { $value.ToString() }
}
}
$r = Invoke-WebRequest -Uri $url -UseBasicParsing `
-Headers $headers `
-UseDefaultCredentials `
Expand Down