3030from installer_config import InstallerConfig , Step , _load_config
3131from loguru import logger
3232from tool_utils import call_tool_with_command , search_device
33- from utils import AppState , get_download_link
33+ from utils import AppState , get_download_link , image_recovery_works_with_device
3434from widgets import call_button , confirm_button , get_title , link_button
3535
3636# Toggle to True for development purposes
37- DEVELOPMENT = False
37+ DEVELOPMENT = True
3838DEVELOPMENT_CONFIG = "yuga" # "a3y17lte" # "sargo"
3939
4040
@@ -250,7 +250,7 @@ def __init__(
250250
251251 def build (self ):
252252 self .download_link = get_download_link (
253- self .state .config .metadata .get ("devicecode" , "test " )
253+ self .state .config .metadata .get ("devicecode" , "ERROR " )
254254 )
255255 self .confirm_button = confirm_button (self .on_confirm )
256256 self .confirm_button .disabled = True
@@ -264,6 +264,8 @@ def build(self):
264264 # add title and progressbar
265265 self .right_view .controls .append (get_title ("Pick image and recovery files:" ))
266266 self .right_view .controls .append (self .progressbar )
267+ # text row to show infos during the process
268+ self .info_field = Row ()
267269 # if there is an available download, show the button to the page
268270 if self .download_link :
269271 self .right_view .controls .append (
@@ -323,15 +325,25 @@ def build(self):
323325 ),
324326 self .selected_recovery ,
325327 Divider (),
326- Text ("If you selected both files you can continue." ),
328+ Text ("If you selected both files and they work for your device you can continue." ),
329+ self .info_field ,
327330 Row ([self .confirm_button ]),
328331 ]
329332 )
330333 return self .view
331334
332335 def enable_button_if_ready (self , e ):
333336 """Enable the confirm button if both files have been selected."""
337+
334338 if (".zip" in self .selected_image .value ) and (".img" in self .selected_recovery .value ):
339+ if not image_recovery_works_with_device (
340+ device_code = self .state .config .metadata .get ("devicecode" ), image_path = self .state .image_path
341+ ):
342+ # if image and recovery work for device allow to move on, otherwise display message
343+ self .info_field .controls .append (Text ("Image and recovery don't work with the device. Please select different ones." ))
344+ self .right_view .update ()
345+ return
346+ self .info_field .controls = []
335347 self .confirm_button .disabled = False
336348 self .right_view .update ()
337349 else :
@@ -465,6 +477,7 @@ def pick_image_result(self, e: FilePickerResultEvent):
465477 )
466478 if e .files :
467479 self .image_path = e .files [0 ].path
480+ self .state .image_path = e .files [0 ].path
468481 logger .info (f"Selected image from { self .image_path } " )
469482 else :
470483 logger .info ("No image selected." )
@@ -476,6 +489,7 @@ def pick_recovery_result(self, e: FilePickerResultEvent):
476489 )
477490 if e .files :
478491 self .recovery_path = e .files [0 ].path
492+ self .state .recovery_path = e .files [0 ].path
479493 logger .info (f"Selected recovery from { self .recovery_path } " )
480494 else :
481495 logger .info ("No image selected." )
0 commit comments