@@ -45,7 +45,7 @@ def __init__(self, dev_id: str):
4545 self .dev_id = dev_id
4646
4747 async def get_device (self ) -> Device | None :
48- return
48+ return None
4949
5050 async def update_force_update (self , force_update : bool ) -> None :
5151 return
@@ -86,7 +86,8 @@ async def subscribe_log(self, callback: Callable):
8686 subscribers = self .log_subscribers
8787 subscribers .append (callback )
8888 self .log_subscribers = subscribers
89- await callback (device .last_log )
89+ if device is not None :
90+ await callback (device .last_log )
9091 try :
9192 yield
9293 except asyncio .CancelledError :
@@ -126,7 +127,7 @@ async def publish_log(self, log_data: str | None):
126127 await cb (log_data )
127128
128129 @abstractmethod
129- async def get_update (self ) -> tuple [HandlingType , Software ]: ...
130+ async def get_update (self ) -> tuple [HandlingType , Software | None ]: ...
130131
131132 @abstractmethod
132133 async def update_log (self , log_data : str ) -> None : ...
@@ -137,11 +138,16 @@ def __init__(self, dev_id: str):
137138 super ().__init__ (dev_id )
138139 self .poll_time = config .poll_time_updating
139140
140- async def _get_software (self ) -> Software :
141- return await Software .latest (await self .get_device ())
141+ async def _get_software (self ) -> Software | None :
142+ device = await self .get_device ()
143+ if device is None :
144+ return None
145+ return await Software .latest (device )
142146
143- async def get_update (self ) -> tuple [HandlingType , Software ]:
147+ async def get_update (self ) -> tuple [HandlingType , Software | None ]:
144148 software = await self ._get_software ()
149+ if software is None :
150+ return HandlingType .SKIP , None
145151 return HandlingType .FORCED , software
146152
147153 async def update_log (self , log_data : str ) -> None :
@@ -276,7 +282,7 @@ async def _get_software(self) -> Software | None:
276282 assert device .update_mode == UpdateModeEnum .PINNED
277283 return None
278284
279- async def get_update (self ) -> tuple [HandlingType , Software ]:
285+ async def get_update (self ) -> tuple [HandlingType , Software | None ]:
280286 device = await self .get_device ()
281287 software = await self ._get_software ()
282288
0 commit comments