Update Time Step with Python programmable source

Dear all,

I want to display 3D Time varying data in Paraview. I partially succeded to do it thanks to the simplified code below :

ReqDataScript = """
import numpy as np
import h5py
import glob, os 

path                = "/home/srendon/Paraview_tests/paraview_support/"
timesteps=range(1, 7)

executive = self.GetExecutive()
outInfo   = executive.GetOutputInformation(0)

for timestep in timesteps:
    outInfo.Append(executive.TIME_STEPS(), timestep)
outInfo.Append(executive.TIME_RANGE(), timesteps[0])
outInfo.Append(executive.TIME_RANGE(), timesteps[-1])

# A 3D cylindrical mesh
f     = h5py.File("{path}{time:03}.data.h5".format(path=path,time=1),"r")
# radius, theta, z-elevation

outInfo.Set(executive.WHOLE_EXTENT(), 0, nx-1 , 0, ny-1 , 0, nz-1)
outInfo.Set(vtk.vtkAlgorithm.CAN_PRODUCE_SUB_EXTENT(), 1)

ReqDataScript = """
import numpy as np
import h5py
from vtk.numpy_interface import algorithms as algs
import vtk
import glob, os 

path                = "/home/srendon/Paraview_tests/paraview_support/"

list_data_files = glob.glob(path + "*data.h5")

executive = self.GetExecutive()
outInfo   = executive.GetOutputInformation(0)
if outInfo.Has(executive.UPDATE_TIME_STEP()):
    time  = int(outInfo.Get(executive.UPDATE_TIME_STEP()))
    print("no update time available")
    time  = 0

exts      = [executive.UPDATE_EXTENT().Get(outInfo, i) for i in range(6)]

print("{path}{time:03}.data.h5".format(path=path, time=time))
f     = h5py.File("{path}{time:03}.data.h5".format(path=path,time=1),"r")
#f     = h5py.File("{path}{time:03}.data.h5".format(path=path,time=time),"r")

### Euler Variables
p_gas      = f["gas"]["p"][()]

### Mesh ###
Raxis     = f["mesh"]["x"][...]
Thetaaxis = f["mesh"]["y"][...]
Zaxis     = f["mesh"]["z"][...]

z, t, r = np.meshgrid(Zaxis, Thetaaxis, Raxis, indexing="ij")
X       = r * np.cos(t)
Y       = r * np.sin(t)
Z       = z

coordinates   = algs.make_vector(X.ravel(),Y.ravel(),Z.ravel())
output.Points = coordinates

### Output PointData ###
output.PointData.append(p_gas.ravel(),     "gas_p")

### Close files ###

output.GetInformation().Set(output.DATA_TIME_STEP(), time)

# create a new 'Programmable Source'
programmableSource1                          = ProgrammableSource()
programmableSource1.OutputDataSetType        = 'vtkStructuredGrid'
programmableSource1.Script                   = ReqDataScript
programmableSource1.ScriptRequestInformation = ReqInfoScript
programmableSource1.PythonPath               = ''

rep2                = Show()
rep2.Representation = 'Surface'
ColorBy(rep2, ('POINTS', 'gas_p'))

However each time I try to visualize my data I am forced to comment in my script the line :
f = h5py.File("{path}{time:03}.data.h5".format(path=path,time=time),"r")

Then when Paraview opens and load only the first file I have to go to the script window :
comment : f = h5py.File("{path}{time:03}.data.h5".format(path=path,time=1),"r")
uncomment f = h5py.File("{path}{time:03}.data.h5".format(path=path,time=time),"r")
And then apply. When this is performed I have a time varying data. However I do not want to do this all the time …
Can someone tell me what I am missing please ?

Thank you in advance,

P-S : In the following link there is a video of the procedure I do and some test files with the programmable source : Nuage