Skip to content

Commit 1d842aa

Browse files
committed
Format and remove grep from linux/mac search devices
1 parent c8e7e8e commit 1d842aa

26 files changed

+41
-21
lines changed

openandroidinstaller/app_state.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""This file contains a class and function to manage the app state over various steps."""
2+
23
# This file is part of OpenAndroidInstaller.
34
# OpenAndroidInstaller is free software: you can redistribute it and/or modify it under the terms of
45
# the GNU General Public License as published by the Free Software Foundation,

openandroidinstaller/installer_config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Class to load config files for the install procedure."""
2+
23
# This file is part of OpenAndroidInstaller.
34
# OpenAndroidInstaller is free software: you can redistribute it and/or modify it under the terms of
45
# the GNU General Public License as published by the Free Software Foundation,

openandroidinstaller/openandroidinstaller.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Main file of the OpenAndroidInstaller."""
2+
23
# This file is part of OpenAndroidInstaller.
34
# OpenAndroidInstaller is free software: you can redistribute it and/or modify it under the terms of
45
# the GNU General Public License as published by the Free Software Foundation,

openandroidinstaller/styles.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""This module contains different pre-configured style elements for building the application."""
2+
23
# This file is part of OpenAndroidInstaller.
34
# OpenAndroidInstaller is free software: you can redistribute it and/or modify it under the terms of
45
# the GNU General Public License as published by the Free Software Foundation,

openandroidinstaller/tooling.py

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -595,28 +595,23 @@ def search_device(platform: str, bin_path: Path) -> SearchResult:
595595
try:
596596
# read device code
597597
if platform in ("linux", "darwin"):
598-
# check if grep is installed and find the right path
599-
try:
600-
grep_command = check_output(["which", "grep"]).decode().strip()
601-
except CalledProcessError:
602-
logger.error(
603-
"Failed to detect a device. Please make sure `grep` is installed."
604-
)
605-
return SearchResult(
606-
msg="Failed to detect a device. Please make sure `grep` is installed."
607-
)
608598
# run the command to get the device code
609-
output = check_output(
610-
[
611-
str(bin_path.joinpath(Path("adb"))),
612-
"shell",
613-
"getprop",
614-
"|",
615-
grep_command,
616-
"ro.product.device",
617-
],
599+
command = [
600+
str(bin_path.joinpath(Path("adb"))),
601+
"shell",
602+
"getprop",
603+
# "|",
604+
# "grep",
605+
# "ro.product.device",
606+
]
607+
logger.info(f"Run command: {command}")
608+
device_prop = check_output(
609+
command,
618610
stderr=STDOUT,
619611
).decode()
612+
output = [
613+
line for line in device_prop.split("\n") if "ro.product.device" in line
614+
][0]
620615
elif platform in ("windows", "win32"):
621616
# run the command to get the device code on windows
622617
output = check_output(
@@ -639,8 +634,8 @@ def search_device(platform: str, bin_path: Path) -> SearchResult:
639634
device_code=device_code,
640635
msg=f"Found device with device code '{device_code}'.",
641636
)
642-
except CalledProcessError:
643-
logger.error("Failed to detect a device.")
637+
except CalledProcessError as e:
638+
logger.error(f"Failed to detect a device. {e}")
644639
return SearchResult(
645640
msg="Failed to detect a device. Connect to USB and try again."
646641
)

openandroidinstaller/views/addon_view.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Contains the select addons view."""
2+
23
# This file is part of OpenAndroidInstaller.
34
# OpenAndroidInstaller is free software: you can redistribute it and/or modify it under the terms of
45
# the GNU General Public License as published by the Free Software Foundation,

openandroidinstaller/views/base.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Contains the base class for views."""
2+
23
# This file is part of OpenAndroidInstaller.
34
# OpenAndroidInstaller is free software: you can redistribute it and/or modify it under the terms of
45
# the GNU General Public License as published by the Free Software Foundation,

openandroidinstaller/views/install_addons_view.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Contains the install addons view."""
2+
23
# This file is part of OpenAndroidInstaller.
34
# OpenAndroidInstaller is free software: you can redistribute it and/or modify it under the terms of
45
# the GNU General Public License as published by the Free Software Foundation,

openandroidinstaller/views/install_view.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Contains the install view."""
2+
23
# This file is part of OpenAndroidInstaller.
34
# OpenAndroidInstaller is free software: you can redistribute it and/or modify it under the terms of
45
# the GNU General Public License as published by the Free Software Foundation,

openandroidinstaller/views/requirements_view.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Contains the requirements view."""
2+
23
# This file is part of OpenAndroidInstaller.
34
# OpenAndroidInstaller is free software: you can redistribute it and/or modify it under the terms of
45
# the GNU General Public License as published by the Free Software Foundation,

0 commit comments

Comments
 (0)