I'm afraid there isn't a way to get the name of the python file that is currently executing. Paraview reads the contents for the file into a string and passes the string to the interpreter, so python has no association between the string and the file. As a feature request, I think it would be reasonable to have paraview set the __file__ variable to be the name of the file before executing it.<br>
<br>Pat<br><br><div class="gmail_quote">On Wed, Jun 9, 2010 at 5:15 PM, <span dir="ltr"><<a href="mailto:m.c.wilkins@massey.ac.nz">m.c.wilkins@massey.ac.nz</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<br>
Hi,<br>
<br>
I would like to find the location of the currently running python<br>
plugin macro. This is so I can do an import of a library that lives<br>
in a directory relative to the directory where all my paraview plugins<br>
live. Is this possible?<br>
<br>
In a normal python programme sys.argv[0] can help me, but ofcourse<br>
that just points to the paraview binary in this case. os.getcwd() is<br>
no use. The info is known to paraview (for instance it is in<br>
~/.config/ParaView/ParaView3.8.0.ini file under the [PythonMacros]<br>
section - but I really don't want to go trolling through that file).<br>
<br>
I have quite a few plugins, and I want to do the correct thing by<br>
breaking some of the shared functionality out into a module.<br>
<br>
Thanks for any help<br>
<br>
Matt<br>
<br>
_______________________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the ParaView Wiki at: <a href="http://paraview.org/Wiki/ParaView" target="_blank">http://paraview.org/Wiki/ParaView</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.paraview.org/mailman/listinfo/paraview" target="_blank">http://www.paraview.org/mailman/listinfo/paraview</a><br>
</blockquote></div><br>