summaryrefslogtreecommitdiff
path: root/ick2/workapi.py
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2018-05-25 20:46:35 +0300
committerLars Wirzenius <liw@liw.fi>2018-05-28 18:18:38 +0300
commitf18a394d0279cf2dc3a768a0470fea2201cad016 (patch)
treec57d671f0e32056a5db6fac60d3bbe90b2187e9b /ick2/workapi.py
parent7a4c92e7171d642a1e1fce324441710ad4d44ce9 (diff)
downloadick2-f18a394d0279cf2dc3a768a0470fea2201cad016.tar.gz
Add: BuildGraph.has_more_to_do method, refactor
Diffstat (limited to 'ick2/workapi.py')
-rw-r--r--ick2/workapi.py39
1 files changed, 12 insertions, 27 deletions
diff --git a/ick2/workapi.py b/ick2/workapi.py
index a2d76d9..c054f0a 100644
--- a/ick2/workapi.py
+++ b/ick2/workapi.py
@@ -134,21 +134,20 @@ class WorkAPI(ick2.APIbase):
if exit_code is not None:
if exit_code == 0:
- self._finish_action(graph, action_id, 'done')
- if self._build_finished(graph):
- self._finish_build(build, 0)
-
- worker.from_dict({
- 'worker': worker_id,
- 'doing': {},
- })
+ graph.set_action_status(action_id, 'done')
+ graph.unblock()
+ if not graph.has_more_to_do():
+ build_obj.set_status('done')
+ build['status'] = 0
elif exit_code is not None:
graph.set_action_status(action_id, 'failed')
- self._finish_build(build, exit_code)
- worker.from_dict({
- 'worker': worker_id,
- 'doing': {},
- })
+ build_obj.set_status('failed')
+ build['status'] = exit_code
+
+ worker.from_dict({
+ 'worker': worker_id,
+ 'doing': {},
+ })
def _check_work_update(self, doing, update): # pragma: no cover
must_match = ['worker', 'project', 'build_id']
@@ -167,20 +166,6 @@ class WorkAPI(ick2.APIbase):
text = update.get(stream, '')
log['log'] = log.get('log', '') + text
- def _finish_action(self, graph, action_id, status):
- graph.set_action_status(action_id, status)
- if status == 'done':
- graph.unblock()
-
- def _build_finished(self, graph):
- return (
- graph.find_actions('ready') == [] and
- graph.find_actions('blocked') == []
- )
-
- def _finish_build(self, build, exit_code):
- build['status'] = exit_code
-
def create(self, body, **kwargs): # pragma: no cover
pass