Source code orco/report.py

 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
class Report:
    """
    Report of an event in ORCO. It can be viewed via ORCO browser.

    Attributes:
    * report_type - "info" / "error" / "timeout"
    * executor_id - Id of executor where even comes from
    * message - string representation of message
    * builder_name - name of builder where event occurs (or None if not related)
    * config - config related to the event (or None if not related)
    * timestamp - datetime when event was created
    """

    __slots__ = (
        "report_type",
        "executor_id",
        "message",
        "builder_name",
        "config",
        "timestamp",
    )

    def __init__(
        self,
        report_type,
        executor_id,
        message,
        builder_name=None,
        config=None,
        timestamp=None,
    ):
        self.executor_id = executor_id
        self.timestamp = timestamp
        self.report_type = report_type
        self.message = message
        self.builder_name = builder_name
        self.config = config

    def to_dict(self):
        return {
            "executor": self.executor_id,
            "timestamp": self.timestamp,
            "type": self.report_type,
            "message": self.message,
            "builder": self.builder_name,
            "config": self.config,
        }

    def __repr__(self):
        return "<Report {}: {}>".format(self.report_type, self.message)