Package coprs :: Package views :: Package status_ns :: Module status_general
[hide private]
[frames] | no frames]

Source Code for Module coprs.views.status_ns.status_general

  1  import flask 
  2  from time import time 
  3   
  4  from copr_common.enums import StatusEnum 
  5  from coprs.views.status_ns import status_ns 
  6  from coprs.logic import batches_logic 
  7  from coprs.logic import builds_logic 
  8  from coprs.logic import complex_logic 
9 10 11 @status_ns.context_processor 12 -def inject_common_blueprint_variables():
13 return dict(queue_sizes=complex_logic.ComplexLogic.get_queue_sizes())
14
15 16 @status_ns.route("/") 17 @status_ns.route("/pending/") 18 -def pending():
19 rpm_tasks = builds_logic.BuildsLogic.get_pending_build_tasks(background=False).all() 20 bg_tasks_cnt = builds_logic.BuildsLogic.get_pending_build_tasks(background=True).count() 21 tasks = list(zip(["rpm"] * len(rpm_tasks), 22 [x.build.submitted_on for x in rpm_tasks], 23 rpm_tasks)) 24 srpm_tasks = builds_logic.BuildsLogic.get_pending_srpm_build_tasks(background=False).all() 25 bg_tasks_cnt += builds_logic.BuildsLogic.get_pending_srpm_build_tasks(background=True).count() 26 srpm_tasks = list(zip(["srpm"] * len(srpm_tasks), 27 [x.submitted_on for x in srpm_tasks], 28 srpm_tasks)) 29 tasks.extend(srpm_tasks) 30 return render_status("pending", tasks=tasks, bg_tasks_cnt=bg_tasks_cnt)
31
32 33 @status_ns.route("/running/") 34 -def running():
35 rpm_tasks = builds_logic.BuildsLogic.get_build_tasks(StatusEnum("running")).all() 36 tasks = list(zip(["rpm"] * len(rpm_tasks), 37 [x.started_on for x in rpm_tasks], 38 rpm_tasks)) 39 srpm_tasks = builds_logic.BuildsLogic.get_srpm_build_tasks(StatusEnum("running")).all() 40 srpm_tasks = list(zip(["srpm"] * len(srpm_tasks), 41 [x.submitted_on for x in srpm_tasks], 42 srpm_tasks)) 43 tasks.extend(srpm_tasks) 44 return render_status("running", tasks=tasks)
45
46 47 @status_ns.route("/importing/") 48 -def importing():
49 tasks = builds_logic.BuildsLogic.get_build_importing_queue(background=False).all() 50 bg_tasks_cnt = builds_logic.BuildsLogic.get_build_importing_queue(background=True).count() 51 tasks = list(zip(["rpm"] * len(tasks), 52 [x.submitted_on for x in tasks], 53 tasks)) 54 return render_status("importing", tasks=tasks, bg_tasks_cnt=bg_tasks_cnt)
55
56 57 @status_ns.route("/starting/") 58 -def starting():
59 tasks = builds_logic.BuildsLogic.get_build_tasks(StatusEnum("starting")).all() 60 tasks = list(zip(["rpm"] * len(tasks), 61 [x.build.submitted_on for x in tasks], 62 tasks)) 63 srpm_tasks = builds_logic.BuildsLogic.get_srpm_build_tasks(StatusEnum("starting")).all() 64 srpm_tasks = list(zip(["srpm"] * len(srpm_tasks), 65 [x.submitted_on for x in srpm_tasks], 66 srpm_tasks)) 67 tasks.extend(srpm_tasks) 68 return render_status("starting", tasks=tasks)
69
70 71 -def render_status(build_status, tasks, bg_tasks_cnt=None):
72 return flask.render_template("status.html", number=len(tasks), 73 tasks=tasks, bg_tasks_cnt=bg_tasks_cnt, 74 state_of_tasks=build_status)
75
76 77 @status_ns.route("/batches/") 78 -def batches():
79 """ Print the list (tree) of batches """ 80 trees = batches_logic.BatchesLogic.pending_batch_trees() 81 return flask.render_template("status/batch_list.html", batch_trees=trees)
82
83 84 @status_ns.route("/batches/detail/<int:batch_id>/") 85 -def coprs_batch_detail(batch_id):
86 """ Print the list (tree) of batches """ 87 chain = batches_logic.BatchesLogic.batch_chain(batch_id) 88 batch = chain[0] 89 deps = chain[1:] 90 return flask.render_template("batches/detail.html", batch=batch, deps=deps)
91
92 93 @status_ns.route("/stats/") 94 -def stats():
95 curr_time = int(time()) 96 chroots_24h = builds_logic.BuildsLogic.get_chroot_histogram(curr_time - 86400, curr_time) 97 chroots_90d = builds_logic.BuildsLogic.get_chroot_histogram(curr_time - 90*86400, curr_time) 98 data_24h = builds_logic.BuildsLogic.get_task_graph_data('10min') 99 data_90d = builds_logic.BuildsLogic.get_task_graph_data('24h') 100 actions_24h = builds_logic.ActionsLogic.get_action_graph_data('10min') 101 actions_90d = builds_logic.ActionsLogic.get_action_graph_data('24h') 102 103 return flask.render_template("status/stats.html", 104 data1=data_24h, 105 data2=data_90d, 106 chroots1=chroots_24h, 107 chroots2=chroots_90d, 108 actions1=actions_24h, 109 actions2=actions_90d 110 )
111