From 2c0bbf09ff0a1e74f8029950ff494ac51f462526 Mon Sep 17 00:00:00 2001 From: Tobias Sterbak Date: Wed, 7 Feb 2024 08:55:32 +0000 Subject: [PATCH] Run all commit hooks and fix linting --- .../device-support-request.yaml | 2 +- .github/workflows/build-release.yml | 6 +- .gitignore | 122 +++++++++--------- .pre-commit-config.yaml | 7 +- CODE_OF_CONDUCT.md | 4 +- CONTRIBUTING.md | 2 +- Makefile | 2 +- ...installer.OpenAndroidInstaller.appdata.xml | 8 +- ...roidinstaller.OpenAndroidInstaller.desktop | 2 +- openandroidinstaller/app_state.py | 8 +- openandroidinstaller/assets/configs/FP3.yaml | 2 +- openandroidinstaller/assets/configs/FP4.yaml | 2 +- .../assets/configs/akatsuki.yaml | 10 +- .../assets/configs/bonito.yaml | 2 +- .../assets/configs/crosshatch.yaml | 2 +- .../assets/configs/guacamoleb.yaml | 1 - openandroidinstaller/assets/helper.txt | 2 +- openandroidinstaller/installer_config.py | 9 +- openandroidinstaller/openandroidinstaller.py | 27 ++-- openandroidinstaller/styles.py | 6 +- openandroidinstaller/tooling.py | 18 +-- openandroidinstaller/utils.py | 6 +- openandroidinstaller/views/__init__.py | 10 +- openandroidinstaller/views/addon_view.py | 28 ++-- openandroidinstaller/views/base.py | 5 - .../views/install_addons_view.py | 35 +---- openandroidinstaller/views/install_view.py | 36 ++---- .../views/requirements_view.py | 23 ++-- openandroidinstaller/views/select_view.py | 40 +++--- openandroidinstaller/views/start_view.py | 30 ++--- openandroidinstaller/views/step_view.py | 40 ++---- openandroidinstaller/views/success_view.py | 17 +-- openandroidinstaller/views/welcome_view.py | 22 +--- openandroidinstaller/widgets.py | 23 ++-- ...androidinstaller.OpenAndroidInstaller.json | 2 +- pyproject.toml | 80 +++++++++++- scripts/build.py | 8 +- scripts/check-install.py | 7 +- scripts/download-tools.py | 4 - scripts/lineageos-on-galaxy-a3.py | 8 +- scripts/lineageos-on-pixel3a.py | 6 +- scripts/lineageos-on-sony-xperia-z.py | 6 +- scripts/utils.py | 7 +- tests/conftest.py | 4 +- tests/test_app.py | 6 +- tests/test_configs.py | 9 +- tests/test_progress_bar.py | 5 - tests/test_terminal_box.py | 13 +- tests/test_tooling.py | 14 +- 49 files changed, 300 insertions(+), 438 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/device-support-request.yaml b/.github/ISSUE_TEMPLATE/device-support-request.yaml index 9823d1f5..59323439 100644 --- a/.github/ISSUE_TEMPLATE/device-support-request.yaml +++ b/.github/ISSUE_TEMPLATE/device-support-request.yaml @@ -85,5 +85,5 @@ body: - type: textarea attributes: label: Additional context - description: Please provide any additional context or information that might be helpful in adding support for this device. + description: Please provide any additional context or information that might be helpful in adding support for this device. render: Markdown diff --git a/.github/workflows/build-release.yml b/.github/workflows/build-release.yml index 26dd3907..e30d5c80 100644 --- a/.github/workflows/build-release.yml +++ b/.github/workflows/build-release.yml @@ -23,7 +23,7 @@ jobs: - run: black . - run: ruff openandroidinstaller/ --ignore E501 - run: PYTHONPATH=openandroidinstaller:$(PYTHONPATH) pytest --cov=openandroidinstaller tests/ - + build: needs: ci runs-on: ${{ matrix.os }} @@ -43,7 +43,7 @@ jobs: with: name: openandroidinstaller-${{ github.ref_name }}-${{ matrix.os }} path: dist/ - + build-windows: needs: ci runs-on: 'windows-latest' @@ -59,7 +59,7 @@ jobs: with: name: openandroidinstaller-${{ github.ref_name }}-windows-latest path: dist/ - + create-release: needs: - build diff --git a/.gitignore b/.gitignore index d96688c8..eb4c282e 100644 --- a/.gitignore +++ b/.gitignore @@ -5,24 +5,24 @@ __pycache__ *.py[cod] *$py.class -# Distribution / packaging -.Python build/ -develop-eggs/ -dist/ -downloads/ -eggs/ -.eggs/ -lib/ -lib64/ -parts/ -sdist/ -var/ -wheels/ -*.egg-info/ -.installed.cfg -*.egg -*.manifest -*.spec +# Distribution / packaging +.Python build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +*.egg-info/ +.installed.cfg +*.egg +*.manifest +*.spec heimdall/ libusb-windows/ openandroidinstaller/bin/ @@ -33,17 +33,17 @@ pip-log.txt pip-delete-this-directory.txt *.log -# Unit test / coverage reports -htmlcov/ -.tox/ -.coverage -.coverage.* -.cache -.pytest_cache/ -nosetests.xml -coverage.xml -*.cover -.hypothesis/ +# Unit test / coverage reports +htmlcov/ +.tox/ +.coverage +.coverage.* +.cache +.pytest_cache/ +nosetests.xml +coverage.xml +*.cover +.hypothesis/ # Translations *.mo @@ -72,42 +72,42 @@ env/ venv/ ENV/ -# If you are using PyCharm # -.idea/**/workspace.xml -.idea/**/tasks.xml -.idea/dictionaries -.idea/**/dataSources/ -.idea/**/dataSources.ids -.idea/**/dataSources.xml -.idea/**/dataSources.local.xml -.idea/**/sqlDataSources.xml -.idea/**/dynamic.xml -.idea/**/uiDesigner.xml -.idea/**/gradle.xml -.idea/**/libraries -*.iws /out/ +# If you are using PyCharm # +.idea/**/workspace.xml +.idea/**/tasks.xml +.idea/dictionaries +.idea/**/dataSources/ +.idea/**/dataSources.ids +.idea/**/dataSources.xml +.idea/**/dataSources.local.xml +.idea/**/sqlDataSources.xml +.idea/**/dynamic.xml +.idea/**/uiDesigner.xml +.idea/**/gradle.xml +.idea/**/libraries +*.iws /out/ # Sublime Text -*.tmlanguage.cache -*.tmPreferences.cache -*.stTheme.cache -*.sublime-workspace -*.sublime-project +*.tmlanguage.cache +*.tmPreferences.cache +*.stTheme.cache +*.sublime-workspace +*.sublime-project -# sftp configuration file +# sftp configuration file sftp-config.json -# Package control specific files Package -Control.last-run -Control.ca-list -Control.ca-bundle -Control.system-ca-bundle -GitHub.sublime-settings +# Package control specific files Package +Control.last-run +Control.ca-list +Control.ca-bundle +Control.system-ca-bundle +GitHub.sublime-settings -# Visual Studio Code # -.vscode/* -!.vscode/settings.json -!.vscode/tasks.json -!.vscode/launch.json -!.vscode/extensions.json +# Visual Studio Code # +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json .history diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 27e29225..9f0c8330 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,5 +1,6 @@ # See https://pre-commit.com for more information # See https://pre-commit.com/hooks.html for more hooks +fail_fast: true repos: - repo: https://github.com/pre-commit/pre-commit-hooks rev: v3.2.0 @@ -12,11 +13,6 @@ repos: - id: end-of-file-fixer - id: trailing-whitespace -- repo: https://github.com/asottile/reorder_python_imports - rev: v3.9.0 - hooks: - - id: reorder-python-imports - - repo: https://github.com/psf/black rev: 22.10.0 hooks: @@ -28,6 +24,7 @@ repos: hooks: # Run the linter. - id: ruff + args: [ '--ignore', 'E501', '--fix' ] # Run the formatter. - id: ruff-format diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index fdaca199..a64f4e38 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -119,11 +119,11 @@ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0, available at [https://www.contributor-covenant.org/version/2/0/code_of_conduct.html][v2.0]. -Community Impact Guidelines were inspired by +Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder][Mozilla CoC]. For answers to common questions about this code of conduct, see the FAQ at -[https://www.contributor-covenant.org/faq][FAQ]. Translations are available +[https://www.contributor-covenant.org/faq][FAQ]. Translations are available at [https://www.contributor-covenant.org/translations][translations]. [homepage]: https://www.contributor-covenant.org diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index aa989a0d..c39a28b7 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,4 +1,4 @@ -# Contributing to the OpenAndroidInstaller project +# Contributing to the OpenAndroidInstaller project 💖 First of all: thank you for contributing to the OpenAndroidInstaller! Great that you are here! diff --git a/Makefile b/Makefile index 5e069da9..f41198b7 100644 --- a/Makefile +++ b/Makefile @@ -16,7 +16,7 @@ poetry: curl -sSL https://install.python-poetry.org | python3 - install: - poetry install + poetry install --with dev poetry run python scripts/download-tools.py poetry run pre-commit install diff --git a/flatpak/org.openandroidinstaller.OpenAndroidInstaller.appdata.xml b/flatpak/org.openandroidinstaller.OpenAndroidInstaller.appdata.xml index aa745b0a..19c4ac46 100644 --- a/flatpak/org.openandroidinstaller.OpenAndroidInstaller.appdata.xml +++ b/flatpak/org.openandroidinstaller.OpenAndroidInstaller.appdata.xml @@ -1,18 +1,18 @@ org.openandroidinstaller.OpenAndroidInstaller - + OpenAndroidInstaller Makes installing alternative Android distributions nice and easy. - + CC-BY-SA-4.0 GPL-3.0-or-later - +

The OpenAndroidInstaller project helps Android users to keep their smartphone's operating system up to date with free software and to continue using the device even though the manufacturer no longer offers updates. With a graphical installation software, users are easily guided through the installation process of free Android operating systems like LineageOS.

- + org.openandroidinstaller.OpenAndroidInstaller.desktop
diff --git a/flatpak/org.openandroidinstaller.OpenAndroidInstaller.desktop b/flatpak/org.openandroidinstaller.OpenAndroidInstaller.desktop index 8771719c..1e831e57 100644 --- a/flatpak/org.openandroidinstaller.OpenAndroidInstaller.desktop +++ b/flatpak/org.openandroidinstaller.OpenAndroidInstaller.desktop @@ -3,7 +3,7 @@ Version=1.0 Type=Application Name=OpenAndroidInstaller -Comment= Makes installing alternative Android distributions nice and easy. +Comment= Makes installing alternative Android distributions nice and easy. Categories=Utility;FileTools; Icon=org.openandroidinstaller.OpenAndroidInstaller diff --git a/openandroidinstaller/app_state.py b/openandroidinstaller/app_state.py index 22d2722f..c1341526 100644 --- a/openandroidinstaller/app_state.py +++ b/openandroidinstaller/app_state.py @@ -1,24 +1,20 @@ """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, # either version 3 of the License, or (at your option) any later version. - # OpenAndroidInstaller is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - # You should have received a copy of the GNU General Public License along with OpenAndroidInstaller. # If not, see .""" # Author: Tobias Sterbak - import copy from pathlib import Path from typing import List, Optional -from loguru import logger -from installer_config import _load_config, Step +from installer_config import Step, _load_config +from loguru import logger class AppState: diff --git a/openandroidinstaller/assets/configs/FP3.yaml b/openandroidinstaller/assets/configs/FP3.yaml index 6de90c06..451737b9 100644 --- a/openandroidinstaller/assets/configs/FP3.yaml +++ b/openandroidinstaller/assets/configs/FP3.yaml @@ -47,7 +47,7 @@ steps: boot_recovery: - type: confirm_button content: > - Now you need to boot a custom recovery system on the phone. A recovery is a small subsystem on your phone, that manages updating, + Now you need to boot a custom recovery system on the phone. A recovery is a small subsystem on your phone, that manages updating, adapting and repairing of the operating system. - type: call_button content: > diff --git a/openandroidinstaller/assets/configs/FP4.yaml b/openandroidinstaller/assets/configs/FP4.yaml index 7e14c899..a27bc3b1 100644 --- a/openandroidinstaller/assets/configs/FP4.yaml +++ b/openandroidinstaller/assets/configs/FP4.yaml @@ -47,7 +47,7 @@ steps: boot_recovery: - type: confirm_button content: > - Now you need to boot a custom recovery system on the phone. A recovery is a small subsystem on your phone, that manages updating, + Now you need to boot a custom recovery system on the phone. A recovery is a small subsystem on your phone, that manages updating, adapting and repairing of the operating system. - type: call_button content: > diff --git a/openandroidinstaller/assets/configs/akatsuki.yaml b/openandroidinstaller/assets/configs/akatsuki.yaml index 7a083b38..daaa1fcc 100644 --- a/openandroidinstaller/assets/configs/akatsuki.yaml +++ b/openandroidinstaller/assets/configs/akatsuki.yaml @@ -2,9 +2,9 @@ metadata: maintainer: Tobias Sterbak (tsterbak) device_name: Sony Xperia XZ3 is_ab_device: true - device_code: akatsuki + device_code: akatsuki supported_device_codes: - - akatsuki + - akatsuki requirements: android: 10 steps: @@ -21,7 +21,7 @@ steps: - type: link_button_with_confirm content: > Click on the button to open the instructions on Sonys official unlocking website to generate an unlock code for your bootloader. - Once you got the code write it down somewhere and continue to input the code. + Once you got the code write it down somewhere and continue to input the code. link: https://developer.sonymobile.com/unlockbootloader/unlock-yourboot-loader/ - type: confirm_button content: > @@ -37,7 +37,7 @@ steps: command: fastboot_unlock_with_code - type: call_button content: > - Press the button to reboot. Since the device resets completely, you will need to re-enable USB debugging to continue. + Press the button to reboot. Since the device resets completely, you will need to re-enable USB debugging to continue. Connect your device to your PC via USB. Then confirm here to continue. command: fastboot_reboot boot_recovery: @@ -59,4 +59,4 @@ steps: - type: call_button content: > Now we need to boot into recovery again. Press run and when you see the TWRP screen you can continue. - command: fastboot_flash_boot \ No newline at end of file + command: fastboot_flash_boot diff --git a/openandroidinstaller/assets/configs/bonito.yaml b/openandroidinstaller/assets/configs/bonito.yaml index 4c62c13a..3d10767c 100644 --- a/openandroidinstaller/assets/configs/bonito.yaml +++ b/openandroidinstaller/assets/configs/bonito.yaml @@ -41,4 +41,4 @@ steps: img: twrp-start.jpeg content: > Boot a custom recovery (temporarily) by pressing 'Confirm and run'. Once your phone screen looks like the picture on the left, continue. - command: fastboot_boot_recovery \ No newline at end of file + command: fastboot_boot_recovery diff --git a/openandroidinstaller/assets/configs/crosshatch.yaml b/openandroidinstaller/assets/configs/crosshatch.yaml index a612f210..ff8d4449 100644 --- a/openandroidinstaller/assets/configs/crosshatch.yaml +++ b/openandroidinstaller/assets/configs/crosshatch.yaml @@ -41,4 +41,4 @@ steps: img: twrp-start.jpeg content: > Boot a custom recovery (temporarily) by pressing 'Confirm and run'. Once your phone screen looks like the picture on the left, continue. - command: fastboot_boot_recovery \ No newline at end of file + command: fastboot_boot_recovery diff --git a/openandroidinstaller/assets/configs/guacamoleb.yaml b/openandroidinstaller/assets/configs/guacamoleb.yaml index 5b4230cb..e9094aa4 100644 --- a/openandroidinstaller/assets/configs/guacamoleb.yaml +++ b/openandroidinstaller/assets/configs/guacamoleb.yaml @@ -39,4 +39,3 @@ steps: content: > Boot a custom recovery (temporarily) by pressing 'Confirm and run'. Once it's done continue. command: fastboot_boot_recovery - diff --git a/openandroidinstaller/assets/helper.txt b/openandroidinstaller/assets/helper.txt index a404baec..8cd748bf 100644 --- a/openandroidinstaller/assets/helper.txt +++ b/openandroidinstaller/assets/helper.txt @@ -1,2 +1,2 @@ This file is sideloaded by OpenAndroidInstaller to help with a TWRP issue on A/B-partioned devices. -Please visit https://github.com/openandroidinstaller-dev/openandroidinstaller to find out more. \ No newline at end of file +Please visit https://github.com/openandroidinstaller-dev/openandroidinstaller to find out more. diff --git a/openandroidinstaller/installer_config.py b/openandroidinstaller/installer_config.py index 7eafe47e..01ac57b0 100644 --- a/openandroidinstaller/installer_config.py +++ b/openandroidinstaller/installer_config.py @@ -1,26 +1,22 @@ """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, # either version 3 of the License, or (at your option) any later version. - # OpenAndroidInstaller is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - # You should have received a copy of the GNU General Public License along with OpenAndroidInstaller. # If not, see .""" # Author: Tobias Sterbak - from pathlib import Path from typing import List, Optional -from typing_extensions import Self import schema import yaml from loguru import logger from schema import Regex, Schema, SchemaError +from typing_extensions import Self class Step: @@ -112,7 +108,8 @@ def _find_config_file(device_code: str, config_path: Path) -> Optional[Path]: f"Device code '{device_code}' is supported by config '{path}'." ) return path - except: + except Exception: + # this is a very broad exception, but we want to catch all errors here and handle them downstream pass return None diff --git a/openandroidinstaller/openandroidinstaller.py b/openandroidinstaller/openandroidinstaller.py index e010ea12..1708eab1 100644 --- a/openandroidinstaller/openandroidinstaller.py +++ b/openandroidinstaller/openandroidinstaller.py @@ -1,27 +1,24 @@ """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, # either version 3 of the License, or (at your option) any later version. - # OpenAndroidInstaller is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - # You should have received a copy of the GNU General Public License along with OpenAndroidInstaller. # If not, see .""" # Author: Tobias Sterbak - +import functools import os import sys import webbrowser -import click -import functools from pathlib import Path from typing import List +import click import flet as ft +from app_state import AppState from flet import ( AppBar, Banner, @@ -37,23 +34,19 @@ icons, ) from loguru import logger - -from styles import ( - Text, -) -from app_state import AppState +from styles import Text +from tooling import run_command from views import ( + AddonsView, + InstallAddonsView, + InstallView, + RequirementsView, SelectFilesView, + StartView, StepView, SuccessView, - StartView, - RequirementsView, - InstallView, WelcomeView, - AddonsView, - InstallAddonsView, ) -from tooling import run_command # VERSION number VERSION = "0.5.3-beta" diff --git a/openandroidinstaller/styles.py b/openandroidinstaller/styles.py index d3783c82..9ac227d3 100644 --- a/openandroidinstaller/styles.py +++ b/openandroidinstaller/styles.py @@ -1,18 +1,14 @@ """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, # either version 3 of the License, or (at your option) any later version. - # OpenAndroidInstaller is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - # You should have received a copy of the GNU General Public License along with OpenAndroidInstaller. # If not, see .""" # Author: Tobias Sterbak - import flet as ft @@ -31,5 +27,5 @@ def __init__(self, *args, **kwargs): selectable=True, on_tap_link=lambda e: self.page.launch_url(e.data), *args, - **kwargs + **kwargs, ) diff --git a/openandroidinstaller/tooling.py b/openandroidinstaller/tooling.py index 47587d90..9fb01d2b 100644 --- a/openandroidinstaller/tooling.py +++ b/openandroidinstaller/tooling.py @@ -1,34 +1,24 @@ """This module contains functions to deal with tools like adb, fastboot and heimdall.""" - # 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, # either version 3 of the License, or (at your option) any later version. - # OpenAndroidInstaller is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - # You should have received a copy of the GNU General Public License along with OpenAndroidInstaller. # If not, see .""" # Author: Tobias Sterbak - +import shlex +import subprocess import sys from pathlib import Path -import subprocess -from subprocess import ( - PIPE, - STDOUT, - CalledProcessError, - check_output, -) -import shlex +from subprocess import PIPE, STDOUT, CalledProcessError, check_output from time import sleep -from typing import Optional, Union, Generator, Callable +from typing import Callable, Generator, Optional, Union from loguru import logger - TerminalResponse = Generator[Union[str, bool], None, None] diff --git a/openandroidinstaller/utils.py b/openandroidinstaller/utils.py index eb503f9f..3db391d7 100644 --- a/openandroidinstaller/utils.py +++ b/openandroidinstaller/utils.py @@ -1,22 +1,18 @@ """This file contains some utility functions.""" - # 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, # either version 3 of the License, or (at your option) any later version. - # OpenAndroidInstaller is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - # You should have received a copy of the GNU General Public License along with OpenAndroidInstaller. # If not, see .""" # Author: Tobias Sterbak - import zipfile from dataclasses import dataclass from enum import Enum -from typing import Optional, List +from typing import List, Optional import requests from loguru import logger diff --git a/openandroidinstaller/views/__init__.py b/openandroidinstaller/views/__init__.py index 93d8d460..7bb73550 100644 --- a/openandroidinstaller/views/__init__.py +++ b/openandroidinstaller/views/__init__.py @@ -1,10 +1,10 @@ +from .addon_view import AddonsView # noqa from .base import BaseView # noqa -from .welcome_view import WelcomeView # noqa -from .start_view import StartView # noqa +from .install_addons_view import InstallAddonsView # noqa +from .install_view import InstallView # noqa from .requirements_view import RequirementsView # noqa from .select_view import SelectFilesView # noqa +from .start_view import StartView # noqa from .step_view import StepView # noqa -from .install_view import InstallView # noqa -from .addon_view import AddonsView # noqa -from .install_addons_view import InstallAddonsView # noqa from .success_view import SuccessView # noqa +from .welcome_view import WelcomeView # noqa diff --git a/openandroidinstaller/views/addon_view.py b/openandroidinstaller/views/addon_view.py index 5999e5b9..072dbcdf 100644 --- a/openandroidinstaller/views/addon_view.py +++ b/openandroidinstaller/views/addon_view.py @@ -1,45 +1,37 @@ """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, # either version 3 of the License, or (at your option) any later version. - # OpenAndroidInstaller is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - # You should have received a copy of the GNU General Public License along with OpenAndroidInstaller. # If not, see .""" # Author: Tobias Sterbak - import webbrowser -from loguru import logger from typing import Callable +from app_state import AppState from flet import ( + AlertDialog, Column, Divider, ElevatedButton, - OutlinedButton, + FilePicker, + FilePickerResultEvent, FilledButton, + OutlinedButton, Row, + TextButton, colors, icons, - TextButton, - AlertDialog, - FilePicker, - FilePickerResultEvent, ) from flet_core.buttons import CountinuosRectangleBorder - -from styles import ( - Text, - Markdown, -) +from loguru import logger +from styles import Markdown, Text from views import BaseView -from app_state import AppState -from widgets import get_title, confirm_button +from widgets import confirm_button, get_title class AddonsView(BaseView): @@ -59,7 +51,7 @@ def build(self): content=Markdown( """## Google Apps: There are different packages of Google Apps available. Most notable -- [MindTheGapps](https://wiki.lineageos.org/gapps#downloads) and +- [MindTheGapps](https://wiki.lineageos.org/gapps#downloads) and - [NikGApps](https://nikgapps.com). These packages are only dependent on your OS version and processor architecture, which can be found on each device specific info page. diff --git a/openandroidinstaller/views/base.py b/openandroidinstaller/views/base.py index 584ee0e9..20e2392f 100644 --- a/openandroidinstaller/views/base.py +++ b/openandroidinstaller/views/base.py @@ -1,20 +1,15 @@ """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, # either version 3 of the License, or (at your option) any later version. - # OpenAndroidInstaller is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - # You should have received a copy of the GNU General Public License along with OpenAndroidInstaller. # If not, see .""" # Author: Tobias Sterbak - from app_state import AppState - from flet import Column, Container, Image, Row, UserControl, VerticalDivider, margin diff --git a/openandroidinstaller/views/install_addons_view.py b/openandroidinstaller/views/install_addons_view.py index bdc54840..be26062d 100644 --- a/openandroidinstaller/views/install_addons_view.py +++ b/openandroidinstaller/views/install_addons_view.py @@ -1,46 +1,25 @@ """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, # either version 3 of the License, or (at your option) any later version. - # OpenAndroidInstaller is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - # You should have received a copy of the GNU General Public License along with OpenAndroidInstaller. # If not, see .""" # Author: Tobias Sterbak - -from loguru import logger +from pathlib import Path from time import sleep from typing import Callable -from pathlib import Path - -from flet import ( - Column, - ElevatedButton, - Row, - icons, - Switch, - colors, -) - -from styles import ( - Text, - Markdown, -) -from views import BaseView from app_state import AppState -from tooling import adb_twrp_install_addon, adb_twrp_finish_install_addons, adb_reboot -from widgets import ( - confirm_button, - get_title, - TerminalBox, - ProgressIndicator, -) +from flet import Column, ElevatedButton, Row, Switch, colors, icons +from loguru import logger +from styles import Markdown, Text +from tooling import adb_reboot, adb_twrp_finish_install_addons, adb_twrp_install_addon +from views import BaseView +from widgets import ProgressIndicator, TerminalBox, confirm_button, get_title class InstallAddonsView(BaseView): diff --git a/openandroidinstaller/views/install_view.py b/openandroidinstaller/views/install_view.py index 6e8c7b4d..7d8e444e 100644 --- a/openandroidinstaller/views/install_view.py +++ b/openandroidinstaller/views/install_view.py @@ -1,45 +1,24 @@ """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, # either version 3 of the License, or (at your option) any later version. - # OpenAndroidInstaller is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - # You should have received a copy of the GNU General Public License along with OpenAndroidInstaller. # If not, see .""" # Author: Tobias Sterbak - -from loguru import logger from time import sleep from typing import Callable -from flet import ( - Column, - ElevatedButton, - Row, - icons, - Switch, - colors, -) - -from styles import ( - Text, - Markdown, -) - -from views import BaseView from app_state import AppState +from flet import Column, ElevatedButton, Row, Switch, colors, icons +from loguru import logger +from styles import Markdown, Text from tooling import adb_twrp_wipe_and_install -from widgets import ( - confirm_button, - get_title, - TerminalBox, - ProgressIndicator, -) +from views import BaseView +from widgets import ProgressIndicator, TerminalBox, confirm_button, get_title class InstallView(BaseView): @@ -74,6 +53,7 @@ def check_advanced_switch(e): on_change=check_advanced_switch, disabled=False, ) + # switch for installing addons def check_addons_switch(e): """Check the switch to enable the addons installation process.""" @@ -108,13 +88,13 @@ def check_addons_switch(e): self.right_view.controls = [ Markdown( """In the next steps, you finally flash the selected OS image. - + Connect your device with your computer with the USB-Cable. This step will format your phone and wipe all the data. It will also remove encryption and delete all files stored in the internal storage. Then the OS image will be installed. Confirm to install. This might take a while. At the end your phone will boot into the new OS. - + #### **Install addons:** If you want to install any addons like Google Apps, microG or F-droid, use the toggle below **before** starting the install process! After the installation you'll be taken through the process. Note, that this process is still somewhat experimental and using ROMs with diff --git a/openandroidinstaller/views/requirements_view.py b/openandroidinstaller/views/requirements_view.py index 0954f052..92039a83 100644 --- a/openandroidinstaller/views/requirements_view.py +++ b/openandroidinstaller/views/requirements_view.py @@ -1,42 +1,35 @@ """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, # either version 3 of the License, or (at your option) any later version. - # OpenAndroidInstaller is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - # You should have received a copy of the GNU General Public License along with OpenAndroidInstaller. # If not, see .""" # Author: Tobias Sterbak - -from loguru import logger from typing import Callable + +from app_state import AppState from flet import ( - Checkbox, + AlertDialog, Card, + Checkbox, Column, Container, Divider, ElevatedButton, + OutlinedButton, Row, + TextButton, colors, - OutlinedButton, icons, - TextButton, - AlertDialog, ) from flet_core.buttons import CountinuosRectangleBorder - -from styles import ( - Text, - Markdown, -) +from loguru import logger +from styles import Markdown, Text from views import BaseView -from app_state import AppState from widgets import get_title diff --git a/openandroidinstaller/views/select_view.py b/openandroidinstaller/views/select_view.py index a6627323..4fb9b13b 100644 --- a/openandroidinstaller/views/select_view.py +++ b/openandroidinstaller/views/select_view.py @@ -1,54 +1,46 @@ """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, # either version 3 of the License, or (at your option) any later version. - # OpenAndroidInstaller is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - # You should have received a copy of the GNU General Public License along with OpenAndroidInstaller. # If not, see .""" # Author: Tobias Sterbak - import webbrowser -from loguru import logger from typing import Callable +from app_state import AppState from flet import ( + AlertDialog, + Checkbox, Column, Divider, ElevatedButton, - OutlinedButton, + FilePicker, + FilePickerResultEvent, FilledButton, + OutlinedButton, Row, + TextButton, colors, icons, - TextButton, - AlertDialog, - FilePicker, - FilePickerResultEvent, - Checkbox, ) from flet_core.buttons import CountinuosRectangleBorder - -from styles import ( - Text, - Markdown, -) -from views import BaseView -from app_state import AppState -from widgets import get_title, confirm_button +from loguru import logger +from styles import Markdown, Text from utils import ( + CheckResult, + CompatibilityStatus, get_download_link, + image_sdk_level, image_works_with_device, recovery_works_with_device, - image_sdk_level, - CheckResult, - CompatibilityStatus, ) +from views import BaseView +from widgets import confirm_button, get_title class SelectFilesView(BaseView): @@ -75,8 +67,8 @@ def init_visuals( content=Markdown( """## OS image or ROM An operating system (OS) is system software that manages computer hardware, -software resources, and provides common services for computer programs. -Popular, custom operating systems for mobile devices based on Android are +software resources, and provides common services for computer programs. +Popular, custom operating systems for mobile devices based on Android are - [LineageOS](https://lineageos.org) - [/e/OS](https://e.foundation/e-os) or - [LineageOS for microG](https://lineage.microg.org) diff --git a/openandroidinstaller/views/start_view.py b/openandroidinstaller/views/start_view.py index 8a752bf3..2057ad39 100644 --- a/openandroidinstaller/views/start_view.py +++ b/openandroidinstaller/views/start_view.py @@ -1,46 +1,38 @@ """Contains the start 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, # either version 3 of the License, or (at your option) any later version. - # OpenAndroidInstaller is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - # You should have received a copy of the GNU General Public License along with OpenAndroidInstaller. # If not, see .""" # Author: Tobias Sterbak - import webbrowser -from loguru import logger from typing import Callable +from app_state import AppState from flet import ( AlertDialog, - Switch, Column, Divider, ElevatedButton, - OutlinedButton, FilledButton, - Row, + OutlinedButton, ResponsiveRow, + Row, + Switch, TextButton, colors, icons, ) from flet_core.buttons import CountinuosRectangleBorder - -from styles import ( - Text, - Markdown, -) +from loguru import logger +from styles import Markdown, Text +from tooling import search_device from views import BaseView -from app_state import AppState from widgets import get_title -from tooling import search_device class StartView(BaseView): @@ -80,8 +72,8 @@ def init_visuals( title=Text("How to enable developer options and OEM unlocking"), content=Markdown( """ -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`. +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`. - Then go back to the main menu and look for **'developer options'**. You can also search for it in your phone. - 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.** @@ -153,7 +145,7 @@ def build(self): [ Markdown( """ -To get started you need to +To get started you need to - **enable developer options** on your device - and then **enable USB debugging** and **OEM unlocking** in the developer options. """ @@ -173,7 +165,7 @@ def build(self): Divider(), Markdown( """ -Now +Now - **connect your device to this computer via USB** and - **allow USB debugging in the pop-up on your phone**. - You might also need to **activate "data transfer"** in the connection settings. diff --git a/openandroidinstaller/views/step_view.py b/openandroidinstaller/views/step_view.py index b64a78c2..99fae039 100644 --- a/openandroidinstaller/views/step_view.py +++ b/openandroidinstaller/views/step_view.py @@ -1,42 +1,23 @@ """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, # either version 3 of the License, or (at your option) any later version. - # OpenAndroidInstaller is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - # You should have received a copy of the GNU General Public License along with OpenAndroidInstaller. # If not, see .""" # Author: Tobias Sterbak - -from loguru import logger +from functools import partial from time import sleep from typing import Callable -from functools import partial -from flet import ( - Column, - ElevatedButton, - Row, - icons, - TextField, - Switch, - colors, -) - - -from styles import ( - Text, - Markdown, -) - -from views import BaseView -from installer_config import Step from app_state import AppState +from flet import Column, ElevatedButton, Row, Switch, TextField, colors, icons +from installer_config import Step +from loguru import logger +from styles import Markdown, Text from tooling import ( adb_reboot, adb_reboot_bootloader, @@ -45,25 +26,26 @@ adb_sideload, adb_twrp_copy_partitions, fastboot_boot_recovery, + fastboot_flash_additional_partitions, fastboot_flash_boot, fastboot_flash_recovery, - fastboot_reboot_recovery, - fastboot_flash_additional_partitions, + fastboot_get_unlock_data, fastboot_oem_unlock, fastboot_reboot, + fastboot_reboot_recovery, fastboot_unlock, fastboot_unlock_critical, fastboot_unlock_with_code, - fastboot_get_unlock_data, heimdall_flash_recovery, ) +from views import BaseView from widgets import ( + ProgressIndicator, + TerminalBox, call_button, confirm_button, get_title, link_button, - TerminalBox, - ProgressIndicator, ) diff --git a/openandroidinstaller/views/success_view.py b/openandroidinstaller/views/success_view.py index e1bd6af8..b9e20458 100644 --- a/openandroidinstaller/views/success_view.py +++ b/openandroidinstaller/views/success_view.py @@ -1,30 +1,19 @@ """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, # either version 3 of the License, or (at your option) any later version. - # OpenAndroidInstaller is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - # You should have received a copy of the GNU General Public License along with OpenAndroidInstaller. # If not, see .""" # Author: Tobias Sterbak - +from app_state import AppState +from flet import ElevatedButton, Row from loguru import logger -from flet import ( - ElevatedButton, - Row, -) - -from styles import ( - Text, - Markdown, -) +from styles import Markdown, Text from views import BaseView -from app_state import AppState from widgets import get_title diff --git a/openandroidinstaller/views/welcome_view.py b/openandroidinstaller/views/welcome_view.py index a3560ea7..50c219b7 100644 --- a/openandroidinstaller/views/welcome_view.py +++ b/openandroidinstaller/views/welcome_view.py @@ -1,34 +1,20 @@ """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, # either version 3 of the License, or (at your option) any later version. - # OpenAndroidInstaller is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - # You should have received a copy of the GNU General Public License along with OpenAndroidInstaller. # If not, see .""" # Author: Tobias Sterbak - from typing import Callable -from flet import ( - Divider, - ElevatedButton, - Row, - icons, -) - -from styles import ( - Text, - Markdown, -) - -from views import BaseView from app_state import AppState +from flet import Divider, ElevatedButton, Row, icons +from styles import Markdown, Text +from views import BaseView from widgets import get_title @@ -86,7 +72,7 @@ def build(self): Before you continue, make sure - your devices is on the latest system update. - you have a backup of all your important data, since this procedure will **erase all data from the phone**. -- to not store the backup on the phone! +- to not store the backup on the phone! Please note, that vendor specific back-ups will most likely not work on LineageOS! """ diff --git a/openandroidinstaller/widgets.py b/openandroidinstaller/widgets.py index c23e8d99..1d72d933 100644 --- a/openandroidinstaller/widgets.py +++ b/openandroidinstaller/widgets.py @@ -1,41 +1,34 @@ """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, # either version 3 of the License, or (at your option) any later version. - # OpenAndroidInstaller is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - # You should have received a copy of the GNU General Public License along with OpenAndroidInstaller. # If not, see .""" # Author: Tobias Sterbak - import webbrowser -import regex as re from functools import partial from typing import Callable, Optional +import regex as re from flet import ( - UserControl, - colors, + Column, Container, ElevatedButton, - ProgressRing, + IconButton, + Image, ProgressBar, + ProgressRing, Row, + UserControl, alignment, + colors, icons, - IconButton, - Image, - Column, -) - -from styles import ( - Text, ) +from styles import Text class TerminalBox(UserControl): diff --git a/org.openandroidinstaller.OpenAndroidInstaller.json b/org.openandroidinstaller.OpenAndroidInstaller.json index f356835c..c873ba60 100644 --- a/org.openandroidinstaller.OpenAndroidInstaller.json +++ b/org.openandroidinstaller.OpenAndroidInstaller.json @@ -101,7 +101,7 @@ "type": "file", "path": "flatpak/org.openandroidinstaller.OpenAndroidInstaller.png" } - + ], "build-commands": [ "mkdir -p /app/{bin,share/{appdata,applications,icons/hicolor/512x512/apps}}", diff --git a/pyproject.toml b/pyproject.toml index 9d0cbfa3..e4ccc57f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -39,7 +39,83 @@ requires = ["poetry-core>=1.0.0"] build-backend = "poetry.core.masonry.api" [tool.ruff] -line-length = 88 +# Exclude a variety of commonly ignored directories. +exclude = [ + ".bzr", + ".direnv", + ".eggs", + ".git", + ".git-rewrite", + ".hg", + ".ipynb_checkpoints", + ".mypy_cache", + ".nox", + ".pants.d", + ".pyenv", + ".pytest_cache", + ".pytype", + ".ruff_cache", + ".svn", + ".tox", + ".venv", + ".vscode", + "__pypackages__", + "_build", + "buck-out", + "build", + "dist", + "node_modules", + "site-packages", + "venv", + "scripts/lineageos-*", # exclude the experimental lineageos scripts +] +# Same as Black. +line-length = 88 +indent-width = 4 # Never enforce `E501`. line length -exclude = ["E501"] +#exclude = ["E501"] + +# Assume Python 3.8 +target-version = "py38" + +[tool.ruff.lint] +# Enable Pyflakes (`F`) and a subset of the pycodestyle (`E`) codes by default. +# Unlike Flake8, Ruff doesn't enable pycodestyle warnings (`W`) or +# McCabe complexity (`C901`) by default. +select = ["E4", "E7", "E9", "F"] +ignore = [] + +# Allow fix for all enabled rules (when `--fix`) is provided. +fixable = ["ALL"] +unfixable = [] + +# Allow unused variables when underscore-prefixed. +dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$" + +[tool.ruff.format] +# Like Black, use double quotes for strings. +quote-style = "double" + +# Like Black, indent with spaces, rather than tabs. +indent-style = "space" + +# Like Black, respect magic trailing commas. +skip-magic-trailing-comma = false + +# Like Black, automatically detect the appropriate line ending. +line-ending = "auto" + +# Enable auto-formatting of code examples in docstrings. Markdown, +# reStructuredText code/literal blocks and doctests are all supported. +# +# This is currently disabled by default, but it is planned for this +# to be opt-out in the future. +docstring-code-format = false + +# Set the line length limit used when formatting code snippets in +# docstrings. +# +# This only has an effect when the `docstring-code-format` setting is +# enabled. +docstring-code-line-length = "dynamic" diff --git a/scripts/build.py b/scripts/build.py index 267da642..be410aab 100644 --- a/scripts/build.py +++ b/scripts/build.py @@ -1,18 +1,14 @@ """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, # either version 3 of the License, or (at your option) any later version. - # OpenAndroidInstaller is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - # You should have received a copy of the GNU General Public License along with OpenAndroidInstaller. # If not, see .""" # Author: Tobias Sterbak - import subprocess import sys @@ -95,10 +91,10 @@ def build(): """Run the build for your OS and save it in the current directory.""" if sys.platform.startswith("linux"): logger.info("Building for Linux") - res = build_linux() + _ = build_linux() elif sys.platform.startswith("darwin"): logger.info("Building for macOS") - res = build_macos() + _ = build_macos() elif sys.platform.startswith("win"): logger.info("Building for Windows") build_windows() diff --git a/scripts/check-install.py b/scripts/check-install.py index 84a0b19a..63c4eda2 100644 --- a/scripts/check-install.py +++ b/scripts/check-install.py @@ -1,19 +1,16 @@ """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, # either version 3 of the License, or (at your option) any later version. - # OpenAndroidInstaller is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - # You should have received a copy of the GNU General Public License along with OpenAndroidInstaller. # If not, see .""" # Author: Tobias Sterbak - -from subprocess import STDOUT, check_output +from subprocess import check_output +from subprocess import STDOUT def check_adb_version(): diff --git a/scripts/download-tools.py b/scripts/download-tools.py index 5237e941..c8a4c230 100644 --- a/scripts/download-tools.py +++ b/scripts/download-tools.py @@ -2,20 +2,16 @@ 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, # either version 3 of the License, or (at your option) any later version. - # OpenAndroidInstaller is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - # You should have received a copy of the GNU General Public License along with OpenAndroidInstaller. # If not, see .""" # Author: Tobias Sterbak - import os import sys import zipfile diff --git a/scripts/lineageos-on-galaxy-a3.py b/scripts/lineageos-on-galaxy-a3.py index 3f2a057e..8839b8e5 100644 --- a/scripts/lineageos-on-galaxy-a3.py +++ b/scripts/lineageos-on-galaxy-a3.py @@ -5,20 +5,16 @@ 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, # either version 3 of the License, or (at your option) any later version. - # OpenAndroidInstaller is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - # You should have received a copy of the GNU General Public License along with OpenAndroidInstaller. # If not, see .""" # Author: Tobias Sterbak - from subprocess import call from time import sleep @@ -100,7 +96,7 @@ def install_os(image: str): ) click.echo("\nRebooting") - if call(f"adb reboot", shell=True) < 0: + if call("adb reboot", shell=True) < 0: return False click.echo("Flashing finished.") @@ -129,7 +125,7 @@ def boot_recovery(recovery: str): err=False, ) click.echo("\nBooting into download mode:") - if call(f"adb reboot download", shell=True) < 0: + if call("adb reboot download", shell=True) < 0: click.echo("*** Booting into download mode failed! ***") return False confirmed = click.confirm( diff --git a/scripts/lineageos-on-pixel3a.py b/scripts/lineageos-on-pixel3a.py index a155193f..97b7d6fa 100644 --- a/scripts/lineageos-on-pixel3a.py +++ b/scripts/lineageos-on-pixel3a.py @@ -1,22 +1,18 @@ """Script to flash a google pixel 3a. 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 + 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, # either version 3 of the License, or (at your option) any later version. - # OpenAndroidInstaller is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - # You should have received a copy of the GNU General Public License along with OpenAndroidInstaller. # If not, see .""" # Author: Tobias Sterbak - from subprocess import call import click diff --git a/scripts/lineageos-on-sony-xperia-z.py b/scripts/lineageos-on-sony-xperia-z.py index cdab4a7e..8478c1c3 100644 --- a/scripts/lineageos-on-sony-xperia-z.py +++ b/scripts/lineageos-on-sony-xperia-z.py @@ -1,22 +1,18 @@ """Script to flash a sony xperia z. 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 + 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, # either version 3 of the License, or (at your option) any later version. - # OpenAndroidInstaller is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - # You should have received a copy of the GNU General Public License along with OpenAndroidInstaller. # If not, see .""" # Author: Tobias Sterbak - from subprocess import call import click diff --git a/scripts/utils.py b/scripts/utils.py index 1372d092..51707274 100644 --- a/scripts/utils.py +++ b/scripts/utils.py @@ -1,19 +1,16 @@ """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, # either version 3 of the License, or (at your option) any later version. - # OpenAndroidInstaller is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - # You should have received a copy of the GNU General Public License along with OpenAndroidInstaller. # If not, see .""" # Author: Tobias Sterbak - -from subprocess import STDOUT, check_output +from subprocess import check_output +from subprocess import STDOUT from typing import List diff --git a/tests/conftest.py b/tests/conftest.py index 2bf0c8d9..6e2b5d65 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -2,17 +2,15 @@ # 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, # either version 3 of the License, or (at your option) any later version. - # OpenAndroidInstaller is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - # You should have received a copy of the GNU General Public License along with OpenAndroidInstaller. # If not, see .""" # Author: Tobias Sterbak +from pathlib import Path import pytest -from pathlib import Path @pytest.fixture diff --git a/tests/test_app.py b/tests/test_app.py index 52d60979..760e24c3 100644 --- a/tests/test_app.py +++ b/tests/test_app.py @@ -1,20 +1,16 @@ """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, # either version 3 of the License, or (at your option) any later version. - # OpenAndroidInstaller is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - # You should have received a copy of the GNU General Public License along with OpenAndroidInstaller. # If not, see .""" # Author: Tobias Sterbak - import flet as ft -from openandroidinstaller.views import InstallView + from openandroidinstaller.openandroidinstaller import main diff --git a/tests/test_configs.py b/tests/test_configs.py index ccb6ec08..b7a09e05 100644 --- a/tests/test_configs.py +++ b/tests/test_configs.py @@ -1,24 +1,21 @@ """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, # either version 3 of the License, or (at your option) any later version. - # OpenAndroidInstaller is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - # You should have received a copy of the GNU General Public License along with OpenAndroidInstaller. # If not, see .""" # Author: Tobias Sterbak - from pathlib import Path import pytest import yaml -from openandroidinstaller.installer_config import validate_config, _load_config +from openandroidinstaller.installer_config import _load_config +from openandroidinstaller.installer_config import validate_config @pytest.mark.parametrize( @@ -46,4 +43,4 @@ def test_load_config_notfound(config_path): config = _load_config(device_code="nothing", config_path=config_path) # assert some properties of the config - assert config == None + assert config is None diff --git a/tests/test_progress_bar.py b/tests/test_progress_bar.py index 31700450..793c60dd 100644 --- a/tests/test_progress_bar.py +++ b/tests/test_progress_bar.py @@ -1,19 +1,14 @@ """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, # either version 3 of the License, or (at your option) any later version. - # OpenAndroidInstaller is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - # You should have received a copy of the GNU General Public License along with OpenAndroidInstaller. # If not, see .""" # Author: Tobias Sterbak - -import pytest from flet import Container from openandroidinstaller.widgets import ProgressIndicator diff --git a/tests/test_terminal_box.py b/tests/test_terminal_box.py index 6a530e50..fbb9a06a 100644 --- a/tests/test_terminal_box.py +++ b/tests/test_terminal_box.py @@ -1,20 +1,15 @@ """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, # either version 3 of the License, or (at your option) any later version. - # OpenAndroidInstaller is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - # You should have received a copy of the GNU General Public License along with OpenAndroidInstaller. # If not, see .""" # Author: Tobias Sterbak - -import pytest -from flet import Container, Page +from flet import Container from openandroidinstaller.widgets import TerminalBox @@ -58,15 +53,15 @@ def test_toggle_visibility(mocker): _ = terminal_box.build() # should be non-visible at the beginning - assert terminal_box._box.visible == False + assert terminal_box._box.visible is False # now toggle terminal_box.toggle_visibility() # now should be visible - assert terminal_box._box.visible == True + assert terminal_box._box.visible is True # now toggle again terminal_box.toggle_visibility() # now it should be non-visible again - assert terminal_box._box.visible == False + assert terminal_box._box.visible is False def test_clear_terminal(mocker): diff --git a/tests/test_tooling.py b/tests/test_tooling.py index ffcaeb5a..d42238ad 100644 --- a/tests/test_tooling.py +++ b/tests/test_tooling.py @@ -1,25 +1,19 @@ """Test interactions with tools like adb and fastboot""" - # 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, # either version 3 of the License, or (at your option) any later version. - # OpenAndroidInstaller is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - # You should have received a copy of the GNU General Public License along with OpenAndroidInstaller. # If not, see .""" # Author: Tobias Sterbak - from pathlib import Path from subprocess import CalledProcessError -from openandroidinstaller.tooling import ( - adb_reboot, - search_device, -) +from openandroidinstaller.tooling import adb_reboot +from openandroidinstaller.tooling import search_device def test_adb_reboot_success(fp): @@ -31,7 +25,7 @@ def test_adb_reboot_success(fp): ) for line in adb_reboot(bin_path=Path("test/path/to/tools")): print(line) - for_later = "error: no devices/emulators found" + # for_later = "error: no devices/emulators found" assert line @@ -94,4 +88,4 @@ def patched_check_output(*args, **kwargs): platform="linux", bin_path=Path("openandroidinstaller/bin/") ) - assert device_code == None + assert device_code is None