I'd like to have an xterm-compatible virtual terminal running inside a Python app.
I'll need to run ncurses-based applications inside it, feed it with user's input and read its output.
So far I've found python-vte, but it only provides a GTK+ widget (libvte has the required VtePty class, but Python bindings don't) and has an unacceptable libgtk dependency.
Is there any other way to perform a teminal emulation in Python?
After all, I've found the pyte, which is exactly what I wanted.
Have you looked at this VT100 terminal emulator, also described in blog form here? It's not an xterm emulator, but perhaps it can be leveraged for your purposes.
I have been running a Rails Tutorial site & have deployed Gateone terminal emulator for users to execute commands. Later we devloped our own Terminal emulation. Check http://github.com/pocha/terminal-codelearn .
If you just need to execute command as a user, then probably you just need http://docs.python.org/2/library/pty.html
Related
I've scoured the interwebs and couldn't find anything with python, android, and "shortcut" or "home-screen" to appear on the same page. I have pydroid3 installed, working great. I'd like to have a shortcut (ideally on the home-screen) that I can tap once and have it run without opening the IDE for editing.
Making a shortcut to the file, or opening a source file in the file manager will at best just open it in the pydroid3 IDE, at worst state "this file type is not supported."
At the beginning of the script, I have tried putting "#!/user/data/../pydroid_dir/python", but alas the OS doesn't realize I mean to run it directly in the python interpreter. Any solutions or alternative lines of thinking are appreciated!
EDIT
I'm running an unrooted android 9 PIE. I wanted to provide some more details but not quite a solution for any readers. Check out related question: How to create a homescreen shortcut to launch a shell script?. Closest I got was trying SManager which allows you to create a homescreen shortcut to a shell script. Your shell script could be hardcoded to call python on your script:
/path/to/python /path/to/python/script
Unfortunately, if you're phone is not rooted, you may not have permission to execute whatever version of python you're calling outside of the context of the app it was installed for. Also, you have to ensure that your shell and python scripts reside in an appropriate place for execution. If your phone is rooted, SManager seems to have options to let you run the script as root.
pydroid3 allows me to run scripts residing on my internal storage as well as lets them read and write files at that location. That's why I was hoping that there was a pydroid way to create a shortcut (or an alternative python app that does this) since it has appropriate privileges.
QPython OL lets you create home screen shortcuts to python scripts on Android. First tap on the 'Q' icon at the top of the main screen (it took me a while to realise this was a button), then long-press on the script you want. This should give you a prompt to create a shortcut, as in the screenshots below.
QPython 3L also claims to have similar functionality when you long-press a script in its 'Programs' section. At time of writing (Jun 20) this seems to be broken.
I've not tried Pydroid myself, but haven't come across anything claiming it could create script shortcuts either.
You can use Termux:Widget as a command line to execute a python script. In Termux you can not create GUI with tkinter. You have to launch X-Server with VNC Mobile client. The widget is like a small shell prompt.
I wish to run some commands which are specifically made for command line interface in idle environment.
There is a library in python called "Ezflix" which is for streaming torrent videos.
It runs properly on command line interface but does not work when I run it on python idle.
I know that command line commands cant be used in idle but I just wish to find if there is any possibility or any hack to make it run on idle.
According to https://pypi.org/project/ezflix/, ezflix is a "command line utility", one which happens to be written in Python. At this level, it is intended to be run from a command line terminal/console.
Such a program, even if written in python, might not be a Python library module, meaning that it is not intended that you import it and directly access its functions. If this is true, it would not have a supported and documented application program interface (API). If so, one could read the code and import it anyway, but the private internal objects and names might change from version to version. So the best way to access it from a Python program would be to run it separately, for instance, with subprocess, as suggested in the comments.
It turns out the ezflix does have a documented API and so it is also a library module. The is briefly described at the bottom of the pypi page linked above.
from ezflix import Ezflix
ez = Ezflix(<arguments>)
...
I presume that the package itself contains more information on its usage.
None of the above has anything to do with whether you run your program directly with python or with IDLE or with any other IDE. What could matter is whether the ezflix user interface specifically requires that it be run connected to the system terminal/console. Noting I saw on its pypi page suggests this. It might also be that the movie player window somehow interferes with the IDLE GUI window, but I also do not expect this.
I've just started using PyCharm, and am consistently pleasantly surprised by its tools and configurability. I know that in PyCharm, you can load code from the editor into a Python console (see https://www.jetbrains.com/pycharm/webhelp/loading-code-from-editor-into-console.html). However, the remote console I'm using in PyCharm is very slow.
If I access python on the remote machine directly via ssh, it has no performance issues. As such, I'd like to just open the remote version of python via PyCharm's Terminal, and execute code in the terminal from my editor.
However, I haven't found any key bindings (or options) that let me automatically load code -- it's a manual copy and past process for now. When I try to create a keyboard shortcut to do this, the option isn't available. Is there a method to create a keyboard shortcut to load code from the editor into the terminal?
The only way to create such a shortcut by yourself is by writing a plugin to PyCharm. PyCharm plugins are written in Java, so I don't know whether this sounds like an appealing option for you. Alternatively, you can file a feature request at http://youtrack.jetbrains.com/ asking for this feature to be added.
Note that you can set up a run configuration that will run your code for you on a remote interpreter without going through a console. Have you tried this? Is it also slow?
I want to generate an Eclipse plugin that just runs an existing Python script with parameters.
While this sounds very simple, I don't think it's easy to implement. I can generate a Eclipse plugin. My issue is not how to use PDE. But:
can I call the existing Python script from Java, from an Eclipse plugin?
it needs to run from the embedded console with some parameters
Is this reasonably easy to do? And I don't plan to reimplement it in any way. Calling it from command-line works very well. My question is: can Eclipse perform this, too?
Best,
Marius
You can already create an External Launch config from Run>External Tools>External Tools Configurations. You are basically calling the program from eclipse. Any output should then show up in the eclipse Console view. External launch configs can also be turned into External Builders and attached to projects.
If you are looking to run your python script within your JVM then you need a implementation of python in java ... is that what you are looking for?
I've been trying to find this information online but I'm not getting the answer.
I've used RStudio and Geany for editing files before. Now I'm trying to use ViM to edit python and R files (I know there's RPy, but nothing to do with my problem).
I would like to know how can I have 3 terminals (could also be vim buffers, or screen windows) with one running ViM and the others running R and Python. When I execute a Python script, the terminal (window or buffer) with python shows the output. The same when I run R scripts.
I would appreciate insight on this as this is something that's keeping me from using ViM regularly. I would also consider a solution with terminator terminal multiplexer or guake terminal. Any information about sending code for scripting from one instance to another is welcome.
Are you looking for a way to have a REPL inside Vim? If so, Vim wasn't really designed with that in mind, though there are some plugins that try. Conque is an example.
Some things I use to have a quicker code/run/test iteration with Python:
IPython's %edit feature, which starts editing a script with $EDITOR and will run the script after you exit.
vim-ipython which can send/execute/recieve code via an IPython interpreter.
tmux which allows you to have multiple shells side by side, but with little interaction between them.
Vim-slime is a general-purpose solution to this I'm pretty happy about, it will send blocks of code to any tmux pane, meaning it works for any language.
https://github.com/jpalardy/vim-slime
Your requirements for online information may not have been spelled out in enough detail, since I seem to find a wealth of information on using ViM as an IDE for both R and Python:
R:
http://www.r-bloggers.com/r-with-vim/
http://www.vim.org/scripts/script.php?script_id=2628
http://www.vim.org/scripts/script.php?script_id=1048
Python:
http://wiki.python.org/moin/Vim
http://blog.dispatched.ch/2009/05/24/vim-as-python-ide/
http://dancingpenguinsoflight.com/2009/02/python-and-vim-make-your-own-ide/
Have a look at vim-ipython, a plug-in for Vim.
You need to download the source (linked above), and run the Vim command :source path/to/file/ipy.vim.
Start by running a new IPython session (e.g. using IPython qtconsole or IPython notebook) and then type :IPython into Vim. Your Vim is now connected to the IPython instance you just opened.
You can press F5 to run the whole python script in your Vim, or Ctrl+s to run the current line. Ctrl+s will also run whatever is selected if you're in visual (i.e. 'select') mode.