5757
5858
5959PLATFORM = sys .platform
60- logger .info (f"Running OpenAndroidInstaller on { PLATFORM } " )
6160# Define asset paths
6261CONFIG_PATH = Path (__file__ ).parent .joinpath (Path ("assets/configs" )).resolve ()
6362IMAGE_PATH = Path (__file__ ).parent .joinpath (Path ("assets/imgs" )).resolve ()
@@ -228,6 +227,7 @@ def search_devices(self, e):
228227 # select a new path and load again
229228 pass
230229 except CalledProcessError :
230+ logger .info (f"Did not detect a device." )
231231 if DEVELOPMENT :
232232 path = CONFIG_PATH .joinpath (Path (f"{ DEVELOPMENT_CONFIG } .yaml" ))
233233 load_config_success = self .load_config (path )
@@ -344,7 +344,7 @@ def build(
344344
345345
346346class MainView (UserControl ):
347- def __init__ (self , page : Page ):
347+ def __init__ (self ):
348348 super ().__init__ ()
349349 self .config = None
350350 # initialize the progress bar indicator
@@ -427,22 +427,27 @@ def load_config(self, path: str):
427427 try :
428428 self .config = InstallerConfig .from_file (path )
429429 self .num_total_steps = len (self .config .steps )
430+ logger .info (f"Loaded device config from { path } ." )
431+ logger .info (f"Config metadata: { self .config .metadata } ." )
430432 return self .config .metadata .get ("devicename" , "No device name in config." )
431433 except FileNotFoundError :
434+ logger .info (f"No device config found for { path } ." )
432435 return False
433436
434437 def pick_image_result (self , e : FilePickerResultEvent ):
435438 self .selected_image .value = (
436439 ", " .join (map (lambda f : f .name , e .files )) if e .files else "Cancelled!"
437440 )
438441 self .image_path = e .files [0 ].path
442+ logger .info (f"Selected image from { self .image_path } " )
439443 self .selected_image .update ()
440444
441445 def pick_recovery_result (self , e : FilePickerResultEvent ):
442446 self .selected_recovery .value = (
443447 ", " .join (map (lambda f : f .name , e .files )) if e .files else "Cancelled!"
444448 )
445449 self .recovery_path = e .files [0 ].path
450+ logger .info (f"Selected recovery from { self .recovery_path } " )
446451 self .selected_recovery .update ()
447452
448453
@@ -500,7 +505,11 @@ def build(self):
500505 return self .view
501506
502507 def call_to_phone (self , e , command : str ):
503- # TODO: use proper windows paths
508+ """
509+ Run the command given on the phone.
510+
511+ Some parts of the command are changed by placeholders.
512+ """
504513 command = command .replace ("adb" , str (BIN_PATH .joinpath (Path ("adb" ))))
505514 command = command .replace ("fastboot" , str (BIN_PATH .joinpath (Path ("fastboot" ))))
506515 command = command .replace ("heimdall" , str (BIN_PATH .joinpath (Path ("heimdall" ))))
@@ -518,6 +527,7 @@ def call_to_phone(self, e, command: str):
518527 logger .info (f"Run command: { command } " )
519528 res = call (f"{ command } " , shell = True )
520529 if res != 0 :
530+ logger .info (f"Command { command } failed." )
521531 self .right_view .controls .pop ()
522532 self .right_view .controls .append (Text ("Command {command} failed!" ))
523533 else :
@@ -526,10 +536,12 @@ def call_to_phone(self, e, command: str):
526536 self .right_view .controls .append (
527537 ElevatedButton ("Confirm and continue" , on_click = self .on_confirm )
528538 )
539+ logger .info ("Success." )
529540 self .view .update ()
530541
531542
532543def main (page : Page ):
544+ logger .info (f"Running OpenAndroidInstaller on { PLATFORM } " )
533545 # Configure the application base page
534546 page .title = "OpenAndroidInstaller"
535547 page .window_height = 720
@@ -581,11 +593,10 @@ def close_banner(e):
581593 )
582594 # TODO: disable the banner for now
583595 # page.banner.open = True
584-
585- page .update ()
596+ # page.update()
586597
587598 # create application instance
588- app = MainView (page )
599+ app = MainView ()
589600
590601 # add application's root control to the page
591602 page .add (app )
0 commit comments