[Paraview] resume python script from last position

Maximilian Albert maximilian.albert at gmail.com
Fri Jul 26 05:43:16 EDT 2013


Hi John

I'm not 100% sure I understand your question correctly, but if I am
right and you're only asking how to find the index of the last saved
picture (and not about Paraview's capabilities to resume a job), does
the following snippet do what you want?

==>
from glob import glob
import re

def get_pic_index(filename):
    match = re.search('pic_([0-9]+).png', filename)
    try:
        index = match.group(1)
    except AttributeError:
        raise ValueError("Filename has the wrong pattern. Expected:
'pic_xxxx.png', got: '{}'".format(filename))
    return int(index)

existing_indices = sorted([get_pic_index(f) for f in glob('pic_*.png')])
print "Last index: {}".format(existing_indices[-1])
<==

Hope this helps (and apologies if I misunderstood your request).

Cheers,
Max


2013/7/25 Biddiscombe, John A. <biddisco at cscs.ch>:
> Hello,
>
>
>
> I need to set a python script running inside paraview and it’ll take days,
> so I’d like to write out the time stamp (screenshot will be pic_XXXX.png so
> I could use that I expect), and when the job is restarted resume from the
> last frame.
>
>
>
> Does anyone have a snippet that will find the right place to restart from
> that I can use. My python skills are learner level, so I’m hoping some does
> this regularly and can send a snippet faster than I can work it out myself.
>
>
>
> thanks
>
>
>
> JB
>
>
>
> --
>
> John Biddiscombe,                        email:biddisco @.at.@ cscs.ch
>
> http://www.cscs.ch/
>
> CSCS, Swiss National Supercomputing Centre  | Tel:  +41 (91) 610.82.07
>
> Via Trevano 131, 6900 Lugano, Switzerland   | Fax:  +41 (91) 610.82.82
>
>
>
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the ParaView Wiki at:
> http://paraview.org/Wiki/ParaView
>
> Follow this link to subscribe/unsubscribe:
> http://www.paraview.org/mailman/listinfo/paraview
>


More information about the ParaView mailing list