Skip to content

Commit

Permalink
Format and remove grep from linux/mac search devices
Browse files Browse the repository at this point in the history
  • Loading branch information
tsterbak committed Mar 24, 2024
1 parent c8e7e8e commit 1d842aa
Show file tree
Hide file tree
Showing 26 changed files with 41 additions and 21 deletions.
1 change: 1 addition & 0 deletions openandroidinstaller/app_state.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""This file contains a class and function to manage the app state over various steps."""

# This file is part of OpenAndroidInstaller.
# OpenAndroidInstaller is free software: you can redistribute it and/or modify it under the terms of
# the GNU General Public License as published by the Free Software Foundation,
Expand Down
1 change: 1 addition & 0 deletions openandroidinstaller/installer_config.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Class to load config files for the install procedure."""

# This file is part of OpenAndroidInstaller.
# OpenAndroidInstaller is free software: you can redistribute it and/or modify it under the terms of
# the GNU General Public License as published by the Free Software Foundation,
Expand Down
1 change: 1 addition & 0 deletions openandroidinstaller/openandroidinstaller.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Main file of the OpenAndroidInstaller."""

# This file is part of OpenAndroidInstaller.
# OpenAndroidInstaller is free software: you can redistribute it and/or modify it under the terms of
# the GNU General Public License as published by the Free Software Foundation,
Expand Down
1 change: 1 addition & 0 deletions openandroidinstaller/styles.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""This module contains different pre-configured style elements for building the application."""

# This file is part of OpenAndroidInstaller.
# OpenAndroidInstaller is free software: you can redistribute it and/or modify it under the terms of
# the GNU General Public License as published by the Free Software Foundation,
Expand Down
37 changes: 16 additions & 21 deletions openandroidinstaller/tooling.py
Original file line number Diff line number Diff line change
Expand Up @@ -595,28 +595,23 @@ def search_device(platform: str, bin_path: Path) -> SearchResult:
try:
# read device code
if platform in ("linux", "darwin"):
# check if grep is installed and find the right path
try:
grep_command = check_output(["which", "grep"]).decode().strip()
except CalledProcessError:
logger.error(
"Failed to detect a device. Please make sure `grep` is installed."
)
return SearchResult(
msg="Failed to detect a device. Please make sure `grep` is installed."
)
# run the command to get the device code
output = check_output(
[
str(bin_path.joinpath(Path("adb"))),
"shell",
"getprop",
"|",
grep_command,
"ro.product.device",
],
command = [
str(bin_path.joinpath(Path("adb"))),
"shell",
"getprop",
# "|",
# "grep",
# "ro.product.device",
]
logger.info(f"Run command: {command}")
device_prop = check_output(
command,
stderr=STDOUT,
).decode()
output = [
line for line in device_prop.split("\n") if "ro.product.device" in line
][0]
elif platform in ("windows", "win32"):
# run the command to get the device code on windows
output = check_output(
Expand All @@ -639,8 +634,8 @@ def search_device(platform: str, bin_path: Path) -> SearchResult:
device_code=device_code,
msg=f"Found device with device code '{device_code}'.",
)
except CalledProcessError:
logger.error("Failed to detect a device.")
except CalledProcessError as e:
logger.error(f"Failed to detect a device. {e}")
return SearchResult(
msg="Failed to detect a device. Connect to USB and try again."
)
1 change: 1 addition & 0 deletions openandroidinstaller/views/addon_view.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Contains the select addons view."""

# This file is part of OpenAndroidInstaller.
# OpenAndroidInstaller is free software: you can redistribute it and/or modify it under the terms of
# the GNU General Public License as published by the Free Software Foundation,
Expand Down
1 change: 1 addition & 0 deletions openandroidinstaller/views/base.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Contains the base class for views."""

# This file is part of OpenAndroidInstaller.
# OpenAndroidInstaller is free software: you can redistribute it and/or modify it under the terms of
# the GNU General Public License as published by the Free Software Foundation,
Expand Down
1 change: 1 addition & 0 deletions openandroidinstaller/views/install_addons_view.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Contains the install addons view."""

# This file is part of OpenAndroidInstaller.
# OpenAndroidInstaller is free software: you can redistribute it and/or modify it under the terms of
# the GNU General Public License as published by the Free Software Foundation,
Expand Down
1 change: 1 addition & 0 deletions openandroidinstaller/views/install_view.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Contains the install view."""

# This file is part of OpenAndroidInstaller.
# OpenAndroidInstaller is free software: you can redistribute it and/or modify it under the terms of
# the GNU General Public License as published by the Free Software Foundation,
Expand Down
1 change: 1 addition & 0 deletions openandroidinstaller/views/requirements_view.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Contains the requirements view."""

# This file is part of OpenAndroidInstaller.
# OpenAndroidInstaller is free software: you can redistribute it and/or modify it under the terms of
# the GNU General Public License as published by the Free Software Foundation,
Expand Down
1 change: 1 addition & 0 deletions openandroidinstaller/views/select_view.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Contains the select files view."""

# This file is part of OpenAndroidInstaller.
# OpenAndroidInstaller is free software: you can redistribute it and/or modify it under the terms of
# the GNU General Public License as published by the Free Software Foundation,
Expand Down
1 change: 1 addition & 0 deletions openandroidinstaller/views/step_view.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Contains the steps view."""

# This file is part of OpenAndroidInstaller.
# OpenAndroidInstaller is free software: you can redistribute it and/or modify it under the terms of
# the GNU General Public License as published by the Free Software Foundation,
Expand Down
1 change: 1 addition & 0 deletions openandroidinstaller/views/success_view.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Contains the final success view."""

# This file is part of OpenAndroidInstaller.
# OpenAndroidInstaller is free software: you can redistribute it and/or modify it under the terms of
# the GNU General Public License as published by the Free Software Foundation,
Expand Down
1 change: 1 addition & 0 deletions openandroidinstaller/views/welcome_view.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Contains the welcome view."""

# This file is part of OpenAndroidInstaller.
# OpenAndroidInstaller is free software: you can redistribute it and/or modify it under the terms of
# the GNU General Public License as published by the Free Software Foundation,
Expand Down
1 change: 1 addition & 0 deletions openandroidinstaller/widgets.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Contains functions and classes to get different elements and widgets of the installer."""

# This file is part of OpenAndroidInstaller.
# OpenAndroidInstaller is free software: you can redistribute it and/or modify it under the terms of
# the GNU General Public License as published by the Free Software Foundation,
Expand Down
1 change: 1 addition & 0 deletions scripts/build.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Script to build the OpenAndroidInstaller executable on different platforms with pyinstaller."""

# This file is part of OpenAndroidInstaller.
# OpenAndroidInstaller is free software: you can redistribute it and/or modify it under the terms of
# the GNU General Public License as published by the Free Software Foundation,
Expand Down
1 change: 1 addition & 0 deletions scripts/check-install.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Check if adb works and print the version."""

# This file is part of OpenAndroidInstaller.
# OpenAndroidInstaller is free software: you can redistribute it and/or modify it under the terms of
# the GNU General Public License as published by the Free Software Foundation,
Expand Down
1 change: 1 addition & 0 deletions scripts/download-tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Inspired by: https://gitlab.com/ubports/installer/android-tools-bin/-/blob/master/build.js
"""

# This file is part of OpenAndroidInstaller.
# OpenAndroidInstaller is free software: you can redistribute it and/or modify it under the terms of
# the GNU General Public License as published by the Free Software Foundation,
Expand Down
1 change: 1 addition & 0 deletions scripts/lineageos-on-galaxy-a3.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
Example usage:
poetry run python scripts/lineageos-on-galaxy-a3.py --recovery images/samsung-galaxy-a3/twrp-3.6.2_9-0-a3y17lte.img --image images/samsung-galaxy-a3/lineage-16.0-20190908-UNOFFICIAL-a3y17lte.zip
"""

# This file is part of OpenAndroidInstaller.
# OpenAndroidInstaller is free software: you can redistribute it and/or modify it under the terms of
# the GNU General Public License as published by the Free Software Foundation,
Expand Down
1 change: 1 addition & 0 deletions scripts/lineageos-on-pixel3a.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
Example usage:
poetry run python scripts/lineageos-on-pixel3a.py --recovery images/google-pixel3a/lineage-19.1-20220830-recovery-sargo.img --image images/google-pixel3a/lineage-19.1-20220830-nightly-sargo-signed.zip
"""

# This file is part of OpenAndroidInstaller.
# OpenAndroidInstaller is free software: you can redistribute it and/or modify it under the terms of
# the GNU General Public License as published by the Free Software Foundation,
Expand Down
1 change: 1 addition & 0 deletions scripts/lineageos-on-sony-xperia-z.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
Example usage:
poetry run python scripts/lineageos-on-sony-xperia-z.py --recovery images/sony-xperia-z/twrp-3.6.2_9-0-yuga.img --image images/sony-xperia-z/lineage-18.1-20220214-UNOFFICIAL-yuga.zip
"""

# This file is part of OpenAndroidInstaller.
# OpenAndroidInstaller is free software: you can redistribute it and/or modify it under the terms of
# the GNU General Public License as published by the Free Software Foundation,
Expand Down
1 change: 1 addition & 0 deletions scripts/utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Reusable functions for flashing."""

# This file is part of OpenAndroidInstaller.
# OpenAndroidInstaller is free software: you can redistribute it and/or modify it under the terms of
# the GNU General Public License as published by the Free Software Foundation,
Expand Down
1 change: 1 addition & 0 deletions tests/test_app.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Test if the main app starts up."""

# This file is part of OpenAndroidInstaller.
# OpenAndroidInstaller is free software: you can redistribute it and/or modify it under the terms of
# the GNU General Public License as published by the Free Software Foundation,
Expand Down
1 change: 1 addition & 0 deletions tests/test_configs.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Test existing config files for schema."""

# This file is part of OpenAndroidInstaller.
# OpenAndroidInstaller is free software: you can redistribute it and/or modify it under the terms of
# the GNU General Public License as published by the Free Software Foundation,
Expand Down
1 change: 1 addition & 0 deletions tests/test_progress_bar.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Test the ProgressIndicator class."""

# This file is part of OpenAndroidInstaller.
# OpenAndroidInstaller is free software: you can redistribute it and/or modify it under the terms of
# the GNU General Public License as published by the Free Software Foundation,
Expand Down
1 change: 1 addition & 0 deletions tests/test_terminal_box.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Test the TerminalBox class."""

# This file is part of OpenAndroidInstaller.
# OpenAndroidInstaller is free software: you can redistribute it and/or modify it under the terms of
# the GNU General Public License as published by the Free Software Foundation,
Expand Down

0 comments on commit 1d842aa

Please sign in to comment.