Skip to content

Commit

Permalink
Merge pull request #37 from saleae/develop
Browse files Browse the repository at this point in the history
Update to 1.0.7
  • Loading branch information
huffman authored Dec 12, 2023
2 parents 76ef6a4 + d424d05 commit c30da69
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 11 deletions.
2 changes: 1 addition & 1 deletion python/BUILD.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Run the following commands to generate a distributable source package:

```
python -m pip install --upgrade build
python -m build --dist
python -m build --sdist
```

### Why not .whl?
Expand Down
5 changes: 5 additions & 0 deletions python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ Documentation can be found at https://saleae.github.io/logic2-automation/

## Changelog

### 1.0.7

- Fix builds not building with hatchling 1.19.0.
- Add option for setting gRPC port.

### 1.0.6

- Moved `grpcio-tools` to build dependencies.
Expand Down
4 changes: 2 additions & 2 deletions python/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "logic2-automation"
version = "1.0.6"
version = "1.0.7"
authors = [
{ name="Saleae, Inc.", email="[email protected]" },
]
Expand Down Expand Up @@ -40,7 +40,7 @@ include = [
"/saleae/grpc",
]

[tool.hatch.build.force-include]
[tool.hatch.build.targets.sdist.force-include]
"../proto/saleae/grpc/saleae.proto" = "proto/saleae/grpc/saleae.proto"

# The gRPC/protobuf files are only generated when building a wheel
Expand Down
13 changes: 9 additions & 4 deletions python/saleae/automation/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,16 +314,18 @@ def cleanup():

@classmethod
def launch(cls,
application_path: Optional[Union[Path, str]] = None,
application_path: Optional[Union[Path, str]] = None,
connect_timeout_seconds: Optional[float] = None,
grpc_channel_arguments: Optional[List[Tuple[str, Any]]] = None) -> 'Manager':
grpc_channel_arguments: Optional[List[Tuple[str, Any]]] = None,
port: Optional[int] = None) -> 'Manager':
"""
Launch the Logic2 application and shut it down when the returned Manager is closed.
:param application_path: The path to the Logic2 binary to run. If not specified,
a locally installed copy of Logic2 will be searched for.
:param connect_timeout_seconds: See __init__
:param grpc_channel_arguments: See __init__
:param port: Port to use for the gRPC server. If not specified, 10430 will be used.
"""

Expand Down Expand Up @@ -357,7 +359,10 @@ def fail(reason: str):
if not os.path.exists(logic2_bin):
fail(f'application path "{application_path}" does not exist')

process = subprocess.Popen([logic2_bin, '--automation', '--automationPort', str(_DEFAULT_GRPC_PORT)],
if port is None:
port = _DEFAULT_GRPC_PORT

process = subprocess.Popen([logic2_bin, '--automation', '--automationPort', str(port)],
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL)

Expand All @@ -383,7 +388,7 @@ def fail(reason: str):

return cls(
address=_DEFAULT_GRPC_ADDRESS,
port=_DEFAULT_GRPC_PORT,
port=port,
logic2_process=process,
connect_timeout_seconds=connect_timeout_seconds,
grpc_channel_arguments=grpc_channel_arguments)
Expand Down
9 changes: 6 additions & 3 deletions python/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
def pytest_addoption(parser):
parser.addoption('--use-existing', action='store_true')
parser.addoption('--app-path', action='store')
parser.addoption('--port', action='store', type=int)

@pytest.fixture
def asset_path() -> str:
Expand All @@ -16,13 +17,15 @@ def asset_path() -> str:
@pytest.fixture(scope='session')
def manager(request):
app_path = request.config.getoption('--app-path')

port = request.config.getoption('--port')
if app_path is not None:
with saleae.automation.Manager.launch(app_path) as mgr:
with saleae.automation.Manager.launch(app_path, port=port) as mgr:
yield mgr
pass
elif request.config.getoption('--use-existing'):
with saleae.automation.Manager.connect(port=10430) as mgr:
with saleae.automation.Manager.connect(port=port) as mgr:
yield mgr
else:
with saleae.automation.Manager.launch() as mgr:
with saleae.automation.Manager.launch(port=port) as mgr:
yield mgr
1 change: 0 additions & 1 deletion python/tests/load_save_test.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import os.path
from tkinter import E

import saleae.automation

Expand Down

0 comments on commit c30da69

Please sign in to comment.