def createHtmlPage(self, strImagePrefix, xsDataResultDimple, strResultsDirectory, strHtmlPath, strProposal, strSessionDate, strBeamline): """Create an HTML page with the results""" if not os.path.exists(strHtmlPath): os.makedirs(strHtmlPath, 0o755) strSample = "_".join(strImagePrefix.split("_")[0:-1]) strHtmlFileName = "ep_%s_index.html" % strImagePrefix strPath = os.path.join(strHtmlPath, strHtmlFileName) page = markupv1_10.page(mode='loose_html') # Title and footer page.init(title="Dimple Results", footer="Generated on %s" % time.asctime()) page.div(align_="LEFT") page.h1() page.strong("Dimple Results for sample {0} from proposal {1}".format(strSample, strProposal)) page.h1.close() page.h3("Session date: {0}-{1}-{2}".format(strSessionDate[0:4], strSessionDate[4:6], strSessionDate[6:])) page.h3("Beamline: {0}".format(strBeamline)) page.h3("Dimple output files can be found in :") page.strong(strResultsDirectory) page.div.close() # Results of REFMAC 5 page.h3("Final results of Recmac 5:") page.pre(self.extractFinalResultsFromRefmac5RestrLog(xsDataResultDimple.refmac5restrLog.path.value)) # Results of findblobs page.h3("Findblobs log:") page.pre(open(xsDataResultDimple.findBlobsLog.path.value).read()) # Blobs page.br() listImageHTML = [] for xsDataFileBlob in xsDataResultDimple.blob: # Copy blob file to html directory strBlobName = os.path.basename(xsDataFileBlob.path.value).split(".")[0] strBlobImage = "ep_%s_%s_dimple.png" % (strImagePrefix, strBlobName) strTargetPath = os.path.join(strHtmlPath, strBlobImage) shutil.copyfile(xsDataFileBlob.path.value, strTargetPath) strPageBlobPath = os.path.join(strHtmlPath, "ep_%s_%s_dimple.html" % (strImagePrefix, strBlobName)) pageBlob = markupv1_10.page() pageBlob.init(title=strBlobName, footer="Generated on %s" % time.asctime()) pageBlob.h1(strBlobName) pageBlob.div(align_="LEFT") pageBlob.img(src=strBlobImage, title=strBlobName) pageBlob.div.close() pageBlob.br() pageBlob.div(align_="LEFT") pageBlob.a("Back to previous page", href_=os.path.basename(strPath)) pageBlob.div.close() EDUtilsFile.writeFile(strPageBlobPath, str(pageBlob)) listImageHTML.append(strPageBlobPath) page.a(href=os.path.basename(strPageBlobPath)) page.img(src=strBlobImage, width=200, height=200, title=strBlobName) page.a.close() if strBlobName == "blob1v3": page.br() page.br() # FInalise html page strHTML = str(page) EDUtilsFile.writeFile(strPath, strHTML) listHTML = [strPath] + listImageHTML return listHTML
def integrationResults(self): # Was the integration successful? xsDataResultIntegration = self.xsDataResultCharacterisation.getIntegrationResult( ) if xsDataResultIntegration: iIntegration = 1 for xsDataIntegrationSubWedgeResult in xsDataResultIntegration.getIntegrationSubWedgeResult( ): if xsDataIntegrationSubWedgeResult.getIntegrationLogFile( ) is not None: strPathToIntegrationLogFile = xsDataIntegrationSubWedgeResult.getIntegrationLogFile( ).getPath().getValue() strIntegrationHtmlPageName = "integration_%d_log.html" % iIntegration strPageIntegrationLog = os.path.join( self.getWorkingDirectory(), strIntegrationHtmlPageName) pageIntegrationLog = markupv1_10.page() pageIntegrationLog.h1("Integration Log No %d" % iIntegration) pageIntegrationLog.a("Back to previous page", href_=self.strHtmlFileName) pageIntegrationLog.pre( cgi.escape( EDUtilsFile.readFile(strPathToIntegrationLogFile))) pageIntegrationLog.a("Back to previous page", href_=self.strHtmlFileName) EDUtilsFile.writeFile(strPageIntegrationLog, str(pageIntegrationLog)) self.page.a("Integration log file %d" % iIntegration, href=strIntegrationHtmlPageName) self.page.br() iIntegration += 1
def createTableWithIndexResults(self, _xsDataResultIndexing, _strForcedSpaceGroup): xsDataSolutionSelected = _xsDataResultIndexing.getSelectedSolution() xsDataCrystal = xsDataSolutionSelected.getCrystal() xsDataCell = xsDataCrystal.getCell() strSpaceGroup = xsDataCrystal.spaceGroup.name.value if _strForcedSpaceGroup is None: self.page.h3("Indexing summary: Selected spacegroup: %s" % strSpaceGroup, align_="LEFT") else: if strSpaceGroup.upper() == _strForcedSpaceGroup.upper(): self.page.h3("Indexing summary: Forced spacegroup: %s" % strSpaceGroup, align_="LEFT") else: self.page.h3( "Indexing summary: Selected spacegroup: %s, forced space group: %s" % (strSpaceGroup, _strForcedSpaceGroup), align_="LEFT") self.page.table(class_='indexResults', border_="1", cellpadding_="0") self.page.tr(align_="CENTER", bgcolor_=self.strTableColourTitle1) self.page.th("Refined unit cell parameters (Å/degrees)", colspan_="6") self.page.tr.close() self.page.tr(align_="CENTER", bgcolor_=self.strTableColourTitle2) self.page.th("a (Å)") self.page.th("b (Å)") self.page.th("c (Å)") self.page.th("alpha (°)") self.page.th("beta (°)") self.page.th("gamma (°)") self.page.tr.close() self.page.tr(align_="CENTER", bgcolor_=self.strTableColourRows) self.page.td("%.3f" % xsDataCell.getLength_a().getValue()) self.page.td("%.3f" % xsDataCell.getLength_b().getValue()) self.page.td("%.3f" % xsDataCell.getLength_c().getValue()) self.page.td("%.3f" % xsDataCell.getAngle_alpha().getValue()) self.page.td("%.3f" % xsDataCell.getAngle_beta().getValue()) self.page.td("%.3f" % xsDataCell.getAngle_gamma().getValue()) self.page.td.close() self.page.tr.close() self.page.table.close() if _xsDataResultIndexing.getIndexingLogFile(): strPathToIndexingLogFile = _xsDataResultIndexing.getIndexingLogFile( ).getPath().getValue() strPageIndexingLog = os.path.join(self.getWorkingDirectory(), "indexing_log.html") pageIndexingLog = markupv1_10.page() pageIndexingLog.h1("Indexing Log") pageIndexingLog.a("Back to previous page", href_=self.strHtmlFileName) pageIndexingLog.pre( cgi.escape(EDUtilsFile.readFile(strPathToIndexingLogFile))) pageIndexingLog.a("Back to previous page", href_=self.strHtmlFileName) EDUtilsFile.writeFile(strPageIndexingLog, str(pageIndexingLog)) self.page.a("Indexing log file", href="indexing_log.html")
def process(self, _edPlugin=None): EDPluginExec.process(self, _edPlugin) self.DEBUG("EDPluginExecSimpleHTMLPagev2_0.process...") if self.xsDataResultCharacterisation is not None: # Create the simple characterisation result page self.page = markupv1_10.page(mode='loose_html') self.page.init(title="Characterisation Results", footer="Generated on %s" % time.asctime()) self.page.div(align_="CENTER") self.page.h1() if self.xsDataResultCharacterisation is not None: self.page.strong("Characterisation Results ") else: self.page.strong("No Characterisation Results! ") # Link to the EDNA log file strPathToLogFile = self.findEDNALogFile() if strPathToLogFile is not None: self.page.strong("(") self.strPageEDNALog = os.path.join(self.getWorkingDirectory(), "edna_log.html") pageEDNALog = markupv1_10.page() pageEDNALog.h1("EDNA Log") pageEDNALog.a("Back to previous page", href_=self.strHtmlFileName) pageEDNALog.pre( cgi.escape(EDUtilsFile.readFile(strPathToLogFile))) pageEDNALog.a("Back to previous page", href_=self.strHtmlFileName) EDUtilsFile.writeFile(self.strPageEDNALog, str(pageEDNALog)) self.page.a("EDNA log file", href_="edna_log.html") self.page.strong(")") self.page.h1.close() self.page.div.close() self.dataCollectionInfo() self.diffractionPlan() self.strategyResults() self.graphs() self.stacResults() self.indexingResults() self.integrationResults() self.imageQualityIndicatorResults()
def __renderImage(self, page, item, pathToHtmlDir): imageName = item["title"].replace(" ", "_") pathToImage = os.path.join(pathToHtmlDir, "{0}.{1}".format(imageName, item["suffix"])) if os.path.exists(pathToImage): fd, pathToImage = tempfile.mkstemp(suffix="." + item["suffix"], prefix=imageName + "_", dir=pathToHtmlDir) os.close(fd) open(pathToImage, "wb").write(base64.b64decode(item["value"])) os.chmod(pathToImage, 0o644) if "thumbnailValue" in item: thumbnailImageName = imageName + "_thumbnail" pathToThumbnailImage = os.path.join( pathToHtmlDir, "{0}.{1}".format(thumbnailImageName, item["suffix"])) if os.path.exists(pathToThumbnailImage): fd, pathToThumbnailImage = tempfile.mkstemp( suffix="." + item["suffix"], prefix=thumbnailImageName + "_", dir=pathToHtmlDir) os.close(fd) open(pathToThumbnailImage, "wb").write(base64.b64decode(item["thumbnailValue"])) os.chmod(pathToThumbnailImage, 0o644) pageReferenceImage = markupv1_10.page(mode='loose_html') pageReferenceImage.init(title=imageName, footer="Generated on %s" % time.asctime()) pageReferenceImage.h1(imageName) pageReferenceImage.br() pageReferenceImage.img(src=os.path.basename(pathToImage), title=imageName, width=item["xsize"], height=item["ysize"]) pageReferenceImage.br() pathPageReferenceImage = os.path.join(pathToHtmlDir, "{0}.html".format(imageName)) filePage = open(pathPageReferenceImage, "w") filePage.write(str(pageReferenceImage)) filePage.close() page.a(href=os.path.basename(pathPageReferenceImage)) page.img(src=os.path.basename(pathToThumbnailImage), title=imageName, width=item["thumbnailXsize"], height=item["thumbnailYsize"]) page.a.close() else: page.img(src=os.path.basename(pathToImage), title=item["title"], width=item["xsize"], height=item["ysize"])
def graphs(self): self.page.table(class_='bestGraphs', border_="0", cellpadding_="0") if self.xsDataResultCharacterisation.strategyResult is None: return if self.xsDataResultCharacterisation.strategyResult.bestGraphFile == []: return listXSDataFile = self.xsDataResultCharacterisation.strategyResult.bestGraphFile if listXSDataFile != []: self.page.tr(align_="CENTER") iIndex = 1 # If -damPar is used only three plots are available: if len(listXSDataFile) >= 7: listPlotsToDisplay = [0, 1, 3, 6] elif len(listXSDataFile) >= 4: listPlotsToDisplay = [0, 1, 2, 3] else: listPlotsToDisplay = range(len(listXSDataFile)) for iIndexPlot in listPlotsToDisplay: xsDataFile = listXSDataFile[iIndexPlot] strFileName = os.path.basename(xsDataFile.path.value) # print strFileName shutil.copy( xsDataFile.path.value, os.path.join(self.getWorkingDirectory(), strFileName)) self.page.td() strPageGraphFileName = os.path.splitext( strFileName)[0] + ".html" strPageGraphPath = os.path.join(self.getWorkingDirectory(), strPageGraphFileName) pageGraph = markupv1_10.page() pageGraph.init(title=strFileName, footer="Generated on %s" % time.asctime()) pageGraph.img(src=strFileName, title=strFileName) pageGraph.br() pageGraph.a("Back to previous page", href_=self.strHtmlFileName) EDUtilsFile.writeFile(strPageGraphPath, str(pageGraph)) self.page.a(href=strPageGraphFileName) self.page.img(src=strFileName, width=200, height=150, title=strFileName) self.page.a.close() self.page.td.close() iIndex += 1 if iIndex > 4: iIndex = 1 self.page.tr.close() self.page.tr(align_="CENTER") self.page.tr.close() self.page.table.close()
def process(self, _edPlugin=None): EDPluginExec.process(self, _edPlugin) self.DEBUG("EDPluginExecSimpleHTMLPagev2_0.process...") if self.xsDataResultCharacterisation is not None: # Create the simple characterisation result page self.page = markupv1_10.page(mode='loose_html') self.page.init(title="Characterisation Results", footer="Generated on %s" % time.asctime()) self.page.div(align_="CENTER") self.page.h1() if self.xsDataResultCharacterisation is not None: self.page.strong("Characterisation Results ") else: self.page.strong("No Characterisation Results! ") # Link to the EDNA log file strPathToLogFile = self.findEDNALogFile() if strPathToLogFile is not None: self.page.strong("(") self.strPageEDNALog = os.path.join(self.getWorkingDirectory(), "edna_log.html") pageEDNALog = markupv1_10.page() pageEDNALog.h1("EDNA Log") pageEDNALog.a("Back to previous page", href_=self.strHtmlFileName) pageEDNALog.pre(cgi.escape(EDUtilsFile.readFile(strPathToLogFile))) pageEDNALog.a("Back to previous page", href_=self.strHtmlFileName) EDUtilsFile.writeFile(self.strPageEDNALog, str(pageEDNALog)) self.page.a("EDNA log file", href_="edna_log.html") self.page.strong(")") self.page.h1.close() self.page.div.close() self.dataCollectionInfo() self.diffractionPlan() self.strategyResults() self.graphs() self.stacResults() self.indexingResults() self.integrationResults() self.imageQualityIndicatorResults()
def createHtmlPage(self): plotImage = Image.open(os.path.join(self.getWorkingDirectory(), self.strScaleIntensityPlot)) plotImageWidth, plotImageHeight = plotImage.size # (width,height) tuple page = markupv1_10.page(mode='loose_html') page.init(title="Burn Strategy Results", footer="Generated on %s" % time.asctime()) page.div(align_="CENTER") page.h1() page.strong("Burn Strategy Results") page.h1.close() page.img(src=self.strScaleIntensityPlot, title=self.strScaleIntensityPlot, height=plotImageHeight, width=plotImageWidth) page.div.close() strHTML = str(page) EDUtilsFile.writeFile(os.path.join(self.getWorkingDirectory(), self.strHtmlPath), strHTML)
def createThumbnailRowOfImages(self, _xsDataResultIndexing): # Thumbnail images of the predictions xsDataResultPrediction = _xsDataResultIndexing.getPredictionResult() listPaths = [] self.page.div(align_="left") self.page.table(class_='imageRow') self.page.tr(align_="CENTER") listXSDataReferenceImage = _xsDataResultIndexing.getImage() for xsDataImagePrediction in xsDataResultPrediction.getPredictionImage(): self.page.td() strPathToPredictionImage = xsDataImagePrediction.getPath().getValue() strFileName = os.path.basename(strPathToPredictionImage) strReferenceFileName = None for xsDataReferenceImage in listXSDataReferenceImage: if xsDataReferenceImage.getNumber().getValue() == xsDataImagePrediction.getNumber().getValue(): strReferenceFileName = os.path.basename(xsDataReferenceImage.getPath().getValue()) if strReferenceFileName is None: strReferenceFileName = strFileName strLocalPath = os.path.join(self.getWorkingDirectory(), strFileName) if os.path.exists(strPathToPredictionImage): shutil.copyfile(strPathToPredictionImage, strLocalPath) listPaths.append(strLocalPath) self.page.table(class_='image') self.page.tr(align_="CENTER") self.page.td() strPageReferenceImage = os.path.splitext(strFileName)[0] + ".html" pageReferenceImage = markupv1_10.page() pageReferenceImage.init(title=strReferenceFileName, footer="Generated on %s" % time.asctime()) pageReferenceImage.h1(strReferenceFileName) pageReferenceImage.a("Back to previous page", href_=self.strHtmlFileName) pageReferenceImage.img(src=strFileName, title=strReferenceFileName) pageReferenceImage.a("Back to previous page", href_=self.strHtmlFileName) EDUtilsFile.writeFile(os.path.join(self.getWorkingDirectory(), strPageReferenceImage), str(pageReferenceImage)) self.page.a(href=strPageReferenceImage) self.page.img(src=strFileName, width=128, height=128, title=strFileName) self.page.a.close() self.page.td.close() self.page.tr.close() self.page.tr(align_="CENTER") self.page.td(strReferenceFileName, class_="caption") self.page.td.close() self.page.tr.close() self.page.table.close() self.page.td.close() self.page.table.close() self.page.div.close()
def createTableWithIndexResults(self, _xsDataResultIndexing, _strForcedSpaceGroup): xsDataSolutionSelected = _xsDataResultIndexing.getSelectedSolution() xsDataCrystal = xsDataSolutionSelected.getCrystal() xsDataCell = xsDataCrystal.getCell() strSpaceGroup = xsDataCrystal.spaceGroup.name.value if _strForcedSpaceGroup is None: self.page.h3("Indexing summary: Selected spacegroup: %s" % strSpaceGroup, align_="LEFT") else: if strSpaceGroup.upper() == _strForcedSpaceGroup.upper(): self.page.h3("Indexing summary: Forced spacegroup: %s" % strSpaceGroup, align_="LEFT") else: self.page.h3("Indexing summary: Selected spacegroup: %s, forced space group: %s" % (strSpaceGroup, _strForcedSpaceGroup), align_="LEFT") self.page.table(class_='indexResults', border_="1", cellpadding_="0") self.page.tr(align_="CENTER", bgcolor_=self.strTableColourTitle1) self.page.th("Refined unit cell parameters (Å/degrees)", colspan_="6") self.page.tr.close() self.page.tr(align_="CENTER", bgcolor_=self.strTableColourTitle2) self.page.th("a (Å)") self.page.th("b (Å)") self.page.th("c (Å)") self.page.th("alpha (°)") self.page.th("beta (°)") self.page.th("gamma (°)") self.page.tr.close() self.page.tr(align_="CENTER", bgcolor_=self.strTableColourRows) self.page.td("%.3f" % xsDataCell.getLength_a().getValue()) self.page.td("%.3f" % xsDataCell.getLength_b().getValue()) self.page.td("%.3f" % xsDataCell.getLength_c().getValue()) self.page.td("%.3f" % xsDataCell.getAngle_alpha().getValue()) self.page.td("%.3f" % xsDataCell.getAngle_beta().getValue()) self.page.td("%.3f" % xsDataCell.getAngle_gamma().getValue()) self.page.td.close() self.page.tr.close() self.page.table.close() if _xsDataResultIndexing.getIndexingLogFile(): strPathToIndexingLogFile = _xsDataResultIndexing.getIndexingLogFile().getPath().getValue() strPageIndexingLog = os.path.join(self.getWorkingDirectory(), "indexing_log.html") pageIndexingLog = markupv1_10.page() pageIndexingLog.h1("Indexing Log") pageIndexingLog.a("Back to previous page", href_=self.strHtmlFileName) pageIndexingLog.pre(cgi.escape(EDUtilsFile.readFile(strPathToIndexingLogFile))) pageIndexingLog.a("Back to previous page", href_=self.strHtmlFileName) EDUtilsFile.writeFile(strPageIndexingLog, str(pageIndexingLog)) self.page.a("Indexing log file", href="indexing_log.html")
def integrationResults(self): # Was the integration successful? xsDataResultIntegration = self.xsDataResultCharacterisation.getIntegrationResult() if xsDataResultIntegration: iIntegration = 1 for xsDataIntegrationSubWedgeResult in xsDataResultIntegration.getIntegrationSubWedgeResult(): if xsDataIntegrationSubWedgeResult.getIntegrationLogFile() is not None: strPathToIntegrationLogFile = xsDataIntegrationSubWedgeResult.getIntegrationLogFile().getPath().getValue() strIntegrationHtmlPageName = "integration_%d_log.html" % iIntegration strPageIntegrationLog = os.path.join(self.getWorkingDirectory(), strIntegrationHtmlPageName) pageIntegrationLog = markupv1_10.page() pageIntegrationLog.h1("Integration Log No %d" % iIntegration) pageIntegrationLog.a("Back to previous page", href_=self.strHtmlFileName) pageIntegrationLog.pre(cgi.escape(EDUtilsFile.readFile(strPathToIntegrationLogFile))) pageIntegrationLog.a("Back to previous page", href_=self.strHtmlFileName) EDUtilsFile.writeFile(strPageIntegrationLog, str(pageIntegrationLog)) self.page.a("Integration log file %d" % iIntegration, href=strIntegrationHtmlPageName) self.page.br() iIntegration += 1
def graphs(self): self.page.table(class_='bestGraphs', border_="0", cellpadding_="0") if self.xsDataResultCharacterisation.strategyResult is None: return if self.xsDataResultCharacterisation.strategyResult.bestGraphFile == []: return listXSDataFile = self.xsDataResultCharacterisation.strategyResult.bestGraphFile if listXSDataFile != []: self.page.tr(align_="CENTER") iIndex = 1 # If -damPar is used only three plots are available: if len(listXSDataFile) >= 7: listPlotsToDisplay = [0, 1, 3, 6] elif len(listXSDataFile) >= 4: listPlotsToDisplay = [0, 1, 2, 3] else: listPlotsToDisplay = range(len(listXSDataFile)) for iIndexPlot in listPlotsToDisplay: xsDataFile = listXSDataFile[iIndexPlot] strFileName = os.path.basename(xsDataFile.path.value) # print strFileName shutil.copy(xsDataFile.path.value, os.path.join(self.getWorkingDirectory(), strFileName)) self.page.td() strPageGraphFileName = os.path.splitext(strFileName)[0] + ".html" strPageGraphPath = os.path.join(self.getWorkingDirectory(), strPageGraphFileName) pageGraph = markupv1_10.page() pageGraph.init(title=strFileName, footer="Generated on %s" % time.asctime()) pageGraph.img(src=strFileName, title=strFileName) pageGraph.br() pageGraph.a("Back to previous page", href_=self.strHtmlFileName) EDUtilsFile.writeFile(strPageGraphPath, str(pageGraph)) self.page.a(href=strPageGraphFileName) self.page.img(src=strFileName, width=200, height=150, title=strFileName) self.page.a.close() self.page.td.close() iIndex += 1 if iIndex > 4: iIndex = 1 self.page.tr.close() self.page.tr(align_="CENTER") self.page.tr.close() self.page.table.close()
def __renderImage(self, page, item, pathToHtmlDir): imageName = item["title"].replace(" ", "_") pathToImage = os.path.join(pathToHtmlDir, "{0}.{1}".format(imageName, item["suffix"])) if os.path.exists(pathToImage): fd, pathToImage = tempfile.mkstemp(suffix="." + item["suffix"], prefix=imageName + "_", dir=pathToHtmlDir) os.close(fd) open(pathToImage, "w").write(base64.b64decode(item["value"])) os.chmod(pathToImage, 0o644) if "thumbnailValue" in item: thumbnailImageName = imageName + "_thumbnail" pathToThumbnailImage = os.path.join(pathToHtmlDir, "{0}.{1}".format(thumbnailImageName, item["suffix"])) if os.path.exists(pathToThumbnailImage): fd, pathToThumbnailImage = tempfile.mkstemp(suffix="." + item["suffix"], prefix=thumbnailImageName + "_", dir=pathToHtmlDir) os.close(fd) open(pathToThumbnailImage, "w").write(base64.b64decode(item["thumbnailValue"])) os.chmod(pathToThumbnailImage, 0o644) pageReferenceImage = markupv1_10.page(mode='loose_html') pageReferenceImage.init(title=imageName, footer="Generated on %s" % time.asctime()) pageReferenceImage.h1(imageName) pageReferenceImage.br() pageReferenceImage.img(src=os.path.basename(pathToImage), title=imageName, width=item["xsize"], height=item["ysize"]) pageReferenceImage.br() pathPageReferenceImage = os.path.join(pathToHtmlDir, "{0}.html".format(imageName)) filePage = open(pathPageReferenceImage, "w") filePage.write(str(pageReferenceImage)) filePage.close() page.a(href=os.path.basename(pathPageReferenceImage)) page.img(src=os.path.basename(pathToThumbnailImage), title=imageName, width=item["thumbnailXsize"], height=item["thumbnailYsize"]) page.a.close() else: page.img(src=os.path.basename(pathToImage), title=item["title"], width=item["xsize"], height=item["ysize"])
def renderHtml(self, pathToHtmlDir, nameOfIndexFile="index.html"): page = markupv1_10.page(mode='loose_html') page.init(title=self.dictReport["title"], footer="Generated on %s" % time.asctime()) page.div(align_="LEFT") page.h1() page.strong(self.dictReport["title"]) page.h1.close() page.div.close() for item in self.dictReport["items"]: if "value" in item: itemValue = item["value"] if "title" in item: itemTitle = self.escapeCharacters(item["title"]) if item["type"] == "info": page.p(itemValue) if item["type"] == "warning": page.font(_color="red", size="+1") page.p() page.strong(itemValue) page.p.close() page.font.close() elif item["type"] == "image": self.__renderImage(page, item, pathToHtmlDir) page.br() page.p(itemTitle) elif item["type"] == "images": page.table() page.tr(align_="CENTER") for item in item["items"]: itemTitle = self.escapeCharacters(item["title"]) page.td() page.table() page.tr() page.td() self.__renderImage(page, item, pathToHtmlDir) page.td.close() page.tr.close() page.tr(align_="CENTER") page.td(itemTitle) page.tr.close() page.table.close() page.td.close() page.tr.close() page.table.close() page.br() elif item["type"] == "table": titleBgColour = "#99c2ff" columnTitleBgColour = "#ffffff" dataBgColour = "#e6f0ff" page.table( border_="1", cellpadding_="2", width="100%", style_= "border: 1px solid black; border-collapse: collapse; margin: 0px; font-size: 12px" ) page.tr(align_="LEFT") # page.strong(itemTitle) page.th( itemTitle, bgcolor_=titleBgColour, align_="LEFT", style_= "border: 1px solid black; border-collapse: collapse; padding: 5px;", colspan_=str(len(item["columns"]))) page.tr.close() if "orientation" in item and item["orientation"] == "vertical": for index1 in range(len(item["columns"])): itemColumn = self.escapeCharacters( item["columns"][index1]) page.tr(align_="LEFT") page.th( itemColumn, bgcolor_=columnTitleBgColour, align_="LEFT", style_= "border: 1px solid black; border-collapse: collapse; padding: 5px;" ) for index2 in range(len(item["data"])): itemData = self.escapeCharacters( str(item["data"][index2][index1])) page.th(itemData, bgcolor_=dataBgColour, style_="padding: 5px;") page.tr.close() else: page.tr( align_="LEFT", bgcolor_=columnTitleBgColour, style_= "border: 1px solid black; border-collapse: collapse; padding: 5px;" ) for column in item["columns"]: itemColumn = self.escapeCharacters(column) page.th( itemColumn, style_= "border: 1px solid black; border-collapse: collapse; padding: 5px;" ) page.tr.close() for listRow in item["data"]: page.tr( align_="LEFT", bgcolor_=dataBgColour, style_="border-collapse: collapse; padding: 5px;") for cell in listRow: itemCell = self.escapeCharacters(str(cell)) page.th( itemCell, style_= "border: 1px solid black; border-collapse: collapse; padding: 5px;" ) page.tr.close() page.table.close() page.br() elif item["type"] == "logFile": pathToLogHtml = os.path.join(pathToHtmlDir, itemTitle + ".html") if os.path.exists(pathToLogHtml): fd, pathToLogHtml = tempfile.mkstemp( suffix=".html", prefix=itemTitle.replace(" ", "_") + "_", dir=pathToHtmlDir) os.close(fd) pageLogHtml = markupv1_10.page() pageLogHtml.h1(itemTitle) # pageLogHtml.pre(html.escape(item["logText"])) open(pathToLogHtml, "w").write(str(pageLogHtml)) os.chmod(pathToLogHtml, 0o644) page.p() page.a(item["linkText"], href_=os.path.basename(pathToLogHtml)) page.p.close() html = str(page) pagePath = os.path.join(pathToHtmlDir, nameOfIndexFile) filePage = open(pagePath, "w") filePage.write(html) filePage.close() return pagePath
def renderHtml(self, pathToHtmlDir, nameOfIndexFile="index.html"): page = markupv1_10.page(mode='loose_html') page.init(title=self.dictReport["title"], footer="Generated on %s" % time.asctime()) page.div(align_="LEFT") page.h1() page.strong(self.dictReport["title"]) page.h1.close() page.div.close() for item in self.dictReport["items"]: if item["type"] == "info": page.p(item["value"]) if item["type"] == "warning": page.font(_color="red", size="+1") page.p() page.strong(item["value"]) page.p.close() page.font.close() elif item["type"] == "image": self.__renderImage(page, item, pathToHtmlDir) page.br() page.p(item["title"]) elif item["type"] == "images": page.table() page.tr(align_="CENTER") for item in item["items"]: page.td() page.table() page.tr() page.td() self.__renderImage(page, item, pathToHtmlDir) page.td.close() page.tr.close() page.tr(align_="CENTER") page.td(item["title"]) page.tr.close() page.table.close() page.td.close() page.tr.close() page.table.close() page.br() elif item["type"] == "table": page.h3() page.strong(item["title"]) page.h3.close() page.table(border_="1", cellpadding_="2") if "orientation" in item and item["orientation"] == "vertical": for index1 in range(len(item["columns"])): page.tr(align_="CENTER") page.th(item["columns"][index1].replace("\n", "<br>"), bgcolor_="#F0F0FF", align_="LEFT") for index2 in range(len(item["data"])): page.th(str(item["data"][index2][index1]).replace( "\n", "<br>"), bgcolor_="#FFFFA0") page.tr.close() else: page.tr(align_="CENTER", bgcolor_="#F0F0FF") for column in item["columns"]: page.th(column.replace("\n", "<br>")) page.tr.close() for listRow in item["data"]: page.tr(align_="CENTER", bgcolor_="#FFFFA0") for cell in listRow: page.th(str(cell).replace("\n", "<br>")) page.tr.close() page.table.close() elif item["type"] == "logFile": fd, pathToLogHtml = tempfile.mkstemp( suffix=".html", prefix=item["title"].replace(" ", "_") + "_", dir=pathToHtmlDir) os.close(fd) pageLogHtml = markupv1_10.page() pageLogHtml.h1(item["title"]) pageLogHtml.pre(cgi.escape(item["logText"])) open(pathToLogHtml, "w").write(str(pageLogHtml)) os.chmod(pathToLogHtml, 0o644) page.p() page.a(item["linkText"], href_=os.path.basename(pathToLogHtml)) page.p.close() html = str(page) pagePath = os.path.join(pathToHtmlDir, nameOfIndexFile) filePage = open(pagePath, "w") filePage.write(html) filePage.close() return pagePath
def createThumbnailRowOfImages(self, _xsDataResultIndexing): # Thumbnail images of the predictions xsDataResultPrediction = _xsDataResultIndexing.getPredictionResult() listPaths = [] self.page.div(align_="left") self.page.table(class_='imageRow') self.page.tr(align_="CENTER") listXSDataReferenceImage = _xsDataResultIndexing.getImage() for xsDataImagePrediction in xsDataResultPrediction.getPredictionImage( ): self.page.td() strPathToPredictionImage = xsDataImagePrediction.getPath( ).getValue() strFileName = os.path.basename(strPathToPredictionImage) strReferenceFileName = None for xsDataReferenceImage in listXSDataReferenceImage: if xsDataReferenceImage.getNumber().getValue( ) == xsDataImagePrediction.getNumber().getValue(): strReferenceFileName = os.path.basename( xsDataReferenceImage.getPath().getValue()) if strReferenceFileName is None: strReferenceFileName = strFileName strLocalPath = os.path.join(self.getWorkingDirectory(), strFileName) if os.path.exists(strPathToPredictionImage): shutil.copyfile(strPathToPredictionImage, strLocalPath) listPaths.append(strLocalPath) self.page.table(class_='image') self.page.tr(align_="CENTER") self.page.td() strPageReferenceImage = os.path.splitext( strFileName)[0] + ".html" pageReferenceImage = markupv1_10.page() pageReferenceImage.init(title=strReferenceFileName, footer="Generated on %s" % time.asctime()) pageReferenceImage.h1(strReferenceFileName) pageReferenceImage.a("Back to previous page", href_=self.strHtmlFileName) pageReferenceImage.img(src=strFileName, title=strReferenceFileName) pageReferenceImage.a("Back to previous page", href_=self.strHtmlFileName) EDUtilsFile.writeFile( os.path.join(self.getWorkingDirectory(), strPageReferenceImage), str(pageReferenceImage)) self.page.a(href=strPageReferenceImage) self.page.img(src=strFileName, width=128, height=128, title=strFileName) self.page.a.close() self.page.td.close() self.page.tr.close() self.page.tr(align_="CENTER") self.page.td(strReferenceFileName, class_="caption") self.page.td.close() self.page.tr.close() self.page.table.close() self.page.td.close() self.page.table.close() self.page.div.close()
def renderHtml(self, pathToHtmlDir, nameOfIndexFile="index.html"): page = markupv1_10.page(mode='loose_html') page.init(title=self.dictReport["title"], footer="Generated on %s" % time.asctime()) page.div(align_="LEFT") page.h1() page.strong(self.dictReport["title"]) page.h1.close() page.div.close() for item in self.dictReport["items"]: if "value" in item: itemValue = self.escapeCharacters(item["value"]) if "title" in item: itemTitle = self.escapeCharacters(item["title"]) if item["type"] == "info": page.p(itemValue) if item["type"] == "warning": page.font(_color="red", size="+1") page.p() page.strong(itemValue) page.p.close() page.font.close() elif item["type"] == "image": self.__renderImage(page, item, pathToHtmlDir) page.br() page.p(itemTitle) elif item["type"] == "images": page.table() page.tr(align_="CENTER") for item in item["items"]: itemTitle = self.escapeCharacters(item["title"]) page.td() page.table() page.tr() page.td() self.__renderImage(page, item, pathToHtmlDir) page.td.close() page.tr.close() page.tr(align_="CENTER") page.td(itemTitle) page.tr.close() page.table.close() page.td.close() page.tr.close() page.table.close() page.br() elif item["type"] == "table": titleBgColour = "#99c2ff" columnTitleBgColour = "#ffffff" dataBgColour = "#e6f0ff" page.table(border_="1", cellpadding_="2", width="100%", style_="border: 1px solid black; border-collapse: collapse; margin: 0px; font-size: 12px") page.tr(align_="LEFT") # page.strong(itemTitle) page.th(itemTitle, bgcolor_=titleBgColour, align_="LEFT", style_="border: 1px solid black; border-collapse: collapse; padding: 5px;", colspan_=str(len(item["columns"]))) page.tr.close() if "orientation" in item and item["orientation"] == "vertical": for index1 in range(len(item["columns"])): itemColumn = self.escapeCharacters(item["columns"][index1]) page.tr(align_="LEFT") page.th(itemColumn, bgcolor_=columnTitleBgColour, align_="LEFT", style_="border: 1px solid black; border-collapse: collapse; padding: 5px;") for index2 in range(len(item["data"])): itemData = self.escapeCharacters(str(item["data"][index2][index1])) page.th(itemData, bgcolor_=dataBgColour, style_="padding: 5px;") page.tr.close() else: page.tr(align_="LEFT", bgcolor_=columnTitleBgColour, style_="border: 1px solid black; border-collapse: collapse; padding: 5px;") for column in item["columns"]: itemColumn = self.escapeCharacters(column) page.th(itemColumn, style_="border: 1px solid black; border-collapse: collapse; padding: 5px;") page.tr.close() for listRow in item["data"]: page.tr(align_="LEFT", bgcolor_=dataBgColour, style_="border-collapse: collapse; padding: 5px;") for cell in listRow: itemCell = self.escapeCharacters(str(cell)) page.th(itemCell, style_="border: 1px solid black; border-collapse: collapse; padding: 5px;") page.tr.close() page.table.close() page.br() elif item["type"] == "logFile": pathToLogHtml = os.path.join(pathToHtmlDir, itemTitle + ".html") if os.path.exists(pathToLogHtml): fd, pathToLogHtml = tempfile.mkstemp(suffix=".html", prefix=itemTitle.replace(" ", "_") + "_", dir=pathToHtmlDir) os.close(fd) pageLogHtml = markupv1_10.page() pageLogHtml.h1(itemTitle) pageLogHtml.pre(cgi.escape(item["logText"])) open(pathToLogHtml, "w").write(str(pageLogHtml)) os.chmod(pathToLogHtml, 0o644) page.p() page.a(item["linkText"], href_=os.path.basename(pathToLogHtml)) page.p.close() html = str(page) pagePath = os.path.join(pathToHtmlDir, nameOfIndexFile) filePage = open(pagePath, "w") filePage.write(html) filePage.close() return pagePath
def strategyResults(self): # Was the strategy successful? xsDataResultStrategy = self.xsDataResultCharacterisation.getStrategyResult() if xsDataResultStrategy is None: # Check if indexing and integration results xsDataResultIntegration = self.xsDataResultCharacterisation.getIntegrationResult() xsDataResultIndexing = self.xsDataResultCharacterisation.getIndexingResult() if xsDataResultIndexing is None: self.page.font(_color="red", size="+2") self.page.h2() self.page.strong("Strategy calculation not performed due to indexing failure, see the ") self.page.a("EDNA log file", href=self.strPageEDNALog) self.page.strong(" for more details") self.page.h2.close() self.page.font.close() elif xsDataResultIntegration is None: self.page.font(_color="red", size="+2") self.page.h2() self.page.strong("Strategy calculation not performed due to integration failure, see the ") self.page.a("EDNA log file", href=self.strPageEDNALog) self.page.strong(" for more details") self.page.h2.close() self.page.font.close() else: self.page.font(_color="red", size="+2") self.page.h2() self.page.strong("Strategy calculation failed, see the ") self.page.a("EDNA log file", href=self.strPageEDNALog) self.page.strong(" for more details") self.page.h2.close() self.page.font.close() else: # Add link to BEST log file: if xsDataResultStrategy.getBestLogFile(): strPathToBestLogFile = xsDataResultStrategy.getBestLogFile().getPath().getValue() if os.path.exists(strPathToBestLogFile): strPageBestLog = os.path.join(self.getWorkingDirectory(), "best_log.html") pageBestLog = markupv1_10.page() pageBestLog.h1("BEST Log") pageBestLog.a("Back to previous page", href_=self.strHtmlFileName) pageBestLog.pre(cgi.escape(EDUtilsFile.readFile(strPathToBestLogFile))) pageBestLog.a("Back to previous page", href_=self.strHtmlFileName) EDUtilsFile.writeFile(strPageBestLog, str(pageBestLog)) # Add link to RADDOSE log file: strPageRaddoseLog = None if xsDataResultStrategy.getRaddoseLogFile(): strPathToRaddoseLogFile = xsDataResultStrategy.getRaddoseLogFile().getPath().getValue() strPageRaddoseLog = os.path.join(self.getWorkingDirectory(), "raddose_log.html") if os.path.exists(strPathToRaddoseLogFile): pageRaddoseLog = markupv1_10.page() pageRaddoseLog.h1("RADDOSE Log") pageRaddoseLog.a("Back to previous page", href_=self.strHtmlFileName) pageRaddoseLog.pre(cgi.escape(EDUtilsFile.readFile(strPathToRaddoseLogFile))) pageRaddoseLog.a("Back to previous page", href_=self.strHtmlFileName) EDUtilsFile.writeFile(strPageRaddoseLog, str(pageRaddoseLog)) listXSDataCollectionPlan = xsDataResultStrategy.getCollectionPlan() if listXSDataCollectionPlan == []: self.page.font(_color="red", size="+2") self.page.h2() self.page.strong("Strategy calculation failed, see the ") self.page.a("BEST log file", href="best_log.html") self.page.strong(" for more details") if strPageRaddoseLog is not None: self.page.a(" (RADDOSE log file)", href="raddose_log.html") self.page.h2.close() self.page.font.close() else: iNoSubWedges = len(listXSDataCollectionPlan) self.page.h2() if iNoSubWedges != 1: self.page.strong("Multi-wedge collection plan strategy (") else: self.page.strong("Collection plan strategy (") if strPageRaddoseLog is not None: self.page.a("RADDOSE log file", href="raddose_log.html") self.page.strong(", ") self.page.a("BEST log file", href="best_log.html") self.page.strong(")") self.page.h2.close() # Check if ranking resolution is higher than the suggested strategy resolution(s) bHigherResolutionDetected = False fRankingResolution = None fResolutionMax = None fDistanceMin = None for xsDataCollectionPlan in listXSDataCollectionPlan: xsDataSummaryStrategy = xsDataCollectionPlan.getStrategySummary() xsDataCollectionStrategy = xsDataCollectionPlan.getCollectionStrategy() if xsDataSummaryStrategy.getRankingResolution(): # Retrieve the resolution... fResolution = xsDataSummaryStrategy.getResolution().getValue() # Retrieve the detector distance... fDistance = xsDataCollectionStrategy.getSubWedge()[0].getExperimentalCondition().getDetector().getDistance().getValue() if fResolutionMax is None: fResolutionMax = fResolution fDistanceMin = fDistance elif (fResolution < fResolutionMax) and (abs(fResolution - fResolutionMax) > 0.1): fResolutionMax = fResolution fDistanceMin = fDistance fRankingResolution = xsDataSummaryStrategy.getRankingResolution().getValue() if fRankingResolution != None and fResolutionMax != None: if fRankingResolution < fResolutionMax: if not bHigherResolutionDetected: self.page.font(_color="red", size="+2") self.page.i() self.page.h2("Best has detected that the sample can diffract to %.2f Å!" % fRankingResolution) self.page.i.close() self.page.font.close() self.page.font(_color="red", size="+1") self.page.strong("The current strategy is calculated to %.2f Å." % fResolutionMax) # self.page.strong("In order to calculate a strategy to %.2f Å set the detector distance to %.2f mm (%.2f Å) and re-launch the EDNA characterisation." % (fRankingResolution,fDistanceMin,fRankingResolution)) self.page.strong("In order to calculate a strategy to %.2f Å move the detector to collect %.2f Å data and re-launch the EDNA characterisation." % (fRankingResolution, fRankingResolution)) self.page.font.close() bHigherResolutionDetected = True for xsDataCollectionPlan in listXSDataCollectionPlan: xsDataSummaryStrategy = xsDataCollectionPlan.getStrategySummary() fResolutionMax = xsDataSummaryStrategy.getResolution().getValue() strResolutionReasoning = "" if xsDataSummaryStrategy.getResolutionReasoning(): strResolutionReasoning = xsDataSummaryStrategy.getResolutionReasoning().getValue() self.page.table(class_='indexResults', border_="1", cellpadding_="0") self.page.tr(align_="CENTER") self.page.th(strResolutionReasoning, colspan_="9", bgcolor_=self.strTableColourTitle1) self.page.tr.close() self.page.tr(align_="CENTER", bgcolor_=self.strTableColourTitle2) self.page.th("Wedge") self.page.th("Subwedge") self.page.th("Start (°)") self.page.th("Width (°)") self.page.th("No images") self.page.th("Exp time (s)") self.page.th("Max res (Å)") self.page.th("Rel trans (%)") self.page.th("Distance (mm)") self.page.tr.close() xsDataCollectionStrategy = xsDataCollectionPlan.getCollectionStrategy() for xsDataSubWegde in xsDataCollectionStrategy.getSubWedge(): xsDataExperimentalCondition = xsDataSubWegde.getExperimentalCondition() iWedge = xsDataCollectionPlan.getCollectionPlanNumber().getValue() iRunNumber = xsDataSubWegde.getSubWedgeNumber().getValue() fRotationAxisStart = xsDataExperimentalCondition.getGoniostat().getRotationAxisStart().getValue() fRotationAxisEnd = xsDataExperimentalCondition.getGoniostat().getRotationAxisEnd().getValue() fOscillationWidth = xsDataExperimentalCondition.getGoniostat().getOscillationWidth().getValue() iNumberOfImages = int((fRotationAxisEnd - fRotationAxisStart) / fOscillationWidth) fExposureTime = xsDataExperimentalCondition.getBeam().getExposureTime().getValue() fTransmission = xsDataExperimentalCondition.getBeam().getTransmission().getValue() fDistance = xsDataExperimentalCondition.getDetector().getDistance().getValue() self.page.tr(align_="CENTER", bgcolor_=self.strTableColourRows) self.page.th(iWedge) self.page.th(iRunNumber) self.page.th("%.2f" % fRotationAxisStart) self.page.th("%.2f" % fOscillationWidth) self.page.th(iNumberOfImages) self.page.th("%.2f" % fExposureTime) self.page.th("%.2f" % fResolutionMax) self.page.th("%.2f" % fTransmission) self.page.th("%.2f" % fDistance) self.page.tr.close() self.page.table.close()
def renderHtml(self, pathToHtmlDir, nameOfIndexFile="index.html"): page = markupv1_10.page(mode='loose_html') page.init(title=self.dictReport["title"], footer="Generated on %s" % time.asctime()) page.div(align_="LEFT") page.h1() page.strong(self.dictReport["title"]) page.h1.close() page.div.close() for item in self.dictReport["items"]: if item["type"] == "info": page.p(item["value"]) if item["type"] == "warning": page.font(_color="red", size="+1") page.p() page.strong(item["value"]) page.p.close() page.font.close() elif item["type"] == "image": self.__renderImage(page, item, pathToHtmlDir) page.br() page.p(item["title"]) elif item["type"] == "images": page.table() page.tr(align_="CENTER") for item in item["items"]: page.td() page.table() page.tr() page.td() self.__renderImage(page, item, pathToHtmlDir) page.td.close() page.tr.close() page.tr(align_="CENTER") page.td(item["title"]) page.tr.close() page.table.close() page.td.close() page.tr.close() page.table.close() page.br() elif item["type"] == "table": page.h3() page.strong(item["title"]) page.h3.close() page.table(border_="1", cellpadding_="2") if "orientation" in item and item["orientation"] == "vertical": for index1 in range(len(item["columns"])): page.tr(align_="CENTER") page.th(item["columns"][index1].replace("\n", "<br>"), bgcolor_="#F0F0FF", align_="LEFT") for index2 in range(len(item["data"])): page.th(str(item["data"][index2][index1]).replace("\n", "<br>"), bgcolor_="#FFFFA0") page.tr.close() else: page.tr(align_="CENTER", bgcolor_="#F0F0FF") for column in item["columns"]: page.th(column.replace("\n", "<br>")) page.tr.close() for listRow in item["data"]: page.tr(align_="CENTER", bgcolor_="#FFFFA0") for cell in listRow: page.th(str(cell).replace("\n", "<br>")) page.tr.close() page.table.close() elif item["type"] == "logFile": pathToLogHtml = tempfile.mkstemp(suffix=".html", prefix=item["title"].replace(" ", "_") + "_", dir=pathToHtmlDir)[1] pageLogHtml = markupv1_10.page() pageLogHtml.h1(item["title"]) pageLogHtml.pre(cgi.escape(item["logText"])) open(pathToLogHtml, "w").write(str(pageLogHtml)) os.chmod(pathToLogHtml, 0o644) page.p() page.a(item["linkText"], href_=os.path.basename(pathToLogHtml)) page.p.close() html = str(page) pagePath = os.path.join(pathToHtmlDir, nameOfIndexFile) filePage = open(pagePath, "w") filePage.write(html) filePage.close() return pagePath
def strategyResults(self): # Was the strategy successful? xsDataResultStrategy = self.xsDataResultCharacterisation.getStrategyResult( ) if xsDataResultStrategy is None: # Check if indexing and integration results xsDataResultIntegration = self.xsDataResultCharacterisation.getIntegrationResult( ) xsDataResultIndexing = self.xsDataResultCharacterisation.getIndexingResult( ) if xsDataResultIndexing is None: self.page.font(_color="red", size="+2") self.page.h2() self.page.strong( "Strategy calculation not performed due to indexing failure, see the " ) self.page.a("EDNA log file", href=self.strPageEDNALog) self.page.strong(" for more details") self.page.h2.close() self.page.font.close() elif xsDataResultIntegration is None: self.page.font(_color="red", size="+2") self.page.h2() self.page.strong( "Strategy calculation not performed due to integration failure, see the " ) self.page.a("EDNA log file", href=self.strPageEDNALog) self.page.strong(" for more details") self.page.h2.close() self.page.font.close() else: self.page.font(_color="red", size="+2") self.page.h2() self.page.strong("Strategy calculation failed, see the ") self.page.a("EDNA log file", href=self.strPageEDNALog) self.page.strong(" for more details") self.page.h2.close() self.page.font.close() else: # Add link to BEST log file: if xsDataResultStrategy.getBestLogFile(): strPathToBestLogFile = xsDataResultStrategy.getBestLogFile( ).getPath().getValue() if os.path.exists(strPathToBestLogFile): strPageBestLog = os.path.join(self.getWorkingDirectory(), "best_log.html") pageBestLog = markupv1_10.page() pageBestLog.h1("BEST Log") pageBestLog.a("Back to previous page", href_=self.strHtmlFileName) pageBestLog.pre( cgi.escape(EDUtilsFile.readFile(strPathToBestLogFile))) pageBestLog.a("Back to previous page", href_=self.strHtmlFileName) EDUtilsFile.writeFile(strPageBestLog, str(pageBestLog)) # Add link to RADDOSE log file: strPageRaddoseLog = None if xsDataResultStrategy.getRaddoseLogFile(): strPathToRaddoseLogFile = xsDataResultStrategy.getRaddoseLogFile( ).getPath().getValue() strPageRaddoseLog = os.path.join(self.getWorkingDirectory(), "raddose_log.html") if os.path.exists(strPathToRaddoseLogFile): pageRaddoseLog = markupv1_10.page() pageRaddoseLog.h1("RADDOSE Log") pageRaddoseLog.a("Back to previous page", href_=self.strHtmlFileName) pageRaddoseLog.pre( cgi.escape( EDUtilsFile.readFile(strPathToRaddoseLogFile))) pageRaddoseLog.a("Back to previous page", href_=self.strHtmlFileName) EDUtilsFile.writeFile(strPageRaddoseLog, str(pageRaddoseLog)) listXSDataCollectionPlan = xsDataResultStrategy.getCollectionPlan() if listXSDataCollectionPlan == []: self.page.font(_color="red", size="+2") self.page.h2() self.page.strong("Strategy calculation failed, see the ") self.page.a("BEST log file", href="best_log.html") self.page.strong(" for more details") if strPageRaddoseLog is not None: self.page.a(" (RADDOSE log file)", href="raddose_log.html") self.page.h2.close() self.page.font.close() else: iNoSubWedges = len(listXSDataCollectionPlan) self.page.h2() if iNoSubWedges != 1: self.page.strong("Multi-wedge collection plan strategy (") else: self.page.strong("Collection plan strategy (") if strPageRaddoseLog is not None: self.page.a("RADDOSE log file", href="raddose_log.html") self.page.strong(", ") self.page.a("BEST log file", href="best_log.html") self.page.strong(")") self.page.h2.close() # Check if ranking resolution is higher than the suggested strategy resolution(s) bHigherResolutionDetected = False fRankingResolution = None fResolutionMax = None fDistanceMin = None for xsDataCollectionPlan in listXSDataCollectionPlan: xsDataSummaryStrategy = xsDataCollectionPlan.getStrategySummary( ) xsDataCollectionStrategy = xsDataCollectionPlan.getCollectionStrategy( ) if xsDataSummaryStrategy.getRankingResolution(): # Retrieve the resolution... fResolution = xsDataSummaryStrategy.getResolution( ).getValue() # Retrieve the detector distance... fDistance = xsDataCollectionStrategy.getSubWedge( )[0].getExperimentalCondition().getDetector( ).getDistance().getValue() if fResolutionMax is None: fResolutionMax = fResolution fDistanceMin = fDistance elif (fResolution < fResolutionMax) and ( abs(fResolution - fResolutionMax) > 0.1): fResolutionMax = fResolution fDistanceMin = fDistance fRankingResolution = xsDataSummaryStrategy.getRankingResolution( ).getValue() if fRankingResolution != None and fResolutionMax != None: if fRankingResolution < fResolutionMax: if not bHigherResolutionDetected: self.page.font(_color="red", size="+2") self.page.i() self.page.h2( "Best has detected that the sample can diffract to %.2f Å!" % fRankingResolution) self.page.i.close() self.page.font.close() self.page.font(_color="red", size="+1") self.page.strong( "The current strategy is calculated to %.2f Å." % fResolutionMax) # self.page.strong("In order to calculate a strategy to %.2f Å set the detector distance to %.2f mm (%.2f Å) and re-launch the EDNA characterisation." % (fRankingResolution,fDistanceMin,fRankingResolution)) self.page.strong( "In order to calculate a strategy to %.2f Å move the detector to collect %.2f Å data and re-launch the EDNA characterisation." % (fRankingResolution, fRankingResolution)) self.page.font.close() bHigherResolutionDetected = True for xsDataCollectionPlan in listXSDataCollectionPlan: xsDataSummaryStrategy = xsDataCollectionPlan.getStrategySummary( ) fResolutionMax = xsDataSummaryStrategy.getResolution( ).getValue() strResolutionReasoning = "" if xsDataSummaryStrategy.getResolutionReasoning(): strResolutionReasoning = xsDataSummaryStrategy.getResolutionReasoning( ).getValue() self.page.table(class_='indexResults', border_="1", cellpadding_="0") self.page.tr(align_="CENTER") self.page.th(strResolutionReasoning, colspan_="9", bgcolor_=self.strTableColourTitle1) self.page.tr.close() self.page.tr(align_="CENTER", bgcolor_=self.strTableColourTitle2) self.page.th("Wedge") self.page.th("Subwedge") self.page.th("Start (°)") self.page.th("Width (°)") self.page.th("No images") self.page.th("Exp time (s)") self.page.th("Max res (Å)") self.page.th("Rel trans (%)") self.page.th("Distance (mm)") self.page.tr.close() xsDataCollectionStrategy = xsDataCollectionPlan.getCollectionStrategy( ) for xsDataSubWegde in xsDataCollectionStrategy.getSubWedge( ): xsDataExperimentalCondition = xsDataSubWegde.getExperimentalCondition( ) iWedge = xsDataCollectionPlan.getCollectionPlanNumber( ).getValue() iRunNumber = xsDataSubWegde.getSubWedgeNumber( ).getValue() fRotationAxisStart = xsDataExperimentalCondition.getGoniostat( ).getRotationAxisStart().getValue() fRotationAxisEnd = xsDataExperimentalCondition.getGoniostat( ).getRotationAxisEnd().getValue() fOscillationWidth = xsDataExperimentalCondition.getGoniostat( ).getOscillationWidth().getValue() iNumberOfImages = int( (fRotationAxisEnd - fRotationAxisStart) / fOscillationWidth) fExposureTime = xsDataExperimentalCondition.getBeam( ).getExposureTime().getValue() fTransmission = xsDataExperimentalCondition.getBeam( ).getTransmission().getValue() fDistance = xsDataExperimentalCondition.getDetector( ).getDistance().getValue() self.page.tr(align_="CENTER", bgcolor_=self.strTableColourRows) self.page.th(iWedge) self.page.th(iRunNumber) self.page.th("%.2f" % fRotationAxisStart) self.page.th("%.2f" % fOscillationWidth) self.page.th(iNumberOfImages) self.page.th("%.2f" % fExposureTime) self.page.th("%.2f" % fResolutionMax) self.page.th("%.2f" % fTransmission) self.page.th("%.2f" % fDistance) self.page.tr.close() self.page.table.close()