diff options
author | Tom Pollard <tom.pollard@codethink.co.uk> | 2019-07-31 16:31:47 +0100 |
---|---|---|
committer | bst-marge-bot <marge-bot@buildstream.build> | 2019-08-08 13:52:36 +0000 |
commit | 0026e37918998addb61d7cefcbb9b5f7f6f7b4f4 (patch) | |
tree | a756eaf5ba545882f8ec69204759ac22b8112d23 /src/buildstream/sandbox | |
parent | 1701aa1239f472317edfc6f675378dc91b1fcd61 (diff) | |
download | buildstream-0026e37918998addb61d7cefcbb9b5f7f6f7b4f4.tar.gz |
_message.py: Use element_name & element_key instead of unique_idtpollard/messageobject
Adding the element full name and display key into all element related
messages removes the need to look up the plugintable via a plugin
unique_id just to retrieve the same values for logging and widget
frontend display. Relying on plugintable state is also incompatible
if the frontend will be running in a different process, as it will
exist in multiple states.
The element full name is now displayed instead of the unique_id,
such as in the debugging widget. It is also displayed in place of
'name' (i.e including any junction prepend) to be more informative.
Diffstat (limited to 'src/buildstream/sandbox')
-rw-r--r-- | src/buildstream/sandbox/_sandboxremote.py | 2 | ||||
-rw-r--r-- | src/buildstream/sandbox/sandbox.py | 23 |
2 files changed, 12 insertions, 13 deletions
diff --git a/src/buildstream/sandbox/_sandboxremote.py b/src/buildstream/sandbox/_sandboxremote.py index 8c9515497..affe597dd 100644 --- a/src/buildstream/sandbox/_sandboxremote.py +++ b/src/buildstream/sandbox/_sandboxremote.py @@ -106,7 +106,7 @@ class SandboxRemote(Sandbox): self.operation_name = None def info(self, msg): - self._get_context().messenger.message(Message(None, MessageType.INFO, msg)) + self._get_context().messenger.message(Message(MessageType.INFO, msg)) @staticmethod def specs_from_config_node(config_node, basedir=None): diff --git a/src/buildstream/sandbox/sandbox.py b/src/buildstream/sandbox/sandbox.py index 8ff0aafa2..6956a7d59 100644 --- a/src/buildstream/sandbox/sandbox.py +++ b/src/buildstream/sandbox/sandbox.py @@ -120,12 +120,12 @@ class Sandbox(): self.__allow_real_directory = kwargs['allow_real_directory'] self.__allow_run = True - # Plugin ID for logging + # Plugin element full name for logging plugin = kwargs.get('plugin', None) if plugin: - self.__plugin_id = plugin._unique_id + self.__element_name = plugin._get_full_name() else: - self.__plugin_id = None + self.__element_name = None # Configuration from kwargs common to all subclasses self.__config = kwargs['config'] @@ -574,12 +574,12 @@ class Sandbox(): return False - # _get_plugin_id() + # _get_element_name() # - # Get the plugin's unique identifier + # Get the plugin's element full name # - def _get_plugin_id(self): - return self.__plugin_id + def _get_element_name(self): + return self.__element_name # _callback() # @@ -633,8 +633,7 @@ class Sandbox(): # details (str): optional, more detatils def _issue_warning(self, message, detail=None): self.__context.messenger.message( - Message(None, - MessageType.WARN, + Message(MessageType.WARN, message, detail=detail ) @@ -660,7 +659,7 @@ class _SandboxBatch(): def execute_group(self, group): if group.label: context = self.sandbox._get_context() - cm = context.messenger.timed_activity(group.label, unique_id=self.sandbox._get_plugin_id()) + cm = context.messenger.timed_activity(group.label, element_name=self.sandbox._get_element_name()) else: cm = contextlib.suppress() @@ -670,8 +669,8 @@ class _SandboxBatch(): def execute_command(self, command): if command.label: context = self.sandbox._get_context() - message = Message(self.sandbox._get_plugin_id(), MessageType.STATUS, - 'Running command', detail=command.label) + message = Message(MessageType.STATUS, 'Running command', detail=command.label, + element_name=self.sandbox._get_element_name()) context.messenger.message(message) exitcode = self.sandbox._run(command.command, self.flags, cwd=command.cwd, env=command.env) |