General XMetaL Discussion
russurquhart1 January 20, 2010 at 11:14 pm
Using python for scriptingJanuary 20, 2010 at 11:14 pmParticipants 5Replies 6Last Activity 12 years, 10 months ago
We have some groups that were interested in using python as their scripting language. Are there any examples available or has anyone out there done this? Issues? Tips?
Any info is greatly appreciated!
RussDerek Read January 21, 2010 at 1:52 am
Reply to: Using python for scriptingJanuary 21, 2010 at 1:52 am
There are no known issues that have been raised by any of our clients.
The last time I installed ActiveState's “ActivePython” engine to try it out about a year ago, special settings had to be configured to enable it to be used as a script engine. I believe this was a concern for some people on a few forum postings that I saw when looking for information on how to enable this functionality and it was also specifically warned about by the ActiveState documentation, as this also enabled it as a scripting language in Internet Explorer which meant that scripts embedded in HTML pages would be run by IE, and you may have little control over which HTML files your users might open in that application. Check the ActiveState documentation (or the documentation for your Python engine) to see if this is still an issue or if there is a way to tell the script engine to only enable itself for specific applications.
Keep in mind that you will also need to install a Python script engine on every user's machine in order for XMetaL macros written in Python to function. The script engine that supports JScript and VBScript (Windows Script Host, aka: WSH) is installed as part of Windows on all versions of Windows supported by XMetaL Author (so no additional installer needs to be run to use these languages).
I'm not aware of any XMetaL clients using Python, possibly for the reason above, We do however, have various clients that run Perl, including two major US gov't agencies that have hundreds of thousands of lines of XMetaL macro code written in PerlScript and they install the ActiveState PerlScript engine on their users machines to facilitate this (so clearly for them having to install an additional scripting engine is not an issue).Derek Read January 21, 2010 at 3:47 am
Reply to: Using python for scriptingJanuary 21, 2010 at 3:47 am
The following page seems to be the answer to what I read about previously with security concerns in IE. Specifically the following statement from the “win32com Readme”:
Python only supports “trusted” execution hosts – thus, it will no longer work as an engine inside IE (Python itself no longer has a restricted execution environment). Python continues to work fine as an Active Scripting Engine in all other applications, including Windows Scripting Host, and ASP.
There is also support for Python as an ActiveX Scripting Host.
Active Debugging seems to be fully functional.
I have not tried a recent installation of ActivePython so cannot provide specific details on what this means specifically for XMetaL Author. However, that statement suggests to me that it should work with any application other than Internet Explorer as it sounds like the engine now specifically detects if IE is the intended host for a given script and disables the engine in that case.
If you are working with another Python engine (not sure how many there are) then this will of course not apply to you and you should consult the documentation it provides if this is a concern.russurquhart1 February 16, 2010 at 10:42 pm
Reply to: Using python for scriptingFebruary 16, 2010 at 10:42 pm
We'll i've installed ActivePython, but i suspect i need something else on the Xmetal side.
The below application is dead simple, but i keep getting an error that it doesn't know MessageBox.
Do you have some sample macros that you tested? (just to see if my installation is correct?
# SoftQuad Script Language Python:
#app=WScript.Application MessageBox(“Hello world!”) ]]>Derek Read February 17, 2010 at 1:00 am
Reply to: Using python for scriptingFebruary 17, 2010 at 1:00 am
You cannot call this method directly (same as with any other scripting language including JScript and VBScript). MessageBox is a method of the Application object.
Please try this instead:
The rest of your macro syntax appears correct to me.russurquhart1 February 17, 2010 at 1:23 am
Reply to: Using python for scriptingFebruary 17, 2010 at 1:23 am
Getting closer, got an error saying Invalid Number of Parameters.
Does this ring a bell, or should i check the ActivePython to see if their MessageBox takes more parameters?
- You must be logged in to reply to this topic.