Revision: 7548
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7548&view=rev
Author: astraw
Date: 2009-08-24 02:37:21 +0000 (Mon, 24 Aug 2009)
Log Message:
-----------
buildbot: add script to consolidate failed images
Added Paths:
-----------
trunk/matplotlib/test/_buildbot_test_postmortem.py
Added: trunk/matplotlib/test/_buildbot_test_postmortem.py
===================================================================
--- trunk/matplotlib/test/_buildbot_test_postmortem.py
(rev 0)
+++ trunk/matplotlib/test/_buildbot_test_postmortem.py 2009-08-24 02:37:21 UTC
(rev 7548)
@@ -0,0 +1,104 @@
+"""For all failed image comparisons, gather the baseline image, the
+current image and the absdiff image into a single directory specified
+by target_dir.
+
+This is meant to be run from the mplroot directory."""
+
+import os, sys, glob, shutil
+
+roots = ['test_matplotlib','test_plots']
+savedresults_dir = 'saved-results'
+baseline_dir = 'baseline'
+basename = 'failed-diff-'
+target_dir = os.path.abspath('status_images')
+nbase = len(basename)
+
+def listFiles(root, patterns='*', recurse=1, return_folders=0):
+ """
+ Recursively list files
+
+ from Parmar and Martelli in the Python Cookbook
+ """
+ import os.path, fnmatch
+ # Expand patterns from semicolon-separated string to list
+ pattern_list = patterns.split(';')
+ # Collect input and output arguments into one bunch
+ class Bunch:
+ def __init__(self, **kwds): self.__dict__.update(kwds)
+ arg = Bunch(recurse=recurse, pattern_list=pattern_list,
+ return_folders=return_folders, results=[])
+
+ def visit(arg, dirname, files):
+ # Append to arg.results all relevant files (and perhaps folders)
+ for name in files:
+ fullname = os.path.normpath(os.path.join(dirname, name))
+ if arg.return_folders or os.path.isfile(fullname):
+ for pattern in arg.pattern_list:
+ if fnmatch.fnmatch(name, pattern):
+ arg.results.append(fullname)
+ break
+ # Block recursion if recursion was disallowed
+ if not arg.recurse: files[:]=[]
+
+ os.path.walk(root, visit, arg)
+
+ return arg.results
+
+def get_recursive_filelist(args):
+ """
+ Recurse all the files and dirs in *args* ignoring symbolic links
+ and return the files as a list of strings
+ """
+ files = []
+
+ for arg in args:
+ if os.path.isfile(arg):
+ files.append(arg)
+ continue
+ if os.path.isdir(arg):
+ newfiles = listFiles(arg, recurse=1, return_folders=1)
+ files.extend(newfiles)
+
+ return [f for f in files if not os.path.islink(f)]
+
+def path_split_all(fname):
+ """split a file path into a list of directories and filename"""
+ pieces = [fname]
+ previous_tails = []
+ while 1:
+ head,tail = os.path.split(pieces[0])
+ if head=='':
+ return pieces + previous_tails
+ pieces = [head]
+ previous_tails.insert(0,tail)
+
+if 1:
+ if os.path.exists(target_dir):
+ shutil.rmtree(target_dir)
+ os.chdir('test')
+ for fpath in get_recursive_filelist(roots):
+ # only images
+ if not fpath.endswith('.png'): continue
+
+ pieces = path_split_all( fpath )
+ if pieces[1]!=savedresults_dir:
+ continue
+ root = pieces[0]
+ testclass = pieces[2]
+ fname = pieces[3]
+ if not fname.startswith(basename):
+ # only failed images
+ continue
+ origname = fname[nbase:]
+ testname = os.path.splitext(origname)[0]
+
+ # make a name for the test
+ teststr = '%s.%s.%s'%(root,testclass,testname)
+ this_targetdir = os.path.join(target_dir,teststr)
+ os.makedirs( this_targetdir )
+ shutil.copy( os.path.join(root,baseline_dir,testclass,origname),
+ os.path.join(this_targetdir,'baseline.png') )
+ shutil.copy( os.path.join(root,savedresults_dir,testclass,origname),
+ os.path.join(this_targetdir,'actual.png') )
+ shutil.copy( os.path.join(root,savedresults_dir,testclass,fname),
+ os.path.join(this_targetdir,'absdiff.png') )
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________
Matplotlib-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins