Skip to content

Commit 2079328

Browse files
committed
Run black
1 parent 0406933 commit 2079328

File tree

3 files changed

+72
-18
lines changed

3 files changed

+72
-18
lines changed

openandroidinstaller/openandroidinstaller.py

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,41 @@
2222
from typing import Callable, Optional
2323

2424
import flet
25-
from flet import (AlertDialog, AppBar, Banner, Checkbox, Column, Container,
26-
Divider, ElevatedButton, FilePicker, FilePickerResultEvent,
27-
FilledButton, Icon, Image, Page, ProgressBar, ProgressRing,
28-
Row, Text, TextButton, TextField, UserControl, FloatingActionButton,
29-
VerticalDivider, colors, icons)
25+
from flet import (
26+
AlertDialog,
27+
AppBar,
28+
Banner,
29+
Checkbox,
30+
Column,
31+
Container,
32+
Divider,
33+
ElevatedButton,
34+
FilePicker,
35+
FilePickerResultEvent,
36+
FilledButton,
37+
Icon,
38+
Image,
39+
Page,
40+
ProgressBar,
41+
ProgressRing,
42+
Row,
43+
Text,
44+
TextButton,
45+
TextField,
46+
UserControl,
47+
FloatingActionButton,
48+
VerticalDivider,
49+
colors,
50+
icons,
51+
)
3052
from installer_config import Step, _load_config
3153
from loguru import logger
3254
from tool_utils import call_tool_with_command, search_device
3355
from utils import AppState, get_download_link, image_recovery_works_with_device
3456
from widgets import call_button, confirm_button, get_title, link_button
3557

3658
# Toggle to True for development purposes
37-
DEVELOPMENT = False
59+
DEVELOPMENT = False
3860
DEVELOPMENT_CONFIG = "yuga" # "a3y17lte" # "sargo"
3961

4062

@@ -339,7 +361,6 @@ def build(self):
339361

340362
def enable_button_if_ready(self, e):
341363
"""Enable the confirm button if both files have been selected."""
342-
343364
if (".zip" in self.selected_image.value) and (
344365
".img" in self.selected_recovery.value
345366
):
@@ -634,7 +655,9 @@ def main(page: Page):
634655

635656
# header
636657
page.appbar = AppBar(
637-
leading=Image(src=f"/assets/logo-192x192.png", height=40, width=40, border_radius=40),
658+
leading=Image(
659+
src=f"/assets/logo-192x192.png", height=40, width=40, border_radius=40
660+
),
638661
leading_width=56,
639662
toolbar_height=72,
640663
elevation=0,

openandroidinstaller/tool_utils.py

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,29 @@
2828
def call_tool_with_command(command: str, bin_path: Path) -> bool:
2929
"""Call an executable with a specific command."""
3030
if PLATFORM == "win32":
31-
command = re.sub(r"^adb", re.escape(str(bin_path.joinpath(Path("adb")))) + ".exe", command)
32-
command = re.sub(r"^fastboot", re.escape(str(bin_path.joinpath(Path("fastboot.exe")))) + ".exe", command)
33-
command = re.sub(r"^heimdall", re.escape(str(bin_path.joinpath(Path("heimdall.exe")))) + ".exe", command)
31+
command = re.sub(
32+
r"^adb", re.escape(str(bin_path.joinpath(Path("adb")))) + ".exe", command
33+
)
34+
command = re.sub(
35+
r"^fastboot",
36+
re.escape(str(bin_path.joinpath(Path("fastboot.exe")))) + ".exe",
37+
command,
38+
)
39+
command = re.sub(
40+
r"^heimdall",
41+
re.escape(str(bin_path.joinpath(Path("heimdall.exe")))) + ".exe",
42+
command,
43+
)
3444
else:
35-
command = re.sub(r"^adb", re.escape(str(bin_path.joinpath(Path("adb")))), command)
36-
command = re.sub(r"^fastboot", re.escape(str(bin_path.joinpath(Path("fastboot")))), command)
37-
command = re.sub(r"^heimdall", re.escape(str(bin_path.joinpath(Path("heimdall")))), command)
45+
command = re.sub(
46+
r"^adb", re.escape(str(bin_path.joinpath(Path("adb")))), command
47+
)
48+
command = re.sub(
49+
r"^fastboot", re.escape(str(bin_path.joinpath(Path("fastboot")))), command
50+
)
51+
command = re.sub(
52+
r"^heimdall", re.escape(str(bin_path.joinpath(Path("heimdall")))), command
53+
)
3854

3955
logger.info(f"Run command: {command}")
4056
res = call(f"{command}", shell=True)
@@ -73,7 +89,8 @@ def search_device(platform: str, bin_path: Path) -> Optional[str]:
7389
"findstr",
7490
"ro.product.device",
7591
],
76-
stderr=STDOUT, shell=True,
92+
stderr=STDOUT,
93+
shell=True,
7794
).decode()
7895
else:
7996
raise Exception(f"Unknown platform {platform}.")

scripts/download-tools.py

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,9 @@ def move_files_to_lib(platform: str):
8282
logger.info(f"Move executables to {target_path}...")
8383
# move the platformtools
8484
pt_path = (
85-
Path(__file__).parent.joinpath(Path(os.sep.join(["..", "tools", "platform-tools"]))).resolve()
85+
Path(__file__)
86+
.parent.joinpath(Path(os.sep.join(["..", "tools", "platform-tools"])))
87+
.resolve()
8688
)
8789
logger.info(pt_path)
8890
pt_target_path = (
@@ -110,11 +112,23 @@ def move_files_to_lib(platform: str):
110112
hd_target_path = hd_target_path.parents[0] / "heimdall.exe"
111113
hd_path.rename(hd_target_path)
112114
# move libusb
113-
libusb_path = Path(__file__).parent.joinpath(Path(os.sep.join(["..", "libusb-windows", "MinGW32", "dll", "libusb-1.0.dll"]))).resolve()
115+
libusb_path = (
116+
Path(__file__)
117+
.parent.joinpath(
118+
Path(
119+
os.sep.join(
120+
["..", "libusb-windows", "MinGW32", "dll", "libusb-1.0.dll"]
121+
)
122+
)
123+
)
124+
.resolve()
125+
)
114126
logger.info(libusb_path)
115127
libusb_target_path = (
116128
Path(__file__)
117-
.parent.joinpath(Path(os.sep.join(["..", "openandroidinstaller", "bin", "libusb-1.0.dll"])))
129+
.parent.joinpath(
130+
Path(os.sep.join(["..", "openandroidinstaller", "bin", "libusb-1.0.dll"]))
131+
)
118132
.resolve()
119133
)
120134
logger.info(libusb_target_path)

0 commit comments

Comments
 (0)