hot to Run Python 2.5 scripts from python (for automating PSSE)

735 views
Skip to first unread message

Janath

unread,
May 22, 2012, 10:07:37 PM5/22/12
to web...@googlegroups.com
I have written python scripts to automate PSSE (Siemens power system simulation tool) using the pythonAPI provided.

I can run them using the gui I have made for python 2.5. 

Psse 32 needs the exact version of python (2.5) to run the API.

I am trying to convert my application to a web based application using web2py. I am unable to use API statements from web2py.

I think, if I can run the python 2.5 and get the outputs to web2py, I will be able to do that.

Can someone give me a hand to do that.... also, better workarounds are welcome.

Thank you,

Massimo Di Pierro

unread,
May 23, 2012, 10:17:46 AM5/23/12
to web...@googlegroups.com
Can you point us to some code?

Janath

unread,
May 23, 2012, 1:50:41 PM5/23/12
to web...@googlegroups.com
when following runs at the initialisation, even the web2py server goes down. the line in the bold face, tries to initialise psse and make trouble. for me it seems, that psse needs the exact version (which is 2.5) to run the api commands. 
(I am not sure whether it checks the registry entry for particular python version)

def index():
    import os,sys
    #import psspath
    mymodule = local_import('pssepath')
    sys.path.append('C:\\Program Files (x86)\\PTI\PSSE32\\PSSBIN')
    import psspy
    import win32gui
    mymodule.add_pssepath()
    try:
        ierr=psspy.psseinit(80000)
        if ierr:
            print "can not initiate psse! quits"
            #raise SystemExit(" can not load case")
    except SystemExit:
        pass 



thank you,
Janath

Derek

unread,
May 23, 2012, 5:13:23 PM5/23/12
to web...@googlegroups.com
Then it is an unhandled exception. Which one? Run it in debug mode and see if you can get the stack trace.

Janath

unread,
May 25, 2012, 11:35:11 PM5/25/12
to web...@googlegroups.com
I am afraid I was unable capture the stack. 

any clue as to how I can run a python process and keep communicating with it during execution of web2py forms. If so I can send and receive the commands and data to webpy.

Thank you,
Janath

Janath

unread,
May 30, 2012, 12:41:57 AM5/30/12
to web...@googlegroups.com
trying to be more specific :)

I am trying to see if I can start a python 2.5 shell (from within web2py) and execute some commands to receive the results back to web2py.

is there any way of doing that, or should I drop that idea. If it sounds not possible at this time with web2py, or if it takes some extensive time consuming programming I am happy to drop that idea to seek for some other way of getting the work done.

please advice.

howesc

unread,
May 31, 2012, 11:14:30 AM5/31/12
to web...@googlegroups.com
i don't know anything about the PSSE system, but i'm confused.  is there a PSSE server that you communicate with over a socket to make the API calls?  the traditional API model is that there is a long running "server" process, and the client (in this case the web2py server) connects to some socket and invokes the API calls.  is this what you are doing?

or is what you are doing using a PSSE python lib to connect to some PSSE server?  in this case you should be able to use the PSSE lib from within web2py.  perhaps you just need to run web2py using the version of python that the PSSE lib requires (i use web2py on python2.5 all the time for google app engine apps that i have not yet upgraded to python2.7, it's still supported!)

hope that helps some!

Janath

unread,
May 31, 2012, 7:23:49 PM5/31/12
to web...@googlegroups.com

Thank you for the reply.


I am on doing last method of your list.

“just need to run web2py using the version of python that the PSSE lib requires (i use web2py on python2.5


This api needs it to be run in python 2.5 ( It doesn’t work for other versions of python I have tested for 2.3) . If I can start web2py in python 2.5 which is already installed in my computer, then it will be fine (as I use the same to run psse). Because I guess it checks the registry info for the particular python version.

 

Also do you think I can try making the python version to 2.5 in web2 py, but I don’t know how to do it.

Christian Foster Howes

unread,
May 31, 2012, 7:55:39 PM5/31/12
to web...@googlegroups.com, Janath
i start we2py with:

python2.5 web2py.py -a <my admin password>

note that i have python2.5 on my path. i'm also running the source
distribution.

is that what you needed to get the python version for web2py?

cfh

On 5/31/12 16:23 , Janath wrote:
>
>
> Thank you for the reply.****
>
> I am on doing last method of your list.****
>
> “just need to run web2py using the version of python that the PSSE lib
> requires (i use web2py on python2.5****
>
> This api needs it to be run in python 2.5 ( It doesn’t work for other
> versions of python I have tested for 2.3) . If I can start web2py in python
> 2.5 which is already installed in my computer, then it will be fine (as I
> use the same to run psse). Because I guess it checks the registry info for
> the particular python version.****
>
> ** **
>>>>>> *ierr=psspy.psseinit(80000)*

Janath

unread,
Jun 1, 2012, 2:00:40 AM6/1/12
to web...@googlegroups.com, Janath
Excellent! it works...

When web2py is started in python shell, PSSE sees the initialisation commands from the python shell and it accepts it!
Reply all
Reply to author
Forward
0 new messages