Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
Pythonista REPL, script execution, etc Help
-
Hi All,
I've noticed a serious lack of attention to some of the work that I've been trying to do for Pythonista (i.e. Modal boxes), and I have recently had a renewed faith in getting it completed, amongst other ideas.
One of the ideas that I had was a helper app, one that would have links to many of the amazing scripts/modules posted here and/or hosted on github, to allow them to be installed (either in the current project or site-packages, as required).
The concept is simple enough, with dulwich and github3 I have almost everything covered, allowing the use of gists and full packages.
However - I have been putting additional effort into the WebIDE app, as I do enjoy working with PyCharm, its a little faster than using git, but in the same respect if I could create a deeper integration with PyCharm I would be able to work a lot more effectively, and further to that it would help me along with another project I have going which is to setup a compatible ui library for OSX (Windows as well, but after OSX is underway).
This would allow me/anyone to develop Pythonista apps on a laptop as well as iDevices.
However, my ability to get this done is contingent on being able to inspect / review things from a working Pythonista installation.
Note: I would use the app template to develop an app to help me, but this only supports Python 2.7, and until omz gets the time to support py3, there are limitations for me.
-
Has anyone successfully setup a python REPL within Pythonista?
Ideally, I want to create a Paramiko based SSH Service, with a limited subset of commands, one of them being 'python' to open a virtual REPL. -
If not, can anyone think of a way to hook into the Python interpreter included with Pythonista? Perhaps using objc_util or something, using stdin/stdout redirection via StringIO?
-
For WebIDE, I setup the ability to 'run' (test) a script that I am working on using runpy, and it works, but I've not used it extensively to see if there are any major limitations or not, if anyone has any better methods of using it, especially one that would allow me to send command line arguments to the script without having to submit modified global() (i.e. forcibly setting sys.argv - which I've not tried yet) I'd love to hear it.
Sorry about the oversharing of information, but sometimes a little conext helps to direct the responses a bit.
Please let me know if anyone can provide any sort of information, code, references, links, ANYTHING really to help me along with getting a remote REPL working with Pythonista.
Regards,
Michael
P.S. Doing this would also help me with another phase of the project, dulwich + webserver + custom git hook (manually installed; not via GH/BB) to ping a waiting Pythonista app to update from the remote, coupled with Working Copy/Clone this would be a very clean way to dev via laptop.
-
-
In beginning to answer my own question - I looked at how Stash handles REPL.
I may copy that concept but I wanted to see if anyone else had a better idea, and/or if anyone had an idea of actually integrating stash as the shell for a Paramiko SSH Server.
That alone may solve majority of the problems I have.
[EDIT]
Okay, updated request - can anyone assist me with sample code (beyond the paramiko sample server) and / or provide some feedback on the "proper" way to setup an SSH server?
Looking at the code module, I can use the InteractiveInterpreter.runsource() with (I hope) launch_stash.py to provide a more than sufficient SSH "shell" for Pythonista/others to use.
It would also allow the developers to run/test code etc. Thanks in advance
[END EDIT]
-
@reticulated dulwich on pythonista should be able to run a git server, if you want to go that route (I think I tried it once), then you can git into your pythonista repo.
Someone developed a webide based server that lets you edit/run code on pythonista.
https://forum.omz-software.com/topic/2714/webide/12 -
It should be possible to hook into pythonista via objc, also. Do you want more of stash/file access, or more ability to run/debug/introspect similar to console?
-
I also setup the ability to run in WebIDE (It was authored by someone here), using runpy.
It works with the exception that I can’t (to my knowledge) pass arguments.
I will figure it out - now I have finally setup a new dev machine (iPad Pro 12.9) so I have plenty of screen real estate to keep research open beside the IDE.
Thanks for your help.
Regards,
Michael
-
@reticulated To pass arguments, you can modify
sys.argv
before callingrunpy.run_...
.
Edit: Also, for running a python REPL, you can use thecode
module.