[Durian-svn] [6860] minor fixes to replace script, check there is at least one valid image in the directory before using it.

campbell institute at blender.org
Tue Jul 13 13:51:26 CEST 2010


Revision: 6860
          https://blenderinstitute.dyndns.org/durian-svn/?do=log&project=durian&path=/&rev=6860
Author:   campbell
Date:     2010-07-13 13:51:26 +0200 (Tue, 13 Jul 2010)
Log Message:
-----------
minor fixes to replace script, check there is at least one valid image in the directory before using it.
do this because jpg's are not in the finals dir.

Modified Paths:
--------------
    pro/scripts/utilities/sequencer_switch_finals.py

Modified: pro/scripts/utilities/sequencer_switch_finals.py
===================================================================
--- pro/scripts/utilities/sequencer_switch_finals.py	2010-07-13 11:46:48 UTC (rev 6859)
+++ pro/scripts/utilities/sequencer_switch_finals.py	2010-07-13 11:51:26 UTC (rev 6860)
@@ -7,6 +7,7 @@
 
 # CONSTANTS
 CONTEXT = 'SEL' # SEL or ALL
+IMAGE_EXT = ".exr" # .exr or .jpg
 AVI_DIR = "//render/"
 EXR_DIR = "/shared/render"
 SVN_DIR = "/d/pro/scenes"
@@ -35,7 +36,6 @@
     '''
     if filepath.startswith(AVI_DIR):
         base_name = os.path.splitext(filepath)[0]
-        
         base_name = os.path.basename(base_name)
 
         if DEBUG:
@@ -46,23 +46,25 @@
         if not blend_name:
             MISSING_BLENDS.append(base_name)
         else:
-            frame_start, frame_end, scene = blend_render_info.read_blend_rend_chunk(blend_name)[0]
-            
             exr_path_current = os.path.join(EXR_DIR, base_name)
             exr_path_final = os.path.join(EXR_DIR, base_name, "final")
 
-            if os.path.exists(exr_path_final):
+            # add extra check that there is at least 1 valid image in the directory
+            if os.path.exists(exr_path_final) and [f for f in os.listdir(exr_path_final) if f.endswith(IMAGE_EXT)]:
                 exr_path = exr_path_final
             else:
                 exr_path = exr_path_current
 
             # print(base_name)
             if os.path.exists(exr_path):
+                # Should be no more then 1 anyway
+                frame_start, frame_end, scene = blend_render_info.read_blend_rend_chunk(blend_name)[0]
+
                 # print(exr_path)
                 exrs = []
                 '''
                 for f in os.listdir(exr_path):
-                    if f.startswith(base_name) and f.endswith(".exr"):
+                    if f.startswith(base_name) and f.endswith(IMAGE_EXT):
                         f_num = f.split("_")[-1].split(".")[0]
                         val = int(f_num)
                         if val >= frame_start and val <= frame_end:
@@ -73,7 +75,7 @@
                 '''
 
                 for i in range(frame_start, frame_end + 1):
-                    exr_name = "%s_%.6d.exr" % (base_name, i)
+                    exr_name = "%s_%.6d%s" % (base_name, i, IMAGE_EXT)
                     exr_name_full = os.path.join(exr_path, exr_name)
                     if not os.path.exists(exr_name_full):
                         MISSING_EXRS_FILES.append(exr_name_full)



More information about the Durian-svn mailing list