summaryrefslogtreecommitdiff
path: root/ick2lib/project.py
blob: ae9a124c47c7f92e76e60200a95b0e28b41b117d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# Copyright 2017  Lars Wirzenius
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
# =*= License: GPL-3+ =*=


class Project(object):

    def __init__(self, name):
        self.name = name
        self.git = None
        self.current_log = ''
        self.previous_log = ''
        self.build_steps = []
        self.current_build_step = None
        self.current_worker = None

    def set_git(self, url):
        self.git = url

    def get_current_log(self):
        return self.current_log

    def get_previous_log(self):
        return self.previous_log

    def append_to_current_log(self, text):
        self.current_log += text

    def finish_current_log(self):
        self.previous_log = self.current_log
        self.current_log = ''

    def get_build_steps(self):
        return self.build_steps

    def add_build_step(self, shell_text):
        self.build_steps.append(shell_text)

    def get_current_build_step(self, worker_name):
        if self.current_build_step is None:
            return None
        if self.current_worker is None:
            self.current_worker = worker_name
        elif self.current_worker != worker_name:
            return None
        return self.build_steps[self.current_build_step]

    def finish_current_build_step(self):
        assert self.current_build_step is not None
        self.current_build_step += 1
        if self.current_build_step >= len(self.build_steps):
            self.current_build_step = None

    def trigger_build(self):
        if self.current_build_step is None:
            self.current_build_step = 0