本文整理汇总了Python中lib.cuckoo.core.database.Database.minmax_tasks方法的典型用法代码示例。如果您正苦于以下问题:Python Database.minmax_tasks方法的具体用法?Python Database.minmax_tasks怎么用?Python Database.minmax_tasks使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lib.cuckoo.core.database.Database
的用法示例。
在下文中一共展示了Database.minmax_tasks方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: index
# 需要导入模块: from lib.cuckoo.core.database import Database [as 别名]
# 或者: from lib.cuckoo.core.database.Database import minmax_tasks [as 别名]
def index(request):
db = Database()
report = dict(
total_samples=db.count_samples(),
total_tasks=db.count_tasks(),
states_count={},
estimate_hour=None,
estimate_day=None
)
states = (
TASK_PENDING,
TASK_RUNNING,
TASK_COMPLETED,
TASK_RECOVERED,
TASK_REPORTED,
TASK_FAILED_ANALYSIS,
TASK_FAILED_PROCESSING,
TASK_FAILED_REPORTING
)
for state in states:
report["states_count"][state] = db.count_tasks(state)
offset = None
# For the following stats we're only interested in completed tasks.
tasks = db.count_tasks(status=TASK_COMPLETED)
tasks += db.count_tasks(status=TASK_REPORTED)
if tasks:
# Get the time when the first task started and last one ended.
started, completed = db.minmax_tasks()
# It has happened that for unknown reasons completed and started were
# equal in which case an exception is thrown, avoid this.
if completed and started and int(completed - started):
hourly = 60 * 60 * tasks / (completed - started)
else:
hourly = 0
report["estimate_hour"] = int(hourly)
report["estimate_day"] = int(24 * hourly)
return render(request, "dashboard/index.html", {
"report": report,
})