def loadConfiguration(self): """Process report template for configuration """ if os.path.exists(self.report_template_file): template_file = open(self.report_template_file) file_string = template_file.read() self.report_template = etree.fromstring(file_string) template_file.close() self.title = get_config(self.report_template, "title", self.title) self.language = get_config(self.report_template, "language", get_default_language() ) coverage_text = get_config(self.report_template, "length") if coverage_text is not None: self.coverage = report_tools.compute_hours(coverage_text) drop_element( self.report_template.find("{%s}config" % BUNGENI_REPORTS_NS) ) else: raise ReportException( _(u"report-template-missing", default=u"Report template file does not exist at ${path}", mapping={"path": self.report_template_file} ) )
def load_configuration(self): """Process report template for configuration """ if os.path.exists(self.report_template_path): template_file = open(self.report_template_path) file_string = template_file.read() self.report_template = etree.fromstring(file_string) template_file.close() self.title = get_config(self.report_template, "title", self.title) self.language = get_config(self.report_template, "language", get_default_language()) coverage_text = get_config(self.report_template, "length") if coverage_text is not None: self.coverage = report_tools.compute_hours(coverage_text) drop_element( self.report_template.find("{%s}config" % BUNGENI_REPORTS_NS)) else: raise ReportException( _(u"report-template-missing", default=u"Report template file does not exist at ${path}", mapping={"path": self.report_template_path}))
def notification_time(time_string): """Takes a time config string and computes the notification time """ hours = report_tools.compute_hours(time_string) return datetime.datetime.now() + datetime.timedelta(hours=hours)