feat(firmware): offer the newest release of the line and install it with owut (NetOrk/netork#2615) #49
@@ -73,8 +73,9 @@ _MAX_BYTES: Final = 2 * 1024 * 1024
|
||||
#: Per server URL: (monotonic time fetched, overview or None for a failed fetch).
|
||||
_OVERVIEWS: dict[str, tuple[float, dict[str, Any] | None]] = {}
|
||||
|
||||
_LOG: Final = "/tmp/owut-upgrade.log"
|
||||
_PID: Final = "/tmp/owut-upgrade.pid"
|
||||
# On the device, not here: its /tmp is RAM, where owut keeps its image too.
|
||||
_LOG: Final = "/tmp/owut-upgrade.log" # nosec B108
|
||||
_PID: Final = "/tmp/owut-upgrade.pid" # nosec B108
|
||||
_STATUS: Final = "__OWUT_RC="
|
||||
_STATUS_RE: Final = re.compile(rf"^{_STATUS}(\d+)\s*$", re.MULTILINE)
|
||||
#: What owut prints right before it hands the image to sysupgrade.
|
||||
@@ -138,7 +139,8 @@ def _builds(branch: dict[str, Any], target: str) -> bool:
|
||||
def _fetch_json(url: str) -> dict[str, Any]:
|
||||
"""GET *url* as JSON; raises on any failure."""
|
||||
request = urllib.request.Request(url, headers={"User-Agent": "napalm-openwrt"})
|
||||
with urllib.request.urlopen(request, timeout=_FETCH_TIMEOUT) as response: # noqa: S310 - http(s) only, see _server_url
|
||||
# http(s) only: _server_url gives nothing else.
|
||||
with urllib.request.urlopen(request, timeout=_FETCH_TIMEOUT) as response: # noqa: S310 # nosec B310
|
||||
data = json.loads(response.read(_MAX_BYTES))
|
||||
if not isinstance(data, dict):
|
||||
raise ValueError("overview.json is not an object")
|
||||
|
||||
Reference in new issue
Block a user