generated from BrianPugh/python-template
-
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
33 changed files
with
927 additions
and
895 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,12 @@ | ||
from .main import app | ||
from belay.cli._cache import cache_app | ||
from belay.cli._clean import clean | ||
from belay.cli._exec import exec | ||
from belay.cli._info import info | ||
from belay.cli._install import install | ||
from belay.cli._new import new | ||
from belay.cli._run import run | ||
from belay.cli._select import select | ||
from belay.cli._sync import sync | ||
from belay.cli._terminal import terminal | ||
from belay.cli._update import update | ||
from belay.cli.main import app |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
from typing import Optional | ||
|
||
from belay import Device | ||
from belay.cli.common import remove_stacktrace | ||
from belay.cli.main import app | ||
|
||
|
||
@app.command | ||
def exec(port: str, statement: str, *, password: Optional[str] = None): | ||
"""Execute python statement on-device. | ||
Parameters | ||
---------- | ||
port: str | ||
Port (like /dev/ttyUSB0) or WebSocket (like ws://192.168.1.100) of device. | ||
statement: str | ||
Statement to execute on-device. | ||
password: Optional[str] | ||
Password for communication methods (like WebREPL) that require authentication. | ||
""" | ||
kwargs = {} | ||
if password is not None: | ||
kwargs["password"] = password | ||
with Device(port, **kwargs) as device, remove_stacktrace(): | ||
device(statement) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
from typing import Optional | ||
|
||
from belay import Device | ||
from belay.cli.main import app | ||
|
||
|
||
@app.command | ||
def info( | ||
port: str, | ||
*, | ||
password: Optional[str] = None, | ||
): | ||
"""Display device firmware information. | ||
Parameters | ||
---------- | ||
port: str | ||
Port (like /dev/ttyUSB0) or WebSocket (like ws://192.168.1.100) of device. | ||
password: Optional[str] | ||
Password for communication methods (like WebREPL) that require authentication. | ||
""" | ||
kwargs = {} | ||
if password is not None: | ||
kwargs["password"] = password | ||
with Device(port, **kwargs) as device: | ||
version_str = "v" + ".".join(str(x) for x in device.implementation.version) | ||
print(f"{device.implementation.name} {version_str} - {device.implementation.platform}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
from pathlib import Path | ||
from typing import Optional | ||
|
||
from belay import Device | ||
from belay.cli.common import remove_stacktrace | ||
from belay.cli.main import app | ||
|
||
|
||
@app.command | ||
def run( | ||
port: str, | ||
file: Path, | ||
*, | ||
password: Optional[str] = None, | ||
): | ||
"""Run file on-device. | ||
If the first argument, ``port``, is resolvable to an executable, | ||
the remainder of the command will be interpreted as a shell command | ||
that will be executed in a pseudo-micropython-virtual-environment. | ||
As of right now, this just sets ``MICROPYPATH`` to all of the dependency | ||
groups' folders. | ||
.. code-block:: console | ||
$ belay run micropython -m unittest | ||
Parameters | ||
---------- | ||
port: str | ||
Port (like /dev/ttyUSB0) or WebSocket (like ws://192.168.1.100) of device. | ||
file: Path | ||
File to run on-device. | ||
password: Optional[str] | ||
Password for communication methods (like WebREPL) that require authentication. | ||
""" | ||
kwargs = {} | ||
if password is not None: | ||
kwargs["password"] = password | ||
|
||
content = file.read_text() | ||
with Device(port, **kwargs) as device, remove_stacktrace(): | ||
device(content) |
Oops, something went wrong.