Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/Arksine/moonraker
Browse files Browse the repository at this point in the history
  • Loading branch information
actions-user committed Feb 2, 2025
2 parents 889c8ed + fad1a15 commit 94957f4
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 15 deletions.
14 changes: 14 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,20 @@ The format is based on [Keep a Changelog].
- **wled**: Use the `async_serial` utility for serial comms.
- **paneldue**: Use the `async_serial` utility for serial comms.
- **scripts**: Update `fetch-apikey.sh` to query the SQL database
- **update_manager**: The following endpoints have been deprecated
as of API version 1.5.0:
- `/machine/update/full`
- `/machine/update/client`
- `/machine/update/moonraker`
- `/machine/update/klipper`
- `/machine/update/system`

The new `/machine/update/upgrade` endpoint replaces the functionality
of all of the above. The deprecated endpoints will NOT be removed,
so existing software does not need to be changed. New software
should use the new endpoint, however it may be desirable to also
support the deprecated `full` and `client` endpoints for compatibility
with older API versions.

### Fixed
- **python_deploy**: fix "dev" channel updates for GitHub sources.
Expand Down
33 changes: 19 additions & 14 deletions moonraker/components/update_manager/update_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,9 @@ def __init__(self, config: ConfigHelper) -> None:
self.server.register_endpoint(
"/machine/update/full", RequestType.POST, self._handle_full_update_request
)
self.server.register_endpoint(
"/machine/update/upgrade", RequestType.POST, self._handle_update_request
)
self.server.register_endpoint(
"/machine/update/status", RequestType.GET, self._handle_status_request
)
Expand Down Expand Up @@ -277,16 +280,17 @@ async def _handle_auto_refresh(self, eventtime: float) -> float:
self.cmd_helper.notify_update_refreshed()
return eventtime + UPDATE_REFRESH_INTERVAL

async def _handle_update_request(self,
web_request: WebRequest
) -> str:
async def _handle_update_request(self, web_request: WebRequest) -> str:
if self.kconn.is_printing():
raise self.server.error("Update Refused: Klippy is printing")
raise self.server.error("Update Refused: Klippy is printing", 503)
app: str = web_request.get_endpoint().split("/")[-1]
if app == "client":
app = web_request.get_str('name')
if app in ("upgrade", "client"):
app_name = web_request.get_str("name", None)
if app_name is None:
return await self._handle_full_update_request(web_request)
app = app_name
if self.cmd_helper.is_app_updating(app):
return f"Object {app} is currently being updated"
raise self.server.error(f"Item {app} is currently updating", 503)
updater = self.updaters.get(app, None)
if updater is None:
raise self.server.error(f"Updater {app} not available", 404)
Expand All @@ -302,12 +306,10 @@ async def _handle_update_request(self,
self.cmd_helper.clear_update_info()
return "ok"

async def _handle_full_update_request(self,
web_request: WebRequest
) -> str:
async def _handle_full_update_request(self, web_request: WebRequest) -> str:
async with self.cmd_request_lock:
app_name = ""
self.cmd_helper.set_update_info('full', id(web_request))
self.cmd_helper.set_update_info("full", id(web_request), True)
self.cmd_helper.notify_update_response(
"Preparing full software update...")
try:
Expand Down Expand Up @@ -360,6 +362,7 @@ async def _handle_full_update_request(self,
self.cmd_helper.set_full_complete(True)
self.cmd_helper.notify_update_response(
f"Error updating {app_name}: {e}", is_complete=True)
raise
finally:
self.cmd_helper.clear_update_info()
return "ok"
Expand Down Expand Up @@ -552,10 +555,12 @@ def get_refresh_interval(self) -> float:
def get_umdb(self) -> NamespaceWrapper:
return self.umdb

def set_update_info(self, app: str, uid: int) -> None:
def set_update_info(
self, app: str, uid: int, full: bool = False
) -> None:
self.cur_update_app = app
self.cur_update_id = uid
self.full_update = app == "full"
self.full_update = full
self.full_complete = not self.full_update
self.pending_service_restarts.clear()

Expand All @@ -582,7 +587,7 @@ def needs_service_restart(self, svc_name: str) -> bool:
return svc_name in self.pending_service_restarts

def is_app_updating(self, app_name: str) -> bool:
return self.cur_update_app == app_name
return self.cur_update_app == app_name or self.full_update

def is_update_busy(self) -> bool:
return self.cur_update_app is not None
Expand Down
2 changes: 1 addition & 1 deletion moonraker/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
FlexCallback = Callable[..., Optional[Coroutine]]
_T = TypeVar("_T", Sentinel, Any)

API_VERSION = (1, 4, 0)
API_VERSION = (1, 5, 0)
SERVER_COMPONENTS = ['application', 'websockets', 'klippy_connection']
CORE_COMPONENTS = [
'dbus_manager', 'database', 'file_manager', 'authorization',
Expand Down

0 comments on commit 94957f4

Please sign in to comment.