- ClientApp has been overhauled majorly, now takes a ClientSettings instead of a ClientOptions
- ClientApp
load/unloadremoved in favor ofadd/remove(still sync).
- Decorators for functions are now optional, we can extract the event name from the function name in the format
on_{event_name}. - Argument for functions are now optional, we check the type of the argument to also derrive the event, and if nothing is specified no args will be used to call it.
For example:
from simplyprint_ws_client.client.protocol import Demands
@Demands.FileEvent.on
async def on_file(self, event: Demands.FileEvent) -> None:
"""Download a file from Simplyprint.io to the printer."""
await self._download_file_from_sp_and_upload_to_duet(event=event)Becomes, the function name can here be anything as we can infer the event type from FileDemandData, the class has the same fields as the old message:
from simplyprint_ws_client.core.ws_protocol.messages import *
async def on_file(self, event: FileDemandData) -> None:
"""Download a file from Simplyprint.io to the printer."""
await self._download_file_from_sp_and_upload_to_duet(event=event)
# Example with no reference to the class
async def on_start_print(self) -> None:
print("Start pending print!")- Client lifetime methods
init,tickandstophave been changed toinit,tick(timedelta),haltandteardown.initis now called
FileProgressState->FileProgressStateEnum/ This is a breaking change as FileProgressState is now the class, and the enum has another name
Now we support importing * with no namespace polution (__all__ is defined)
from simplyprint_ws_client.client.state.printer import FileProgressState, PrinterFilamentSensorEnum, PrinterStatus->from simplyprint_ws_client.core.state import *
from simplyprint_ws_client.client.config -> from simplyprint_ws_client.core.config
from simplyprint_ws_client.helpers.intervals -> from simplyprint_ws_client.core.state
Helpers moved into shared module
from simplyprint_ws_client.helpers.file_download -> from simplyprint_ws_client.shared.files.file_download
from simplyprint_ws_client.helpers.physical_machine -> from simplyprint_ws_client.shared.hardware.physical_machine
- ClientApp, ClientSettings now in
core. - ClientCli in
shared.cli.