Add remote command-line client (python -m mytk --remote / mytk-remote)#94
Merged
Conversation
Add a CLI to call a function on a running RemoteControllable app and print
the result:
python -m mytk --remote "turn_on()"
mytk-remote "add(2, 3)" --port 9000
mytk-remote --list
The call string is parsed with ast (arguments must be Python literals; no code
execution), a bare name means a no-argument call, and keyword arguments are
rejected since XML-RPC carries positional args only. --list prints the exposed
functions via remote_signatures(); --host/--port/--app-name select and verify
the target. Wired both as `python -m mytk --remote ...` (intercepted before the
example-launcher parser) and a `mytk-remote` console script.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
A command-line client for sending a single call to a running
RemoteControllableapp (from v1.6.0/1.6.1) and printing the result.Both entry points requested were added:
python -m mytk --remote ...— intercepted at the top of__main__.main()before the example-launcher argparse (which has its own-l/--list), so there's no flag collision.mytk-remote— a[project.scripts]console script (mytk.remotecli:main).Behavior
None).--listprints each exposed function and signature (viaremote_signatures()).--host/--port/--app-nameselect and verify the target (--app-nameusesconnect()'s identity check →RemoteAppMismatch).0success,1runtime error (unreachable server, remote fault),2usage/bad command/identity mismatch.Safety of the command string
Parsed with
ast, noteval— arguments must be Python literals (ast.literal_evalper arg), so no arbitrary code runs. A bare"turn_on"meansturn_on(). Keyword arguments are rejected (XML-RPC carries positional args only).Tests
New
mytk/tests/testRemoteCLI.py(10 tests): call-string parsing (no-arg, bare name, literals, rejected kwargs/non-call/non-literal), end-to-end call over a real socket printing the result + asserting the state change,--listoutput,--app-namemismatch exit code, and connection-refused handling. Full suite: 533 passed, 8 skipped.Targeted for release v1.7.0 (new feature → minor).
🤖 Generated with Claude Code