mirror of
https://github.com/virt-manager/virt-manager.git
synced 2026-08-07 11:45:09 -05:00
urlfetcher: Deal with 'file://' in _LocalURLFetcher()
osinfo-db may contain files pointing to local paths, which will have the format 'file:///usr/share/...'. With the current code, virt-install would just bail as it doesn't understand the 'file://' schema. Let's start using urllib (which is already imported in the very same file) and parse the URL so both 'file:///usr/share/...' and '/usr/share/...' would work. Reviewed-by: Cole Robinson <crobinso@redhat.com> Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com>
This commit is contained in:
committed by
Cole Robinson
parent
96af1de49f
commit
9465da4174
@@ -365,11 +365,13 @@ class _LocalURLFetcher(_URLFetcher):
|
||||
For grabbing files from a local directory
|
||||
"""
|
||||
def _hasFile(self, url):
|
||||
return os.path.exists(url)
|
||||
parsed = urllib.parse.urlparse(url)
|
||||
return os.path.exists(parsed.path)
|
||||
|
||||
def _grabber(self, url):
|
||||
urlobj = open(url, "rb")
|
||||
size = os.path.getsize(url)
|
||||
parsed = urllib.parse.urlparse(url)
|
||||
urlobj = open(parsed.path, "rb")
|
||||
size = os.path.getsize(parsed.path)
|
||||
return urlobj, size
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user