[Paraview] resume python script from last position
Biddiscombe, John A.
biddisco at cscs.ch
Sat Jul 27 19:27:32 EDT 2013
Max
Absolutely marvellous, does exactly what I wanted. Just tested it out and it finds the sequence and returns the last index.
I only needed to add an except handler if there were no files found so on the first run it sets last index to 0.
Many thanks indeed. I learn a lot from snippets like these.
Burlen : My mail server rejected an attachment from you with .sh extension. Do I still need it - given that Max's snippet server my current purpose?
Thanks to both of you
JB
-----Original Message-----
From: Maximilian Albert [mailto:maximilian.albert at gmail.com]
Sent: 26 July 2013 11:43
To: Biddiscombe, John A.
Cc: paraview at paraview.org
Subject: Re: [Paraview] resume python script from last position
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