tasks = {} for updatetime, task in sorted(rpc.get_active_tasks(limit), key=lambda x: x[0]): task['updatetime'] = updatetime tasks['%(project)s:%(taskid)s' % task] = task return render_template("tasks.html", tasks=tasks.values(), status_to_string=taskdb.status_to_string) @app.route('/active_tasks') def active_tasks(): rpc = app.config['scheduler_rpc'] taskdb = app.config['taskdb'] limit = int(request.args.get('limit', 100)) tasks = rpc.get_active_tasks(limit) result = [] for updatetime, task in tasks: task['updatetime'] = updatetime task['updatetime_text'] = utils.format_date(updatetime) if 'status' in task: task['status_text'] = taskdb.status_to_string(task['status']) result.append(task) return json.dumps(result), 200, {'Content-Type': 'application/json'} app.template_filter('format_date')(utils.format_date)
taskdb = app.config['taskdb'] project = request.args.get('project', "") limit = int(request.args.get('limit', 100)) tasks = {} for updatetime, task in sorted( rpc.get_active_tasks(project, limit), key=lambda x: x[0]): task['updatetime'] = updatetime tasks['%(project)s:%(taskid)s' % task] = task return render_template("tasks.html", tasks=tasks.values(), status_to_string=taskdb.status_to_string) @app.route('/active_tasks') def active_tasks(): rpc = app.config['scheduler_rpc'] taskdb = app.config['taskdb'] limit = int(request.args.get('limit', 100)) tasks = rpc.get_active_tasks(limit) result = [] for updatetime, task in tasks: task['updatetime'] = updatetime task['updatetime_text'] = utils.format_date(updatetime) if 'status' in task: task['status_text'] = taskdb.status_to_string(task['status']) result.append(task) return json.dumps(result), 200, {'Content-Type': 'application/json'} app.template_filter('format_date')(utils.format_date)
from bson import ObjectId from flask import ( Markup, url_for, ) import simplejson as json import time import urllib import urlparse from app import app, mongo, strip_tags app.template_filter('Markup')(Markup) @app.template_filter('bot_steamid') def bot_steamid(s): bot = mongo.db.bots.find_one({'_id': ObjectId(s)}, {'steamid': 1}) if bot: return bot['steamid'] @app.template_filter('strip') def strip(s): return strip_tags(s) @app.template_filter('json') def json_encode(s): return Markup(json.dumps(s)) @app.template_filter('bool') def bool_encode(d): return bool(d)