[pythonvis] Running scripts from EdSharp

  • From: "Richard Dinger" <rrdinger@xxxxxxxxxx>
  • To: <pythonvis@xxxxxxxxxxxxx>
  • Date: Mon, 26 May 2014 07:30:40 -0700

Preliminary: How to run Python scripts from inside EdSharp

I have been snooping around in EdSharp trying to determine how to use the 
various forms of the f5 command to execute the script from within the editor.  
This document describes what I have found so far.  If anyone has additional 
information, please share it by responding to this message.

Warning while experimenting, I occasionally caused my machine to lock up and 
ctrl+alt+delete took a long time to regain control of the machine -- so be 
careful.

First, get your EdSharp editor set up for Python.  Select Python via the 
shift+ctrl+f5 command and select any options you want from the configuration 
command shift+alt+c or leave the default values for now if you don't know what 
the option means.  See more on options in the following.

As I currently understand it, there are three forms of the editor's f5 command 
that execute your script.  The first is just f5 or the run command, which 
simply runs your source file via the Windows run command.  That is the same as 
hitting enter on the file name in Windows Explorer.

When using f5 including a raw_input('enter to continue') call at the end of 
your script will hold output on screen until you type enter.      You can then 
examine the output via the jaws cursor.  If there is an error, however, you may 
not hear anything and nothing is on screen just like Windows Explorer.

The second form of the editor's f5 command is alt+f5 or the prompt command.  
This appears to run the command line in the prompt tag in your configuration 
(shift+alt+c).  For python installed at c:\python27 I set this to:
c:\python27\python.exe %Source% 2>&1

The %Source% is an environment variable with the current editor file path.  
When you run alt+f5 a dialog with this prompt comes up so you can add command 
line arguments or make some other change before running it.  The output goes to 
attempt file accessible via shift+alt+f5.  The temp can be dismissed via 
ctrl+f4.

Warning: Do not leave off the 2>&1 output redirection or your machine may lock 
up!  I don't know if you can direct to another file of your choice as I have 
not tried that out.

The last form of the f5 command is ctrl+f5 or the compile command..  This also 
requires some set up in the configuration file (shift+alt+c).  I am using the 
same text as the prompt above, but for the compile tag in the configuration:
c:\python27\python.exe %Source% 2>&1

The differences I know of between prompt and compile are:
- prompt gives you a chance to change the command
- compile speaks the output and the errors
- compile positions the editor at the error

Both save output to a temp file, type shift+alt+f5 to bring up the temp file 
containing output and errors.  Type ctrl+f4 to dismiss the temp file window.

A problem with alt+f5 and ctrl+f5 is using the raw_input function yields an EOF 
error instead of waiting for you to hit enter.  Jamal, the author of EdSharp is 
looking into this problem.  And I find shift+alt+f5 a little clumsy to bring up 
the temp file.

While EdSharp may not eliminate the need for a command shell running, the 
editor does provide some options.

Richard

Other related posts: