[Durian-svn] [2196] simple utilities for checking lib linking error, absolute paths and duplicate images.

campbell institute at blender.org
Tue Apr 20 09:15:47 CEST 2010


Revision: 2196
          https://blenderinstitute.dyndns.org/durian-svn/?do=log&project=durian&path=/&rev=2196
Author:   campbell
Date:     2010-04-20 09:15:46 +0200 (Tue, 20 Apr 2010)
Log Message:
-----------
simple utilities for checking lib linking error, absolute paths and duplicate images.

Added Paths:
-----------
    pro/scripts/utilities/
    pro/scripts/utilities/findLibError.py
    pro/scripts/utilities/findPathError.py

Added: pro/scripts/utilities/findLibError.py
===================================================================
--- pro/scripts/utilities/findLibError.py	                        (rev 0)
+++ pro/scripts/utilities/findLibError.py	2010-04-20 07:15:46 UTC (rev 2196)
@@ -0,0 +1,106 @@
+'''
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * 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
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ *
+ *
+ * Contributor(s): Campbell Barton
+ *
+ * ***** END GPL LICENSE BLOCK *****
+'''
+
+'''
+This script goes through loading blend files and reporting any library errors they have in a useful way
+Run every once in a while to chack the validity of the movies blend files
+'''
+
+import os
+
+tempf = '/tmp/blenLibChecker.temp'
+blends = '/tmp/blenLibCheckerFiles.temp'
+
+outfile = '/shared/durian/missing_lib.txt'
+
+# search = '/media/data/peach/production'
+search = '/media/data/durian/pro'
+
+# blender_bin = '/render/blender_$(whoami)/blender/blender'
+blender_cmd = 'LD_LIBRARY_PATH=/shared/software/exr/lib /b/B'
+
+VERBOSE = True
+
+def main():
+    os.system('find %s -name "*.blend" > %s' % (search, blends))
+    
+    file_blends = open(blends, 'r').readlines()
+    
+    errors = {}
+    error_count = 0
+    error_path = []
+    tot = len(file_blends)
+    for i, line in enumerate(file_blends):
+        line = line.strip()
+        
+        if VERBOSE:
+            print 'Loading', line, str(int( (float(i)/tot) * 100.0 )) + '% done,  error count:', error_count
+        
+        line = line.strip()
+        #os.system('export ')
+        
+        
+        # RUN Blender to find Library errors AND run a script that looks broken paths!
+        ## os.system('LD_LIBRARY_PATH=/shared/software/exr/lib /render/blender_$(whoami)/blender/blender -b %s 1> %s 2>&1' % (line, tempf))
+        
+        pyscript = os.path.join(os.getcwd(), os.path.dirname(__file__) + "findPathError.py")
+
+        # Also run a py script
+
+        cmd = '%s -b %s   -P %s   1> %s 2>&1' % (blender_cmd, line, pyscript, tempf)
+        # print(cmd)
+        os.system(cmd)
+        
+        #os.system('/render/blender_$(whoami)/blender/blender -b %s')
+        file_lib = open(tempf, 'r')
+        
+        context_lib = None
+        for out_line in file_lib.readlines():
+            if out_line.startswith('ERROR PATH: ') or out_line.startswith('ABSOLUTE PATH: ') or out_line.startswith('DUPLICATE PATH: '): # Py Script makes this one
+                context_lib = out_line.strip()
+                errors.setdefault(line, ({}, []))[1].append(out_line.strip())
+                error_count += 1
+            elif out_line.startswith('read library: '):
+                context_lib = out_line.strip()
+            elif out_line.startswith('LIB ERROR: '):
+                errors.setdefault(line, ({}, []))[0].setdefault(context_lib, []).append(out_line.strip())
+                error_count += 1
+    
+    
+    # Repor errors
+    out = open(outfile, 'w')
+    
+    for blenfile, blenfile_dict_and_pics in errors.iteritems():
+        out.write('BLENFILE: ' + blenfile + '\n')
+        for libfile, errorls in blenfile_dict_and_pics[0].iteritems():
+            out.write('    LIBFILE: ' + libfile + '\n' )
+            for err in errorls:
+                out.write( '        : ' + err + '\n')
+        for file in blenfile_dict_and_pics[1]:
+            out.write('    ' + file + '\n')
+    
+    os.system('rm ' + tempf)
+    os.system('rm ' + blends)
+    
+
+main()

Added: pro/scripts/utilities/findPathError.py
===================================================================
--- pro/scripts/utilities/findPathError.py	                        (rev 0)
+++ pro/scripts/utilities/findPathError.py	2010-04-20 07:15:46 UTC (rev 2196)
@@ -0,0 +1,62 @@
+'''
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * 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
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ *
+ *
+ * Contributor(s): Campbell Barton
+ *
+ * ***** END GPL LICENSE BLOCK *****
+'''
+
+'''
+This script prints files that have absolute paths or missing files
+'''
+
+import bpy
+import os
+
+DUMMY_NAMES = ('Viewer Node', 'Render Result', 'Untitled')
+
+expandpath = bpy.utils.expandpath
+from os.path import exists
+
+image_duplicates = {}
+
+for i in bpy.data.images:
+    if not i.library:
+        name = i.name
+        if name in DUMMY_NAMES or os.path.splitext(name)[0] in DUMMY_NAMES:
+            continue
+        
+        filename = i.filename
+        filename_abs = filename
+        if not filename.startswith('//'):
+            print("ABSOLUTE PATH:", name, filename)
+        else:
+            filename_abs = expandpath(filename)
+        
+        if not exists(expandpath(filename)):
+            print("ERROR PATH:", name, filename, 'ABS:', filename_abs)
+    
+    # lookup duplicates
+    image_duplicates.setdefault(filename_abs, []).append(name)
+
+for filename_abs in sorted(image_duplicates.keys()):
+    value = image_duplicates[filename_abs]
+    if len(value) > 1:
+        print("DUPLICATE PATH:", filename_abs, 'Datablocks:', ' '.join(value))
+
+    
\ No newline at end of file



More information about the Durian-svn mailing list