def list_file_templates(manager, options): header = [ 'Name', 'Use with', TerminalTable.Column('Full Path', overflow='fold'), TerminalTable.Column('Contents', overflow='ignore'), ] table = TerminalTable(*header, table_type=options.table_type, show_lines=True) console('Fetching all file templates, stand by...') for template_name in list_templates(extensions=['template']): if options.name and not options.name in template_name: continue template = get_template(template_name) if 'entries' in template_name: plugin = 'notify_entries' elif 'task' in template_name: plugin = 'notify_task' else: plugin = '-' name = template_name.replace('.template', '').split('/')[-1] with open(template.filename) as contents: table.add_row(name, plugin, template.filename, contents.read().strip()) console(table)
def list_failed(options): with Session() as session: results = session.query(db.FailedEntry).all() header = [ TerminalTable.Column('#', justify='center'), 'Title', 'Fail count', 'Reason', 'Failure time', ] table = TerminalTable(*header, table_type=options.table_type) for entry in results: table.add_row( str(entry.id), entry.title, str(entry.count), '' if entry.reason == 'None' else entry.reason, entry.tof.strftime('%Y-%m-%d %H:%M'), ) console(table)