How to access to pvserver files from Python shell

In my server machine I am running pvserver:
mpiexec -np 12 pvserver

On my local machine I could easily connect to the server machine and from File > Open I could browse files on the server but when I run Python Shell (View > Python Shell) I don’t know how to access the remote files:

import os
os.getcwd() # This returns the path in the local machine not in the remote server.

How can I access remote server files from within Python Shell in the local machine?

The Python shell is designed to only operate on the client-side, so if you want to access files from your remote server you would have to go through a mapped network drive.

1 Like

Thank you for the info.
Is there a way to create an empty file on the server when browsing the remote server from the local machine?
A little bit of context —
I am trying to postprocess an OpenFOAM simulation case. In general to open OpenFOAM case I have to create manually an empty file with .foam extension, e.g: mysimulation.foam in order to open it in Paraview. So I wonder how can I create such a file in the remote server from the local machine?

Just use standard python calls.

f = open('\path\through\mapped\network\drive\mysimulation.foam', 'w')
f.close()

I don’t recommend doing any of this, however. You’re probably voiding the parallel-processing capabilities from your mpiexec call. Why must you access the files from the python shell instead of the typical way?

And if you have access to the server, why not do your file manipulation through some other means (ssh-ing through a local terminal)?

I think it is a tedious task to connect to a server using ssh …etc just to create an empty file to enable Paraview to open the simulation case from the local machine. Your suggestion of using mapped drives may works fine but in my case it not always possible to move my simulation to a mapped drive or share it on network.

Assuming you use a pvpython that is connected to a remote server, you can use the following proxy to query the remote disk in order to load files within ParaView.

Sorry, I don’t understand what do you mean load files within paraview, I executed the those code lines in pvpython but how can I access those files?

You can use reader = simple.OpenDataFile(fileToLoad) once you know the actual path of the file on the server side.

1 Like