Kinook Software Forum

Go Back   Kinook Software Forum > Visual Build Professional > [VBP] Third Party Tools
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 08-14-2006, 11:12 AM
craiga craiga is online now
Registered User
 
Join Date: 08-14-2006
Posts: 2
Problem running Python script

I am trying to run a Python script and I am getting a couple different errors.

First I just try a simple 2-line script:

import marshal, os, re, sys, time
print "test"

I get this error:

8/14/2006 10:45:37 AM: --------------------Starting Build: test.bld'--------------------
8/14/2006 10:45:37 AM: Building project step 'Run Python script'...
Failed to instantiate script engine 'Python': Invalid class string
8/14/2006 10:45:37 AM: Step 'Run Python script' failed
8/14/2006 10:45:37 AM: Build ended.


When I run a more substantial script (pasted in below) I get this error, which I assume has to do with the brackets. I tried doubling up the brackets for accessing the Python dictionary object but then I get the "invalid class string" error.

8/14/2006 10:40:03 AM: --------------------Starting Build: 'Test.bld'--------------------
8/14/2006 10:40:03 AM: Building project step 'Check for opened P4 files under '...
Error expanding macros or script in property Script: <Error parsing macros: Unrecoverable Parse Error at position 373 - expecting macro_name>
8/14/2006 10:40:03 AM: Build ended.

By the way giving the character position of the parse error is not very helpful, since the script editor does not display the character position, only the row and column of the cursor.


Below is the script that gets the Unrecoverable Parse error. If I double up the brackets, then I get the first error ("Failed to instantiate script engine 'Python': Invalid class string"). Both these scripts run fine when run directly from Python.

import marshal, os, re, sys, time

p4changes = 'p4 -G opened'
stream = os.popen(p4changes, 'rb')
nReturn = 0;

try:
while 1:
dict = marshal.load(stream)
if(dict["depotFile"].find("//somedepot/somefile/")):
print dict["depotFile"]
nReturn = 1;
except EOFError: pass

sys.exit(nReturn)
Reply With Quote
  #2  
Old 08-14-2006, 04:32 PM
kinook kinook is online now
Administrator
 
Join Date: 03-06-2001
Location: Colorado
Posts: 6,034
Python needs to be registered as an Active Script / Windows Script Host engine to use it from VBP scripting [1]. I believe ActivePython [2] must be used, including the 'Python for Windows Extensions' option when installing.

Also, VBP will not capture language-specific output (i.e., print) statements; you would need to use WScript.Echo or Builder.LogMessage to send output to VBP. And you do need to double up bracket characters so they will not be interpreted by VBP as a script expression [3].

Another option would be to invoke Python directly (not using Active Scripting) from a Run Program action.

[1] http://www.visualbuild.com/Manual/script.htm
[2] http://www.activestate.com/Products/ActivePython/
[3] http://www.visualbuild.com/Manual/scriptexpressions.htm
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



All times are GMT -5. The time now is 11:20 PM.


Copyright © 1999-2023 Kinook Software, Inc.