Skip to content

Commit

Permalink
Merge branch 'master' into feature/element-refresh
Browse files Browse the repository at this point in the history
  • Loading branch information
cmin764 committed Oct 2, 2023
2 parents 5b6d908 + b7a8055 commit 2a74ad2
Show file tree
Hide file tree
Showing 11 changed files with 448 additions and 201 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: java-access-bridge-wrapper

on:
push:
paths:
- src/**
- .github/workflows/**

jobs:
lint:
# Not using the latest ubuntu until this issue is fixed in setup-python:
# https://github.com/actions/setup-python/issues/401
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.10.12
- name: Upgrade pip
run: python -m pip install --upgrade pip
- name: Install requirements
run: pip install -Ur requirements.txt
- name: Set up cache
uses: actions/cache@v3
with:
path: .venv
key: venv-${{ hashFiles('poetry.lock') }}
- name: Install dependencies
run: invoke update
- name: Run lint
run: invoke lint
38 changes: 26 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@

Python wrapper around the Java Access Bridge / Windows Access Bridge.

# Prerequisites
# Requirements

* 64-bit Windows
* Java >= 8 (https://docs.aws.amazon.com/corretto/latest/corretto-8-ug/downloads-list.html)
* If you are doing development install JDK, otherwise JRE is enough
* Python >= 3.7 (https://www.python.org/downloads/release/python-375/)
* Python >= 3.8 (https://www.python.org/downloads/release/python-375/)

Enable the Java Access Bridge in windows

Expand Down Expand Up @@ -67,30 +67,44 @@ Once the JABWrapper object is initialized, attach to some frame and optionally c

# Development

## Development prerequisites
## Prerequisites

* Install poetry: https://python-poetry.org/docs/
1. Install Invoke, Poetry and the other required dependencies in order to be able to develop and package the library:
`pip install -Ur requirements.txt`.
- If you want to isolate these from the other projects and not rely on the OS
Python, enable a (_pyenv_) virtual environment first by following these
[instructions](https://github.com/robocorp/rpaframework/blob/master/docs/source/contributing/development.md#virtual-environments).
2. Now you're ready to set-up Poetry for the first time with `inv setup`.
- Check with `-h` on how to pass credentials for ensuring that both your production PyPI and CI DevPI are
configured. You'll find these in our **Robocorp** > **Shared** 1Password by searching for keywords like "pypi"
(where we recommend a personal _token_ instead) and "devpi".
3. Run `inv update` so the library gets ready for development.

## Test
## Testing

Run test script against simple Swing application
Run test script against a simple Swing application.

Set environment variable

set RC_JAVA_ACCESS_BRIDGE_DLL="C:\path\to\Java\bin\WindowsAccessBridge-64.dll"

Initialize poetry
Update requirements and install the library in development mode

poetry intall
inv update

Run test with poetry
Run tests

poetry run python tests\test.py
inv test

## Packaging

poetry build
poetry publish
Check linting

inv lint # apply with '-a'

Building and publishing

inv publish # '-c' for DevPI

## TODO:

Expand Down
18 changes: 15 additions & 3 deletions config/flake8
Original file line number Diff line number Diff line change
@@ -1,10 +1,22 @@
# List of codes:
# https://pycodestyle.pycqa.org/en/latest/intro.html#error-codes
# https://flake8.pycqa.org/en/latest/user/error-codes.html

[flake8]
ignore = W503, E203, E501
ignore =
# W503: line break before binary operator
W503,
# E203: whitespace before ‘,’, ‘;’, or ‘:’
E203,
# E501: line too long (82 > 79 characters)
E501
per-file-ignores =
# F401: module imported but unused
*/__init__.py: F401
exclude =
.git,
.venv

max-complexity = 10
# Subject to change after deciding upon a standard.
max-line-length = 120
per-file-ignores =
*/__init__.py: F401
64 changes: 63 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions poetry.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[virtualenvs]
in-project = true
create = true
path = "null"

[installer]
parallel = true

[repositories.devpi]
url = "https://devpi.robocorp.cloud/ci/test"
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ pywin32 = { version = ">=300,<307", platform = "win32", python = "!=3.8.1" }
black = "^23.9.1"
flake8 = "^6.1.0"
isort = "^5.12.0"
pytest = "^7.4.2"

[tool.poetry.scripts]
java_tree_reader = 'JABWrapper.context_tree_reader:main'
Expand Down
3 changes: 3 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
invoke~=2.2.0
poetry~=1.6.1
keyring~=24.2.0
3 changes: 2 additions & 1 deletion src/JABWrapper/context_tree.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import logging
import re
import threading
from dataclasses import dataclass
from typing import List
Expand Down Expand Up @@ -233,7 +234,7 @@ def _match_attrs(self, search_elements: List[SearchElement]) -> bool:
for search_element in search_elements:
attr = getattr(self._aci, search_element.name)
if isinstance(attr, str) and not search_element.strict:
if not attr.startswith(search_element.value):
if not re.match(search_element.value, attr):
return False
else:
if not attr == search_element.value:
Expand Down
6 changes: 5 additions & 1 deletion src/JABWrapper/jab_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -698,7 +698,11 @@ def switch_window_by_pid(self, pid: int) -> int:

logging.info(
"Found Java window text={} pid={} hwnd={} vmID={} context={}\n".format(
java_window.title, java_window.pid, self._hwnd, self._vmID, self.context
java_window.title,
java_window.pid,
self._hwnd,
self._vmID,
self.context,
)
)

Expand Down
Loading

0 comments on commit 2a74ad2

Please sign in to comment.