Skip to content
Snippets Groups Projects
Commit 372cb56a authored by ave's avatar ave
Browse files

updat3r: regex the version string instead

parent f09f8973
No related branches found
No related tags found
No related merge requests found
...@@ -4,10 +4,20 @@ All notable changes to this project will be documented in this file. ...@@ -4,10 +4,20 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
## [Unreleased]
### Added
### Changed
### Fixed
- updat3r: Improved version comparison logic, making the "you are up to date :)" logic work
## [1.3.0] - 2023-11-26 ## [1.3.0] - 2023-11-26
### Summary ### Summary
- Wifi connection UI - Wifi connection UI
- Media framework - Media framework
- SD card works reliably
- Performance improvements - Performance improvements
- Backend improvements - Backend improvements
- Wider micropython API - Wider micropython API
......
...@@ -7,6 +7,7 @@ import sys_kernel ...@@ -7,6 +7,7 @@ import sys_kernel
import urequests import urequests
import math import math
import sys import sys
import re
from st3m.ui.view import ViewManager from st3m.ui.view import ViewManager
import st3m.wifi import st3m.wifi
...@@ -62,11 +63,15 @@ class UpdaterApp(Application): ...@@ -62,11 +63,15 @@ class UpdaterApp(Application):
ctx.move_to(0, 55) ctx.move_to(0, 55)
ctx.text("enter Wi-Fi settings") ctx.text("enter Wi-Fi settings")
def version_to_number(self, version: str): def version_to_number(self, version_raw: str):
if "dev" in version: if "dev" in version_raw:
return 0 return 0
major, minor, patch = version.split(".") version_re = re.search("[0-9]+.[0-9]+.[0-9]+", version_raw)
if not version_re:
return 0
major, minor, patch = version_re.group(0).split(".")
try: try:
version_number = (int(major) * 1000000) + (int(major) * 1000) + int(patch) version_number = (int(major) * 1000000) + (int(major) * 1000) + int(patch)
...@@ -151,9 +156,7 @@ class UpdaterApp(Application): ...@@ -151,9 +156,7 @@ class UpdaterApp(Application):
self._state_text = "latest dev build\n\npress app shoulder button\nto start downloading\n\n(tilt shoulder left to\nswitch to latest version)" self._state_text = "latest dev build\n\npress app shoulder button\nto start downloading\n\n(tilt shoulder left to\nswitch to latest version)"
elif self.fetched_version: elif self.fetched_version:
self.selected_version = self.fetched_version[0] self.selected_version = self.fetched_version[0]
latest_version_number = self.version_to_number( latest_version_number = self.version_to_number(self.selected_version["tag"])
self.selected_version["tag"].replace("v", "")
)
self._state_text = f"latest version: \n{self.selected_version['name']}" self._state_text = f"latest version: \n{self.selected_version['name']}"
if latest_version_number > self._firmware_version_number: if latest_version_number > self._firmware_version_number:
self._state_text += ( self._state_text += (
...@@ -168,7 +171,6 @@ class UpdaterApp(Application): ...@@ -168,7 +171,6 @@ class UpdaterApp(Application):
super().think(ins, delta_ms) super().think(ins, delta_ms)
# TODO: verify hash # TODO: verify hash
# TODO: download percentage
if self.input.buttons.app.right.pressed: if self.input.buttons.app.right.pressed:
self.use_dev_version = True self.use_dev_version = True
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment