pvpython how to run startup script

When I run pvpython, it does not initialize with the famous "from paraview.simple import * ".

Is there a way to execute a series of commands when we start up pvpython? Examples are above, or setting a “Reverse Connection” in order to connect to a back end server.

@utkarsh.ayachit @cory.quammen

I’ve been placing from paraview.simple import * at the top of my pvpython scripts

pvpython is simply a standard Python interpreter. I don’t think we should do much more than that standard Python interpreter does. It’s best for users to realize that it is a standard Python interpreter and treat it as such.

The reason for the question is I am trying to create scripts that automate pvpython connecting to a backend server. I would prefer not having the user be forced to type the Reverse Connection command. This is a request from Greg W.

Just write the following at the top of your script

from paraview.simple import *
ReverseConnect()

# [...]

See Reverse connection

Seb,
This is for other users. Thus, if I hard code pvpython with a script (of mine), users won’t then be able to run their own script. What I’m trying to do is create a client, and server pair of scripts that allow a user to run pvpython2cluster (with all of the magic hidden). If I am then passing in a script under the covers, users then won’t be able to do pvpython2cluster usersScript. Or, am I missing something?

I think you can load another script from the args and execute it inside your context…

You can obviously create an alias or equivalent of the first part of such command line:

pvpython wait-cluster.py user-script.py

Seb, that doesn’t work. Correct, wait-cluster executes, then user-script executes, works. However, if we run wait-cluster.py, Python ends and we get a command prompt back. This is correct behavior normally, but not in this case.

Try pvpython -i wait-cluster.py. That will keep you in the Python interpretter after wait-cluster.py executes.

That was the trick. Thanks Cory!