-
Notifications
You must be signed in to change notification settings - Fork 299
Added support for executing remote commands through the command line. #28
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
Conversation
dov
commented
Apr 4, 2017
- Added text flag to ws.write for sending text (terminal) messages.
- Rewrite of help.
- Rewrite of parsing.
@@ -36,13 +36,14 @@ def __init__(self, s): | |||
self.s = s | |||
self.buf = b"" | |||
|
|||
def write(self, data): | |||
def write(self, data, text=False): | |||
OpCode = 1 if text else 2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Codestyle: you violate both PEP8 and convention of this file (which of course uses standard_python_style).
webrepl_cli.py
Outdated
l = len(data) | ||
if l < 126: | ||
# TODO: hardcoded "binary" type | ||
hdr = struct.pack(">BB", 0x82, l) | ||
hdr = struct.pack(">BB", 0x80+OpCode, l) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PEP8 violation: spacing around operators.
print(" %s script.py 192.168.4.1:/another_name.py" % exename) | ||
print(" %s script.py 192.168.4.1:/app/" % exename) | ||
print(" %s 192.168.4.1:/app/script.py ." % exename) | ||
exename = os.path.basename(sys.argv[0]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rewrite of help.
That maybe even nice (maybe not), but definitely can't be part of a commit with the description "Added support for executing remote commands through the command line.". One commit - one logical change. Each change should be grounded (i.e., there should be arguments why change is needed).
Thanks for the submission, but the patch has multiple issue. Are you aware that there're other tools which already implement (should implement IIRC) this functionality? |
Thanks for the comments, and for webrepl! I admit that the changes in this pull request was more of a sloppy hack for learning how to communicate with the esp8266, but I thought that there is no harm in trying to contribute it back. Let me know if you think whether you think my patch in within the scope of how you envision webrepl_cli and I'll make the effort to clean it up. If not, that's fine with me as well. |
We, MicroPython maintainers, are trying to concentrate on the core interpreter and libraries. So, as long as there're community utility/tooling projects, our preference is to save maintenance efforts on our side, and vice-versa, encourage their further development and maintenance on community side. So, I'd really recommend to see if there's a tool which already suits your needs among those listed in https://forum.micropython.org/viewtopic.php?f=16&t=1908 (and on that forum in general), and if you see opportunity to improve them/it, to contribute to them instead. |
I understand and I accept this policy, but I have a few comments:
If I were to address the latter two issues in code style complient separate pull requests, would that be more acceptable? |
Is there another terminal client with this feature? I’d love to see a version of this merged. |
* Added text flag to ws.write for sending text (terminal) messages. * Rewrite of help. * Rewrite of parsing.
I just updated my master branch, and added the following functionality:
The python interface is just as simple. Here is the same command from python: from webrepl_cli import WebreplCLI
wc = WebreplCLI(host = '192.168.1.220',
password = 'secret')
print(wc.command('machine.Pin(15,machine.Pin.IN).value()')) A nice usage for the RPC is to create a few commands in def d8():
return machine.Pin(15,machine.Pin.IN).value()) And then you can just do RPC to this method:
This is obviously more useful for more complex functions. Since my previous pull request was ignored without explanation during the last four years, I doubt that there will be any interest in merging this either. If there were, I'd separate this change into at least three separate commits/pull requests:
|
I closed this pull request, in order to free up my master branch for additional work. If there is any interest, I'll be happy to open a new pull request based on a different branch. |