# Generate HTML demonstrations based on Screenshots Tool and PngWalkTool QC facility. # The screenshots tool is run, creating a sequence of screenshots. This should be trimmed # automatically, so that all images are of the same size, and as small as possible. # The PNGWalk QC tool is turned on, and then "OK/green" images are written to HTML with # the last comment as the caption to each figure. from javax.xml.parsers import ParserConfigurationException from javax.xml.parsers import DocumentBuilderFactory from javax.xml.xpath import XPath from javax.xml.xpath import XPathExpressionException from javax.xml.xpath import XPathFactory from javax.xml.xpath import XPathConstants from org.xml.sax import InputSource from java.io import File from java.io import FileInputStream d= getParam('dir','/home/jbf/pngwalk/', 'the pngwalk home' ) ff= getParam('name', 'product') def getCaption( qcFile ): 'return the last review comment in the xml file' myin= FileInputStream( qcFile ) builder = DocumentBuilderFactory.newInstance().newDocumentBuilder() source = InputSource( myin ) initialDocument = builder.parse(source) factory= XPathFactory.newInstance() xpath= factory.newXPath() caption= xpath.evaluate( '/qualityControlRecord/reviewComment[last()]/text()', initialDocument, XPathConstants.STRING ) return caption ll= listDirectory( d + '/' + ff + '*.ok' ) thedate= TimeParser.create('$Y$m$d_$H$M').format(TimeUtil.now()) if ( ff=='' ): ff= thedate html= open( d + '/' + ff + '.html', 'w' ) html.write( '''