Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

accessibility: raise RpcFailedToGetPrimaryAppError if failed to get it #371

Merged
merged 3 commits into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,13 @@ jobs:
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Lint with flake8
- name: Install dependencies
run: |
python -m pip install flake8
flake8 . --max-complexity=14 --max-line-length=127 --statistics
python3 -m pip install --upgrade pip
python3 -m pip install pre-commit
- name: Run pre-commit hooks
run: |
pre-commit run --all-files
- name: Verify sorted imports
run: |
python -m pip install isort
Expand Down
15 changes: 15 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# .pre-commit-config.yaml
repos:
- repo: https://github.com/pre-commit/mirrors-isort
rev: v5.9.3
hooks:
- id: isort
args: [ '-m', 'HANGING_INDENT', '-l', '120','--check-only' ]
files: src/client

- repo: https://github.com/pycqa/flake8
rev: "7.0.0"
hooks:
- id: flake8
args: [ '--max-line-length=127' ]
files: src/client
1 change: 1 addition & 0 deletions src/rpcclient/rpcclient/darwin/keychain.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

logger = logging.getLogger(__name__)


class Keychain:
""" keychain utils """

Expand Down
6 changes: 6 additions & 0 deletions src/rpcclient/rpcclient/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class ResponseNotFoundError(RpcClientException):

class ServerResponseError(RpcClientException):
""" Server returned error """

def __init__(self, error):
super().__init__()
self.error = error
Expand Down Expand Up @@ -197,3 +198,8 @@ class RpcXpcSerializationError(RpcXpcError):
class RpcSetDeveloperModeError(BadReturnValueError):
""" Failed to set Developer Mode """
pass


class RpcFailedToGetPrimaryAppError(BadReturnValueError):
""" Failed to get [AXElement primaryApp] """
pass
7 changes: 5 additions & 2 deletions src/rpcclient/rpcclient/ios/accessibility.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from rpcclient.darwin.symbol import DarwinSymbol
from rpcclient.exceptions import ElementNotFoundError, FirstElementNotFoundError, LastElementNotFoundError, \
MissingLibraryError, RpcAccessibilityTurnedOffError
MissingLibraryError, RpcAccessibilityTurnedOffError, RpcFailedToGetPrimaryAppError
from rpcclient.structs.consts import RTLD_NOW


Expand Down Expand Up @@ -393,7 +393,10 @@ def __init__(self, client):
def primary_app(self) -> AXElement:
if not self.enabled:
raise RpcAccessibilityTurnedOffError()
return self.axelement(self._client.symbols.objc_getClass('AXElement').objc_call('primaryApp'))
primary_app = self._client.symbols.objc_getClass('AXElement').objc_call('primaryApp')
if primary_app == 0:
raise RpcFailedToGetPrimaryAppError()
return self.axelement(primary_app)

@property
def enabled(self) -> bool:
Expand Down
Loading