From d03ef546301cb5c6150b2eeb4918520032c240f9 Mon Sep 17 00:00:00 2001 From: Tristan Van Berkom Date: Thu, 12 Jan 2017 14:39:49 -0500 Subject: _message.py: Added Message and MessageType definitions For transporting messages about plugin instances in the data model, back from their subprocesses, and controlling message flow. --- buildstream/_message.py | 52 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 buildstream/_message.py (limited to 'buildstream/_message.py') diff --git a/buildstream/_message.py b/buildstream/_message.py new file mode 100644 index 000000000..4f5de5c1d --- /dev/null +++ b/buildstream/_message.py @@ -0,0 +1,52 @@ +#!/usr/bin/env python3 +# +# Copyright (C) 2017 Codethink Limited +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2 of the License, or (at your option) any later version. +# +# This library 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 +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library. If not, see . +# +# Authors: +# Tristan Van Berkom + +import os + + +# Types of status messages. +# +class MessageType(): + DEBUG = "debug" # Debugging message + STATUS = "status" # Status message + WARN = "warning" # Warning messages + ERROR = "error" # Error messages + + # The following types are timed, SUCCESS/FAIL have timestamps + START = "start" # Status start message + SUCCESS = "success" # Successful status complete message + FAIL = "failure" # Failing status complete message + + +# Message object +# +class Message(): + def __init__(self, unique_id, message_type, message, + detail=None, + elapsed=None): + self.pid = os.getpid() + self.unique_id = unique_id + self.message_type = message_type + self.message = message + self.detail = detail + self.elapsed = elapsed + + if message_type in (MessageType.SUCCESS, MessageType.FAIL): + assert(elapsed is not None) -- cgit v1.2.1