diff options
author | Tristan Van Berkom <tristan.vanberkom@codethink.co.uk> | 2017-01-12 14:39:49 -0500 |
---|---|---|
committer | Tristan Van Berkom <tristan.vanberkom@codethink.co.uk> | 2017-01-12 16:20:33 -0500 |
commit | d03ef546301cb5c6150b2eeb4918520032c240f9 (patch) | |
tree | 9f409e6323a8a837d0780d835695ea1ce456109d /buildstream/_message.py | |
parent | 859dabec1aa1528472d223d3059e7ed50f86b9ca (diff) | |
download | buildstream-d03ef546301cb5c6150b2eeb4918520032c240f9.tar.gz |
_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.
Diffstat (limited to 'buildstream/_message.py')
-rw-r--r-- | buildstream/_message.py | 52 |
1 files changed, 52 insertions, 0 deletions
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 <http://www.gnu.org/licenses/>. +# +# Authors: +# Tristan Van Berkom <tristan.vanberkom@codethink.co.uk> + +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) |