def list_emails_template(self,start=0,count=30): title='SHIVA honeypot: list emails' headline_title = 'SHIVA honeypot: list {0} emails starting from {1}'.format(start,count) overview_list=backend_operations.get_overview(start,count) total = backend_operations.get_mail_count() template = Template('<%include file="list_emails.html"/>', lookup=self.template_lookup) return template.render(headline=headline_title, title=title, overview_list=overview_list, total=int(total), start=int(start), count=int(count))
def index_template(self): title='SHIVA honeypot: mainpage' start = 0 count = 10 overview_list=backend_operations.get_overview(start,count) learning_overview_list=backend_operations.get_learning_overview(5) total_mails = backend_operations.get_mail_count() today_mails = backend_operations.get_mail_count_for_date(datetime.date.today(), datetime.date.today() + datetime.timedelta(days=1)) uptime_str = 'uknown' uptime = time.time() - self.startup_time if self.startup_time else 0 if uptime > 0: days, remainder = divmod(uptime, 24 * 60 * 60) hours, remainder = divmod(remainder, 60 * 60) minutes, _ = divmod(remainder, 60) uptime_str = "{:.0f} days {:.0f} hours {:.0f} minutes".format(days,hours,minutes) template = Template('<%include file="index.html"/>', lookup=self.template_lookup, output_encoding='utf-8', encoding_errors='replace') return template.render(title=title, overview_list=overview_list, start=start,count=count,report_overview=learning_overview_list, uptime=uptime_str, total_mails=total_mails, today_mails=today_mails)