Package PyFoam :: Package Applications :: Module CommonReportRunnerData
[hide private]
[frames] | no frames]

Source Code for Module PyFoam.Applications.CommonReportRunnerData

 1  """ 
 2  Class that implements the common functionality for reporting the data that was submitted to the runner 
 3  """ 
 4   
 5  from PyFoam.Basics.RestructuredTextHelper import ReSTTable,RestructuredTextHelper 
 6   
7 -class CommonReportRunnerData(object):
8 """ The class that reports the resource usage 9 """ 10
11 - def addOptions(self):
12 self.ensureGeneralOptions() 13 self.generalOpts.add_option("--report-runner-data", 14 action="store_true", 15 default=False, 16 dest="reportRunnerData", 17 help="After the execution the data collected by the runner (except for the analyzed data) is printed to the screen") 18 self.generalOpts.add_option("--report-analyzed-data", 19 action="store_true", 20 default=False, 21 dest="reportAnalyzedData", 22 help="After the execution the analyzed data collected by the runner is printed to the screen") 23 self.generalOpts.add_option("--dump-runner-data", 24 action="store_true", 25 default=False, 26 dest="dumpRunnerData", 27 help="After the execution the data collected by the runner is dumped")
28
29 - def reportRunnerData(self,run):
30 if self.opts.reportRunnerData: 31 try: 32 data=run.data["analyzed"] 33 except KeyError: 34 self.error("No analyzed data") 35 36 print "\n Analyzed data:" 37 print 38 39 helper=RestructuredTextHelper(RestructuredTextHelper.LevelSubSubSection) 40 41 for n,d in data.iteritems(): 42 table=helper.table() 43 heads=["Descrition","value"] 44 table[0]=heads 45 table.addLine(head=True) 46 lNr=1 47 48 for k,v in d.iteritems(): 49 table[(lNr,0)]=k 50 table[(lNr,1)]=v 51 lNr+=1 52 53 print helper.heading(n),table 54 55 if self.opts.reportRunnerData: 56 table=ReSTTable() 57 heads=["Descrition","value"] 58 table[0]=heads 59 table.addLine(head=True) 60 lNr=1 61 done=["analyzed"] 62 63 def addLine(key,description): 64 if key in run.data: 65 table[(lNr,0)]=description 66 table[(lNr,1)]=run.data[key] 67 done.append(key) 68 return lNr+1 69 return lNr
70 71 lNr=addLine("time","Last simulation time") 72 lNr=addLine("stepNr","Number of timesteps") 73 lNr=addLine("lines","Lines written to stdout") 74 lNr=addLine("warnings","Number of warnings") 75 76 table.addLine() 77 78 for k,v in run.data.iteritems(): 79 if k not in done: 80 table[(lNr,0)]=k 81 table[(lNr,1)]=v 82 lNr+=1 83 84 print "\n Runner data:" 85 print 86 print table 87 88 if self.opts.dumpRunnerData: 89 print "\n Runner data:",run.data
90