tags:

views:

477

answers:

9

This may sound strange, but I need a better way to build python scripts than opening a file with nano/vi, change something, quit the editor, and type in python script.py, over and over again.

I need to build the script on a webserver without any gui. Any ideas how can I improve my workflow?

+6  A: 

You should give the screen utility a look. While it's not an IDE it is some kind of window manager on the terminal -- i.e. you can have multiple windows and switch between them, which makes especially tasks like this much easier.

bluebrother
I like tmux better than screen.
Yktula
+5  A: 

You can execute shell commands from within vim.

voyager
+1  A: 

You could run XVNC over ssh, which is actually passably responsive for doing this sort of thing and gets you a windowing GUI. I've done this quite effectively over really asthmatic Jetstart DSL services in New Zealand (128K up/ 128K down =8^P) and it's certainly responsive enough for gvim and xterm windows. Another option would be screen, which lets you have multiple textual sessions open and switch between them.

ConcernedOfTunbridgeWells
+3  A: 

Using emacs with python-mode you can execute the script with C-c C-c

hiena
+9  A: 

put this line in your .vimrc file:

:map <F2> :w\|!python %<CR>

now hitting <F2> will save and run your python script

anteatersa
great, thanks! it's like F8 Build ;)
Henrik P. Hessel
very helpful, thx!
timepilot
+1  A: 

When working with Vim on the console, I have found that using "tabs" in Vim, instead of having multiple Vim instances suspended in the background, makes handling multiple files in Vim more efficient. It takes a bit of getting used to, but it works really well.

ayaz
A: 

Well, apart from using one of the more capable console editors (Emacs or vi would come to mind), why do you have to edit it on the web server itself? Just edit it remotely if constant FTP/WebDAV transfer would seem to cumbersome.

Emacs has Tramp Mode, gedit on Linux and bbedit on the Mac support remote editing, too. Probably quite a large number of other editors. In that case you would just edit in on a more capable desktop and restart the script from a shell window.

mhd
+3  A: 

you can try ipython. using its edit command, it will bring up your editor (nano/vim/etc), you write your script, and then on exiting you're returned to the ipython prompt and the script is automatically executed.

Autoplectic
+1  A: 

There are actually 2 questions. First is polling for a console IDE for python and the second is a better dev/test/deploy workflow.

For while there are many ways you can write python code in the console, I find a combination of screen, vim and python/ipython is the best as they are usually available on most servers. If you are doing long sessions, I find emacs + python-mode typically involves less typing.

For a better workflow, I would suggest setting up a development environment. You can easily setup a Linux VM on your desktop/laptop easily these days - there isn't a excuse not to even if it's for hobby projects. That opens up a much larger selection of IDEs available to you, such as:

I would also setup a SCM to keep track of changes so that you do better QA and use it to deploy tested changes onto the server.

For example I use Mercurial for my pet projects and I simply tag my repo when it's ready and update the production server to the tag when I deploy. On the devbox, I do:

  • (hack hack hack, test test test)
  • hg ci -m 'comment'
  • hg tag
  • hg push

Then I jump onto the server and do the following when I deploy:

  • hg update
  • restart service/webserver as needed
Lester Cheung