[virt-tools-list] [virt-manager PATCH 10/12] unattended: Add method to download drivers
Cole Robinson
crobinso at redhat.com
Fri Jun 7 00:32:10 UTC 2019
On 6/6/19 10:11 AM, Fabiano Fidêncio wrote:
> This will be used by unattended installations. The drivers are
> downloaded in the very same directory where the unattended files are
> generated.
>
> Signed-off-by: Fabiano Fidêncio <fidencio at redhat.com>
> ---
> virtinst/unattended.py | 16 ++++++++++++++++
> 1 file changed, 16 insertions(+)
>
> diff --git a/virtinst/unattended.py b/virtinst/unattended.py
> index 7a62dc9c..573289c2 100644
> --- a/virtinst/unattended.py
> +++ b/virtinst/unattended.py
> @@ -8,6 +8,7 @@
>
> import logging
> import os
> +import requests
>
> import gi
> gi.require_version('Libosinfo', '1.0')
> @@ -270,3 +271,18 @@ def generate_install_script(script):
> cmdline = script.generate_cmdline()
>
> return path, cmdline
> +
> +
> +def download_drivers(locations):
> + drivers = []
> +
> + scratch = util.make_unattended_cache_dir()
> + for location in locations:
> + filename = location.rsplit('/', 1)[1]
> + path = os.path.join(scratch, filename)
> + logging.debug("Downloading %s", path)
> + r = requests.get(location)
> + open(path, 'wb').write(r.content)
> + drivers.append(path)
> +
> + return drivers
>
Since this is using requests, I'd rather find a way to reuse the
urlfetcher.py support, which can receive a passed in 'meter' and do cli
download progress reporting, and already handles saving to a tempfile
- Cole
More information about the virt-tools-list
mailing list