zephyr/scripts/west_commands/fetchers/http.py
Carles Cufi 336aa9dc88 modules: Basic binary blob infrastructure
This patch introduces the basic infrastructure to list and fetch binary
blobs. This includes:

- The new 'blobs' extension command
- An implementation of the `west blobs list` command
  with custom formatting
- A very simple mechanism for loading fetchers
- A basic implementation of an HTTP fetcher

In order to ensure consistency among the west extension commands in the
main zephyr tree, we reuse a similar class factory pattern that is present
for ZephyrBinaryRunner instances in the ZephyrBlobFetcher case. This
could be achieved with a simpler mechanism, but opted for consistency
before simplicity.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2022-08-16 05:59:02 -07:00

21 lines
450 B
Python

# Copyright (c) 2022 Nordic Semiconductor ASA
#
# SPDX-License-Identifier: Apache-2.0
import requests
from west import log
from fetchers.core import ZephyrBlobFetcher
class HTTPFetcher(ZephyrBlobFetcher):
@classmethod
def schemes(cls):
return ['http', 'https']
def fetch(self, url, path):
log.dbg(f'HTTPFetcher fetching {url} to {path}')
resp = requests.get(url)
open(path, "wb").write(resp.content)