How to run a python macro with paraFoam?

I created a simple macro to automate some post processing. It works if I launch paraFoam and click the button for it in the GUI. But I want to run this without having to “click the button”. Here’s what I tried along with the error messages. Guessing I need to manually edit the paraFoam script?

[fhussa@lgn001 0.5_conical]$ touch 0.5_conical.foam
[fhussa@lgn001 0.5_conical]$ pvpython movie.py
Traceback (most recent call last):
  File "/data/users/fhussa/openfoam/0.5_conical/movie.py", line 15, in <module>
    a02_conicalfoam.CaseType = 'Decomposed Case'
AttributeError: 'NoneType' object has no attribute 'CaseType'

[fhussa@lgn001 0.5_conical]$ paraview --script movie.py
Traceback (most recent call last):
  File "<string>", line 15, in <module>
AttributeError: 'NoneType' object has no attribute 'CaseType'

[fhussa@lgn001 0.5_conical]$ paraFoam --script movie.py
Invalid $PV_PLUGIN_PATH and -plugin-path= not defined
No supplementary ParaView/OpenFOAM reader modules
Using builtin reader: paraFoam -vtk

--script excludes --data
Usage: paraview [OPTIONS] 

[General Guidelines] 

Values for options can be specified either with a space (' ') or an equal-to sign ('='). Thus, '--option=value' and '--option value' are equivalent. 

Multi-valued options can be specified by providing the option multiple times or separating the values by a comma (','). Thus, '--moption=foo,bar' and '--moption=foo --moption=bar' are equivalent. 

Short-named options with more than one character name are no longer supported, and should simply be specified as long-named option by adding an additional '-'. Thus, use '--dr' instead of '-dr'. 

Some options are described in this help text with the format '--moption TYPE:name' where 'TYPE' specifies what kind of value is expected for the option 'name'. Type 'ENUM' means there are several possible predefined values for the option. Type 'TEXT' means that the filename option is any text string. 

Numeric specifiers 'INT' and 'FLOAT' in this help text indicate the expected option value type of some options, either an integer or floating point number. 

 
Try `--help` for more more information.
[fhussa@lgn001 0.5_conical]$

Think I got it working. I first copied the paraFoam script to the folder where my project is. I edited the third last line at the bottom as follows:

Code:

paraview --script my_macro.py 2>&1 \

Then in my_macro.py I add this at the top after the import line:

Code:

from paraview.simple import *
reader = OpenDataFile("my_project.foam")

Then from command line I run:

Code:

./paraFoam

Seems to work ok!

Also worked as follows:

Code:

touch my_project.foam
paraview --script automate.py

and:

Code:

touch my_project.foam
pvpython automate.py