本文整理汇总了Python中mrq.dashboard.utils.jsonify函数的典型用法代码示例。如果您正苦于以下问题:Python jsonify函数的具体用法?Python jsonify怎么用?Python jsonify使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了jsonify函数的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: api
def api(*func_args, **func_kwgs):
args = request.args.to_dict()
try:
params = schema.validate(args)
return jsonify(func(**params))
except SchemaError as ex:
return jsonify(ApiErrorBuild('%s:%s' % (ex.__class__.__name__, ex), 511))
开发者ID:wowngasb,项目名称:kl_tool,代码行数:7,代码来源:tool.py
示例2: api_job_result
def api_job_result(job_id):
collection = connections.mongodb_jobs.mrq_jobs
job_data = collection.find_one({"_id": ObjectId(job_id)}, projection=["result"])
if not job_data:
return jsonify({})
return jsonify({"result": job_data.get("result")})
开发者ID:sebastiken,项目名称:mrq,代码行数:8,代码来源:app.py
示例3: api_job_action
def api_job_action():
params = {k: v for k, v in request.form.iteritems()}
if params.get("status") and "-" in params.get("status"):
params["status"] = params.get("status").split("-")
return jsonify({"job_id": queue_job("mrq.basetasks.utils.JobAction",
params,
queue=get_current_config()["dashboard_queue"])})
开发者ID:benjisg,项目名称:mrq,代码行数:7,代码来源:app.py
示例4: api_queue_job
def api_queue_job(task): #存在参数相互依赖的关系 无法使用 ApiSchemaWrapper
queue = request.args.get('queue', '').strip()
args = request.args.to_dict()
params, err = fixTaskParams(MRQ_TASK_DICT, task, args)
rst = ApiErrorBuild()
rst = {"job_id": queue_job(task, params, queue=queue if queue else None)} if err is None else err
return jsonify(rst)
开发者ID:wowngasb,项目名称:kl_tool,代码行数:8,代码来源:mrq-dashboard.py
示例5: api_job_traceback
def api_job_traceback(job_id):
collection = connections.mongodb_jobs.mrq_jobs
job_data = collection.find_one({"_id": ObjectId(job_id)}, projection=["traceback"])
if not job_data:
job_data = {}
return jsonify({"traceback": job_data.get("traceback", "No exception raised")})
开发者ID:sebastiken,项目名称:mrq,代码行数:8,代码来源:app.py
示例6: api_taskpaths
def api_taskpaths():
stats = list(connections.mongodb_jobs.mrq_jobs.aggregate([
{"$sort": {"path": 1}}, # https://jira.mongodb.org/browse/SERVER-11447
{"$group": {"_id": "$path", "jobs": {"$sum": 1}}}
]))
stats.sort(key=lambda x: -x["jobs"])
data = {
"aaData": stats,
"iTotalDisplayRecords": len(stats)
}
data["sEcho"] = request.args["sEcho"]
return jsonify(data)
开发者ID:benjisg,项目名称:mrq,代码行数:16,代码来源:app.py
示例7: api_task_exceptions
def api_task_exceptions():
stats = list(connections.mongodb_jobs.mrq_jobs.aggregate([
{"$match": {"status": "failed"}},
{"$group": {"_id": {"path": "$path", "exceptiontype": "$exceptiontype"}, "jobs": {"$sum": 1}}},
])["result"])
stats.sort(key=lambda x: -x["jobs"])
start = int(request.args.get("iDisplayStart", 0))
end = int(request.args.get("iDisplayLength", 20)) + start
data = {
"aaData": stats[start:end],
"iTotalDisplayRecords": len(stats)
}
data["sEcho"] = request.args["sEcho"]
return jsonify(data)
开发者ID:bossjones,项目名称:mrq,代码行数:18,代码来源:app.py
示例8: api_job_traceback
def api_job_traceback(job_id):
collection = connections.mongodb_jobs.mrq_jobss
if get_current_config().get("save_traceback_history"):
field_sent = "traceback_history"
else:
field_sent = "traceback"
job_data = collection.find_one(
{"_id": ObjectId(job_id)}, projection=[field_sent])
if not job_data:
# If a job has no traceback history, we fallback onto traceback
if field_sent == "traceback_history":
field_sent = "traceback"
job_data = collection.find_one(
{"_id": ObjectId(job_id)}, projection=[field_sent])
if not job_data:
job_data = {}
return jsonify({
field_sent: job_data.get(field_sent, "No exception raised")
})
开发者ID:pricingassistant,项目名称:mrq,代码行数:23,代码来源:app.py
示例9: api_logs
def api_logs():
collection = connections.mongodb_logs.mrq_logs
if request.args.get("job"):
query = {"job": ObjectId(request.args.get("job"))}
elif request.args.get("worker"):
query = {"worker": ObjectId(request.args.get("worker"))}
else:
raise Exception("No ID")
if request.args.get("last_log_id"):
query["_id"] = {"$gt": ObjectId(request.args.get("min_log_id"))}
logs = list(collection.find(query, projection={"_id": 1, "logs": 1}))
data = {
"logs": "\n".join([lines["logs"] for lines in logs]),
# Don't be surprised, this will send unexisting ObjectIds when we're up
# to date!
"last_log_id": logs[-1]["_id"] if len(logs) else ObjectId(),
}
return jsonify(data)
开发者ID:sebastiken,项目名称:mrq,代码行数:23,代码来源:app.py
示例10: api_datatables
def api_datatables(unit):
# import time
# time.sleep(5)
collection = None
sort = None
skip = int(request.args.get("iDisplayStart", 0))
limit = int(request.args.get("iDisplayLength", 20))
if unit == "queues":
queues = []
for name, jobs in Queue.all_known().items():
queue = Queue(name)
q = {
"name": name,
"jobs": jobs, # MongoDB size
"size": queue.size(), # Redis size
"is_sorted": queue.is_sorted,
"is_timed": queue.is_timed,
"is_raw": queue.is_raw,
"is_set": queue.is_set
}
if queue.is_sorted:
raw_config = cfg.get("raw_queues", {}).get(name, {})
q["graph_config"] = raw_config.get("dashboard_graph", lambda: {
"start": time.time() - (7 * 24 * 3600),
"stop": time.time() + (7 * 24 * 3600),
"slices": 30
} if queue.is_timed else {
"start": 0,
"stop": 100,
"slices": 30
})()
if q["graph_config"]:
q["graph"] = queue.get_sorted_graph(**q["graph_config"])
if queue.is_timed:
q["jobs_to_dequeue"] = queue.count_jobs_to_dequeue()
queues.append(q)
queues.sort(key=lambda x: -(x["jobs"] + x["size"]))
data = {
"aaData": queues,
"iTotalDisplayRecords": len(queues)
}
elif unit == "workers":
fields = None
query = {"status": {"$nin": ["stop"]}}
collection = connections.mongodb_jobs.mrq_workers
sort = [("datestarted", -1)]
if request.args.get("showstopped"):
query = {}
elif unit == "scheduled_jobs":
collection = connections.mongodb_jobs.mrq_scheduled_jobs
fields = None
query = {}
elif unit == "jobs":
fields = None
query = build_api_datatables_query(request)
sort = [("_id", 1)]
# We can't search easily params because we store it as decoded JSON in mongo :(
# Add a string index?
# if request.args.get("sSearch"):
# query.update(json.loads(request.args.get("sSearch")))
collection = connections.mongodb_jobs.mrq_jobs
if collection is not None:
cursor = collection.find(query, projection=fields)
if sort:
cursor.sort(sort)
if skip is not None:
cursor.skip(skip)
if limit is not None:
cursor.limit(limit)
data = {
"aaData": list(cursor),
"iTotalDisplayRecords": collection.find(query).count()
}
data["sEcho"] = request.args["sEcho"]
return jsonify(data)
开发者ID:benjisg,项目名称:mrq,代码行数:98,代码来源:app.py
示例11: get_workers
def get_workers():
collection = connections.mongodb_jobs.mrq_workers
cursor = collection.find({"status": {"$ne": "stop"}})
data = {"workers": list(cursor)}
return jsonify(data)
开发者ID:benjisg,项目名称:mrq,代码行数:5,代码来源:app.py
示例12: route_index
def route_index():
report = self.get_worker_report()
report.update({"_id": self.id})
return jsonify(report)
开发者ID:nfredrik,项目名称:mrq,代码行数:4,代码来源:worker.py
示例13: api_job_action
def api_job_action():
return jsonify({
"job_id": send_task("mrq.basetasks.utils.JobAction", {k: v for k, v in request.form.iteritems()}, queue=get_current_config()["dashboard_queue"])
})
开发者ID:bossjones,项目名称:mrq,代码行数:4,代码来源:app.py
注:本文中的mrq.dashboard.utils.jsonify函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论