refresh_mb_output.py 1.86 KB
Newer Older
Jonathan Lambrechts's avatar
Jonathan Lambrechts committed
1
# Marblesbag - Copyright (C) <2010-2018>
2
3
# <Universite catholique de Louvain (UCL), Belgium
#  Universite de Montpellier, France>
Jonathan Lambrechts's avatar
Jonathan Lambrechts committed
4
# 	
5
# List of the contributors to the development of Marblesbag: see AUTHORS file.
Jonathan Lambrechts's avatar
Jonathan Lambrechts committed
6
7
8
# Description and complete License: see LICENSE file.
# 	
# This program (Marblesbag) is free software: 
9
# you can redistribute it and/or modify it under the terms of the GNU Lesser General 
Jonathan Lambrechts's avatar
Jonathan Lambrechts committed
10
11
12
13
14
15
# Public License as published by the Free Software Foundation, either version
# 3 of the License, or (at your option) any later version.
# 
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
# GNU Lesser General Public License for more details.
Jonathan Lambrechts's avatar
Jonathan Lambrechts committed
17
# 
18
19
# You should have received a copy of the GNU Lesser General Public License
# along with this program (see COPYING and COPYING.LESSER files).  If not, 
Jonathan Lambrechts's avatar
Jonathan Lambrechts committed
20
21
# see <http://www.gnu.org/licenses/>.

22
23
24
25
26
27
28
29
30
import glob
import os
from paraview.simple import *

for sname,sid in GetSources() :
    s = FindSource(sname)
    if not hasattr(s,'FileName') :
        continue
    l = s.FileName.GetData()
Jonathan Lambrechts's avatar
Jonathan Lambrechts committed
31
    for ext in [".vtu",".vtp",".vtm"] :
32
        if l and l[0][-4:]==ext:
Jonathan Lambrechts's avatar
Jonathan Lambrechts committed
33
34
35
36
37
            p = l[0].rfind("_")
            basename = l[0][:p]
            idname = l[0][p+1:-4]
            idnamelength = len(idname)    
            fmt = basename+"_%0"+str(idnamelength)+"i"+ext
38
39
40
41
            t0 = os.path.getmtime(l[0])
            allfiles = []
            i = 1
            while True :
Jonathan Lambrechts's avatar
Jonathan Lambrechts committed
42
                fname = fmt%i
43
44
45
46
47
48
49
50
51
                try :
                    mt = os.path.getmtime(fname)
                    if mt < t0 :
                        break
                except :
                    break
                allfiles += [fname]
                i += 1
            if allfiles :
Jonathan Lambrechts's avatar
Jonathan Lambrechts committed
52
                s.FileName.SetData(allfiles)