Skip to content

Commit 17264d7

Browse files
committed
run black
1 parent b3b2fd9 commit 17264d7

File tree

3 files changed

+48
-23
lines changed

3 files changed

+48
-23
lines changed

openandroidinstaller/installer_config.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,19 @@ def from_file(cls, path):
7373

7474
if raw_steps.get("unlock_bootloader") is not None:
7575
unlock_bootloader = [
76-
Step(**raw_step, title="Unlock the bootloader") for raw_step in raw_steps.get("unlock_bootloader")
76+
Step(**raw_step, title="Unlock the bootloader")
77+
for raw_step in raw_steps.get("unlock_bootloader")
7778
]
7879
else:
7980
unlock_bootloader = []
8081
flash_recovery = [
81-
Step(**raw_step, title="Flash custom recovery") for raw_step in raw_steps.get("flash_recovery", [])
82+
Step(**raw_step, title="Flash custom recovery")
83+
for raw_step in raw_steps.get("flash_recovery", [])
84+
]
85+
install_os = [
86+
Step(**raw_step, title="Install OS")
87+
for raw_step in raw_steps.get("install_os", [])
8288
]
83-
install_os = [Step(**raw_step, title="Install OS") for raw_step in raw_steps.get("install_os", [])]
8489
return cls(unlock_bootloader, flash_recovery, install_os, metadata)
8590

8691

@@ -119,7 +124,9 @@ def validate_config(config: str) -> bool:
119124
r"text|confirm_button|call_button|call_button_with_input|link_button_with_confirm"
120125
),
121126
"content": str,
122-
schema.Optional("command"): Regex(r"adb_reboot|adb_reboot_bootloader|adb_reboot_download|adb_sideload|adb_twrp_wipe_and_install|fastboot_flash_recovery|fastboot_unlock_with_code|fastboot_unlock|fastboot_oem_unlock|fastboot_reboot|heimdall_flash_recovery"),
127+
schema.Optional("command"): Regex(
128+
r"adb_reboot|adb_reboot_bootloader|adb_reboot_download|adb_sideload|adb_twrp_wipe_and_install|fastboot_flash_recovery|fastboot_unlock_with_code|fastboot_unlock|fastboot_oem_unlock|fastboot_reboot|heimdall_flash_recovery"
129+
),
123130
schema.Optional("allow_skip"): bool,
124131
schema.Optional("img"): str,
125132
schema.Optional("link"): str,

openandroidinstaller/openandroidinstaller.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
fastboot_unlock,
6565
fastboot_oem_unlock,
6666
fastboot_unlock_with_code,
67-
heimdall_flash_recovery
67+
heimdall_flash_recovery,
6868
)
6969
from utils import AppState, get_download_link, image_recovery_works_with_device
7070
from widgets import call_button, confirm_button, get_title, link_button
@@ -131,7 +131,7 @@ def build(self):
131131
modal=True,
132132
title=Text("How to enable developer options and OEM unlocking"),
133133
content=Markdown(
134-
"""
134+
"""
135135
To do this, tap seven times on the build number in the 'System'- or 'About the phone'-Menu in Settings. You can also use the phones own search to look for `build number`.
136136
Then go back to the main menu and look for 'developer options'. You can also search for it in your phone.
137137
When you are in developer options, toggle OEM unlocking and USB-Debugging. If your phone is already connected to your PC, a pop-up might appear. Allow USB debugging in the pop-up on your phone.
@@ -656,19 +656,27 @@ def call_to_phone(self, e, command: str):
656656
elif command == "adb_sideload":
657657
success = adb_sideload(bin_path=BIN_PATH, target=self.image_path)
658658
elif command == "adb_twrp_wipe_and_install":
659-
success = adb_twrp_wipe_and_install(bin_path=BIN_PATH, target=self.image_path)
659+
success = adb_twrp_wipe_and_install(
660+
bin_path=BIN_PATH, target=self.image_path
661+
)
660662
elif command == "fastboot_flash_recovery":
661-
success = fastboot_flash_recovery(bin_path=BIN_PATH, recovery=self.recovery_path)
663+
success = fastboot_flash_recovery(
664+
bin_path=BIN_PATH, recovery=self.recovery_path
665+
)
662666
elif command == "fastboot_unlock_with_code":
663-
success = fastboot_unlock_with_code(bin_path=BIN_PATH, unlock_code=self.inputtext.value)
667+
success = fastboot_unlock_with_code(
668+
bin_path=BIN_PATH, unlock_code=self.inputtext.value
669+
)
664670
elif command == "fastboot_unlock":
665671
success = fastboot_unlock(bin_path=BIN_PATH)
666672
elif command == "fastboot_oem_unlock":
667673
success = fastboot_oem_unlock(bin_path=BIN_PATH)
668674
elif command == "fastboot_reboot":
669675
success = fastboot_reboot(bin_path=BIN_PATH)
670676
elif command == "heimdall_flash_recovery":
671-
success = heimdall_flash_recovery(bin_path=BIN_PATH, recovery=self.recovery_path)
677+
success = heimdall_flash_recovery(
678+
bin_path=BIN_PATH, recovery=self.recovery_path
679+
)
672680
else:
673681
raise Exception(f"Unknown command type: {command}. Stopping.")
674682

openandroidinstaller/tool_utils.py

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,15 @@
1616
import sys
1717
from pathlib import Path
1818
from time import sleep
19-
from subprocess import STDOUT, CalledProcessError, call, check_output, PIPE, run, CompletedProcess
19+
from subprocess import (
20+
STDOUT,
21+
CalledProcessError,
22+
call,
23+
check_output,
24+
PIPE,
25+
run,
26+
CompletedProcess,
27+
)
2028
from typing import Optional, List
2129

2230
import regex as re
@@ -38,7 +46,7 @@ def run_command(tool: str, command: List[str], bin_path: Path) -> CompletedProce
3846
logger.info(f"Run command: {full_command}")
3947
result = run(full_command, stdout=PIPE, stderr=PIPE, universal_newlines=True)
4048
# result contains result.returncode, result.stdout, result.stderr
41-
return result
49+
return result
4250

4351

4452
def adb_reboot(bin_path: Path) -> bool:
@@ -92,7 +100,7 @@ def adb_sideload(bin_path: Path, target: str) -> bool:
92100

93101
def adb_twrp_wipe_and_install(bin_path: Path, target: str) -> bool:
94102
"""Wipe and format data with twrp, then flash os image with adb.
95-
103+
96104
Only works for twrp recovery.
97105
"""
98106
logger.info("Wipe and format data with twrp, then install os image.")
@@ -137,7 +145,7 @@ def adb_twrp_wipe_and_install(bin_path: Path, target: str) -> bool:
137145
logger.info("Rebooting with twrp failed.")
138146
return False
139147

140-
return True
148+
return True
141149

142150

143151
def fastboot_unlock_with_code(bin_path: Path, unlock_code: str) -> bool:
@@ -148,22 +156,22 @@ def fastboot_unlock_with_code(bin_path: Path, unlock_code: str) -> bool:
148156
logger.info(f"Unlocking with code {unlock_code} failed.")
149157
return False
150158
return True
151-
159+
152160

153161
def fastboot_unlock(bin_path: Path) -> bool:
154162
"""Unlock the device with fastboot and without code."""
155163
logger.info(f"Unlock the device with fastboot.")
156-
result = run_command("fastboot", ["flashing", "unlock"] , bin_path)
164+
result = run_command("fastboot", ["flashing", "unlock"], bin_path)
157165
if result.returncode != 0:
158166
logger.info(f"Unlocking failed.")
159167
return False
160168
return True
161-
169+
162170

163171
def fastboot_oem_unlock(bin_path: Path) -> bool:
164172
"""OEM unlock the device with fastboot and without code."""
165173
logger.info(f"OEM unlocking the device with fastboot.")
166-
result = run_command("fastboot", ["oem", "unlock"] , bin_path)
174+
result = run_command("fastboot", ["oem", "unlock"], bin_path)
167175
if result.returncode != 0:
168176
logger.info(f"OEM unlocking failed.")
169177
return False
@@ -173,27 +181,29 @@ def fastboot_oem_unlock(bin_path: Path) -> bool:
173181
def fastboot_reboot(bin_path: Path) -> bool:
174182
"""Reboot with fastboot"""
175183
logger.info(f"Rebooting device with fastboot.")
176-
result = run_command("fastboot", ["reboot"] , bin_path)
184+
result = run_command("fastboot", ["reboot"], bin_path)
177185
if result.returncode != 0:
178186
logger.info(f"Rebooting with fastboot failed.")
179187
return False
180188
return True
181-
189+
182190

183191
def fastboot_flash_recovery(bin_path: Path, recovery: str) -> bool:
184192
"""Temporarily, flash custom recovery with fastboot."""
185193
logger.info(f"Flash custom recovery with fastboot.")
186-
result = run_command("fastboot", ["boot", f"{recovery}"] , bin_path)
194+
result = run_command("fastboot", ["boot", f"{recovery}"], bin_path)
187195
if result.returncode != 0:
188196
logger.info(f"Flashing recovery failed.")
189197
return False
190198
return True
191-
199+
192200

193201
def heimdall_flash_recovery(bin_path: Path, recovery: str) -> bool:
194202
"""Temporarily, flash custom recovery with heimdall."""
195203
logger.info(f"Flash custom recovery with heimdall.")
196-
result = run_command("heimdall", ["flash", "--no-reboot", "--RECOVERY", f"{recovery}"] , bin_path)
204+
result = run_command(
205+
"heimdall", ["flash", "--no-reboot", "--RECOVERY", f"{recovery}"], bin_path
206+
)
197207
if result.returncode != 0:
198208
logger.info(f"Flashing recovery failed.")
199209
return False

0 commit comments

Comments
 (0)