|
13 | 13 | # If not, see <https://www.gnu.org/licenses/>.""" |
14 | 14 | # Author: Tobias Sterbak |
15 | 15 |
|
| 16 | +import os |
16 | 17 | import sys |
17 | 18 | import webbrowser |
18 | 19 | from pathlib import Path |
|
38 | 39 |
|
39 | 40 | PLATFORM = sys.platform |
40 | 41 | # Define asset paths |
41 | | -CONFIG_PATH = Path(__file__).parent.joinpath(Path("assets/configs")).resolve() |
42 | | -IMAGE_PATH = Path(__file__).parent.joinpath(Path("assets/imgs")).resolve() |
| 42 | +CONFIG_PATH = Path(__file__).parent.joinpath(Path(os.sep.join(["assets", "configs"]))).resolve() |
| 43 | +IMAGE_PATH = Path(__file__).parent.joinpath(Path(os.sep.join(["assets", "imgs"]))).resolve() |
43 | 44 | BIN_PATH = Path(__file__).parent.joinpath(Path("bin")).resolve() |
44 | 45 |
|
45 | 46 |
|
@@ -115,7 +116,7 @@ def check_bootloader_unlocked(e): |
115 | 116 | self.state.num_total_steps = len(self.state.steps) |
116 | 117 |
|
117 | 118 | self.bootloader_checkbox = Checkbox( |
118 | | - label="Bootlaoder is already unlocked.", on_change=check_bootloader_unlocked, disabled=True |
| 119 | + label="Bootloader is already unlocked.", on_change=check_bootloader_unlocked, disabled=True |
119 | 120 | ) |
120 | 121 |
|
121 | 122 | # build up the main view |
@@ -324,7 +325,7 @@ def build(self): |
324 | 325 |
|
325 | 326 | def enable_button_if_ready(self, e): |
326 | 327 | """Enable the confirm button if both files have been selected.""" |
327 | | - if self.selected_image.value and self.selected_recovery.value: |
| 328 | + if (".zip" in self.selected_image.value) and (".img" in self.selected_recovery.value): |
328 | 329 | self.confirm_button.disabled = False |
329 | 330 | self.right_view.update() |
330 | 331 | else: |
@@ -456,16 +457,22 @@ def pick_image_result(self, e: FilePickerResultEvent): |
456 | 457 | self.selected_image.value += ( |
457 | 458 | ", ".join(map(lambda f: f.name, e.files)) if e.files else "Cancelled!" |
458 | 459 | ) |
459 | | - self.image_path = e.files[0].path |
460 | | - logger.info(f"Selected image from {self.image_path}") |
| 460 | + if e.files: |
| 461 | + self.image_path = e.files[0].path |
| 462 | + logger.info(f"Selected image from {self.image_path}") |
| 463 | + else: |
| 464 | + logger.info("No image selected.") |
461 | 465 | self.selected_image.update() |
462 | 466 |
|
463 | 467 | def pick_recovery_result(self, e: FilePickerResultEvent): |
464 | 468 | self.selected_recovery.value += ( |
465 | 469 | ", ".join(map(lambda f: f.name, e.files)) if e.files else "Cancelled!" |
466 | 470 | ) |
467 | | - self.recovery_path = e.files[0].path |
468 | | - logger.info(f"Selected recovery from {self.recovery_path}") |
| 471 | + if e.files: |
| 472 | + self.recovery_path = e.files[0].path |
| 473 | + logger.info(f"Selected recovery from {self.recovery_path}") |
| 474 | + else: |
| 475 | + logger.info("No image selected.") |
469 | 476 | self.selected_recovery.update() |
470 | 477 |
|
471 | 478 |
|
@@ -587,7 +594,7 @@ def main(page: Page): |
587 | 594 | page.horizontal_alignment = "center" |
588 | 595 |
|
589 | 596 | # header |
590 | | - image_path = Path(__file__).parent.joinpath(Path("assets/logo-192x192.png")) |
| 597 | + image_path = Path(__file__).parent.joinpath(Path(os.sep.join(["assets", "logo-192x192.png"]))) |
591 | 598 | page.appbar = AppBar( |
592 | 599 | leading=Image(src=image_path, height=40, width=40, border_radius=40), |
593 | 600 | leading_width=56, |
|
0 commit comments