Qinusty pushed to branch Qinusty/message-helpers at BuildStream / buildstream
Commits:
-
4389acba
by Tristan Maat at 2018-08-16T12:54:22Z
-
08d38437
by Tristan Maat at 2018-08-16T12:54:32Z
-
21582e87
by Josh Smith at 2018-08-16T12:58:08Z
13 changed files:
- buildstream/_artifactcache/artifactcache.py
- buildstream/_artifactcache/cascache.py
- buildstream/_context.py
- buildstream/_frontend/app.py
- buildstream/_pipeline.py
- buildstream/_platform/linux.py
- buildstream/_project.py
- buildstream/_scheduler/jobs/elementjob.py
- buildstream/_scheduler/jobs/job.py
- buildstream/_scheduler/queues/buildqueue.py
- buildstream/_scheduler/queues/queue.py
- buildstream/_stream.py
- buildstream/plugin.py
Changes:
... | ... | @@ -23,7 +23,6 @@ from collections import Mapping, namedtuple |
23 | 23 |
|
24 | 24 |
from ..element import _KeyStrength
|
25 | 25 |
from .._exceptions import ArtifactError, ImplError, LoadError, LoadErrorReason
|
26 |
-from .._message import Message, MessageType
|
|
27 | 26 |
from .. import utils
|
28 | 27 |
from .. import _yaml
|
29 | 28 |
|
... | ... | @@ -490,15 +489,6 @@ class ArtifactCache(): |
490 | 489 |
# Local Private Methods #
|
491 | 490 |
################################################
|
492 | 491 |
|
493 |
- # _message()
|
|
494 |
- #
|
|
495 |
- # Local message propagator
|
|
496 |
- #
|
|
497 |
- def _message(self, message_type, message, **kwargs):
|
|
498 |
- args = dict(kwargs)
|
|
499 |
- self.context.message(
|
|
500 |
- Message(None, message_type, message, **args))
|
|
501 |
- |
|
502 | 492 |
# _set_remotes():
|
503 | 493 |
#
|
504 | 494 |
# Set the list of remote caches. If project is None, the global list of
|
... | ... | @@ -522,7 +512,7 @@ class ArtifactCache(): |
522 | 512 |
#
|
523 | 513 |
def _initialize_remotes(self):
|
524 | 514 |
def remote_failed(url, error):
|
525 |
- self._message(MessageType.WARN, "Failed to initialize remote {}: {}".format(url, error))
|
|
515 |
+ self.context.warn("Failed to fetch remote refs from {}: {}".format(url, error))
|
|
526 | 516 |
|
527 | 517 |
with self.context.timed_activity("Initializing remote caches", silent_nested=True):
|
528 | 518 |
self.initialize_remotes(on_failure=remote_failed)
|
... | ... | @@ -33,7 +33,6 @@ from .._protos.google.bytestream import bytestream_pb2, bytestream_pb2_grpc |
33 | 33 |
from .._protos.build.bazel.remote.execution.v2 import remote_execution_pb2, remote_execution_pb2_grpc
|
34 | 34 |
from .._protos.buildstream.v2 import buildstream_pb2, buildstream_pb2_grpc
|
35 | 35 |
|
36 |
-from .._message import MessageType, Message
|
|
37 | 36 |
from .. import _signals, utils
|
38 | 37 |
from .._exceptions import ArtifactError
|
39 | 38 |
|
... | ... | @@ -348,12 +347,10 @@ class CASCache(ArtifactCache): |
348 | 347 |
raise ArtifactError("Failed to push artifact {}: {}".format(refs, e), temporary=True) from e
|
349 | 348 |
|
350 | 349 |
if skipped_remote:
|
351 |
- self.context.message(Message(
|
|
352 |
- None,
|
|
353 |
- MessageType.SKIPPED,
|
|
350 |
+ self.context.skipped(
|
|
354 | 351 |
"Remote ({}) already has {} cached".format(
|
355 | 352 |
remote.spec.url, element._get_brief_display_key())
|
356 |
- ))
|
|
353 |
+ )
|
|
357 | 354 |
return pushed
|
358 | 355 |
|
359 | 356 |
################################################
|
... | ... | @@ -447,6 +447,9 @@ class Context(): |
447 | 447 |
def failure(self, text, *, plugin=None, **kwargs):
|
448 | 448 |
self._message(text, plugin=plugin, msg_type=MessageType.FAIL, **kwargs)
|
449 | 449 |
|
450 |
+ def skipped(self, text, *, plugin=None, **kwargs):
|
|
451 |
+ self._message(text, plugin=plugin, msg_type=MessageType.SKIPPED, **kwargs)
|
|
452 |
+ |
|
450 | 453 |
def debug(self, text, *, plugin=None, **kwargs):
|
451 | 454 |
self._message(text, plugin=plugin, msg_type=MessageType.DEBUG, **kwargs)
|
452 | 455 |
|
... | ... | @@ -512,8 +515,7 @@ class Context(): |
512 | 515 |
with _signals.suspendable(stop_time, resume_time):
|
513 | 516 |
try:
|
514 | 517 |
# Push activity depth for status messages
|
515 |
- message = Message(unique_id, MessageType.START, activity_name, detail=detail)
|
|
516 |
- self.message(message)
|
|
518 |
+ self.start(activity_name, detail=detail, plugin=unique_id)
|
|
517 | 519 |
self._push_message_depth(silent_nested)
|
518 | 520 |
yield
|
519 | 521 |
|
... | ... | @@ -521,15 +523,14 @@ class Context(): |
521 | 523 |
# Note the failure in status messages and reraise, the scheduler
|
522 | 524 |
# expects an error when there is an error.
|
523 | 525 |
elapsed = datetime.datetime.now() - starttime
|
524 |
- message = Message(unique_id, MessageType.FAIL, activity_name, elapsed=elapsed)
|
|
525 | 526 |
self._pop_message_depth()
|
526 |
- self.message(message)
|
|
527 |
+ self.failure(activity_name, detail=detail, elapsed=elapsed, plugin=unique_id)
|
|
527 | 528 |
raise
|
528 | 529 |
|
529 | 530 |
elapsed = datetime.datetime.now() - starttime
|
530 |
- message = Message(unique_id, MessageType.SUCCESS, activity_name, elapsed=elapsed)
|
|
531 | 531 |
self._pop_message_depth()
|
532 |
- self.message(message)
|
|
532 |
+ self.success(activity_name, detail=detail,
|
|
533 |
+ elapsed=elapsed, plugin=unique_id)
|
|
533 | 534 |
|
534 | 535 |
# recorded_messages()
|
535 | 536 |
#
|
... | ... | @@ -36,7 +36,7 @@ from .._context import Context |
36 | 36 |
from .._platform import Platform
|
37 | 37 |
from .._project import Project
|
38 | 38 |
from .._exceptions import BstError, StreamError, LoadError, LoadErrorReason, AppError
|
39 |
-from .._message import Message, MessageType, unconditional_messages
|
|
39 |
+from .._message import MessageType, unconditional_messages
|
|
40 | 40 |
from .._stream import Stream
|
41 | 41 |
from .._versions import BST_FORMAT_VERSION
|
42 | 42 |
from .. import _yaml
|
... | ... | @@ -253,7 +253,7 @@ class App(): |
253 | 253 |
|
254 | 254 |
# Mark the beginning of the session
|
255 | 255 |
if session_name:
|
256 |
- self._message(MessageType.START, session_name)
|
|
256 |
+ self.context.start(session_name)
|
|
257 | 257 |
|
258 | 258 |
# Run the body of the session here, once everything is loaded
|
259 | 259 |
try:
|
... | ... | @@ -265,9 +265,9 @@ class App(): |
265 | 265 |
elapsed = self.stream.elapsed_time
|
266 | 266 |
|
267 | 267 |
if isinstance(e, StreamError) and e.terminated: # pylint: disable=no-member
|
268 |
- self._message(MessageType.WARN, session_name + ' Terminated', elapsed=elapsed)
|
|
268 |
+ self.context.warn(session_name + ' Terminated', elapsed=elapsed)
|
|
269 | 269 |
else:
|
270 |
- self._message(MessageType.FAIL, session_name, elapsed=elapsed)
|
|
270 |
+ self.context.failure(session_name, elapsed=elapsed)
|
|
271 | 271 |
|
272 | 272 |
if self._started:
|
273 | 273 |
self._print_summary()
|
... | ... | @@ -282,7 +282,7 @@ class App(): |
282 | 282 |
else:
|
283 | 283 |
# No exceptions occurred, print session time and summary
|
284 | 284 |
if session_name:
|
285 |
- self._message(MessageType.SUCCESS, session_name, elapsed=self.stream.elapsed_time)
|
|
285 |
+ self.context.success(session_name, elapsed=self.stream.elapsed_time)
|
|
286 | 286 |
if self._started:
|
287 | 287 |
self._print_summary()
|
288 | 288 |
|
... | ... | @@ -419,21 +419,13 @@ class App(): |
419 | 419 |
# Local Functions #
|
420 | 420 |
############################################################
|
421 | 421 |
|
422 |
- # Local message propagator
|
|
423 |
- #
|
|
424 |
- def _message(self, message_type, message, **kwargs):
|
|
425 |
- args = dict(kwargs)
|
|
426 |
- self.context.message(
|
|
427 |
- Message(None, message_type, message, **args))
|
|
428 |
- |
|
429 | 422 |
# Exception handler
|
430 | 423 |
#
|
431 | 424 |
def _global_exception_handler(self, etype, value, tb):
|
432 | 425 |
|
433 | 426 |
# Print the regular BUG message
|
434 | 427 |
formatted = "".join(traceback.format_exception(etype, value, tb))
|
435 |
- self._message(MessageType.BUG, str(value),
|
|
436 |
- detail=formatted)
|
|
428 |
+ self.context.bug(str(value), detail=formatted)
|
|
437 | 429 |
|
438 | 430 |
# If the scheduler has started, try to terminate all jobs gracefully,
|
439 | 431 |
# otherwise exit immediately.
|
... | ... | @@ -24,7 +24,6 @@ import itertools |
24 | 24 |
from operator import itemgetter
|
25 | 25 |
|
26 | 26 |
from ._exceptions import PipelineError
|
27 |
-from ._message import Message, MessageType
|
|
28 | 27 |
from ._profile import Topics, profile_start, profile_end
|
29 | 28 |
from . import Scope, Consistency
|
30 | 29 |
from ._project import ProjectRefStorage
|
... | ... | @@ -201,8 +200,8 @@ class Pipeline(): |
201 | 200 |
for t in targets:
|
202 | 201 |
new_elm = t._get_source_element()
|
203 | 202 |
if new_elm != t and not silent:
|
204 |
- self._message(MessageType.INFO, "Element '{}' redirected to '{}'"
|
|
205 |
- .format(t.name, new_elm.name))
|
|
203 |
+ self._context.info("Element '{}' redirected to '{}'"
|
|
204 |
+ .format(t.name, new_elm.name))
|
|
206 | 205 |
if new_elm not in elements:
|
207 | 206 |
elements.append(new_elm)
|
208 | 207 |
elif mode == PipelineSelection.PLAN:
|
... | ... | @@ -428,15 +427,6 @@ class Pipeline(): |
428 | 427 |
|
429 | 428 |
raise PipelineError("Untrackable sources", detail=detail, reason="untrackable-sources")
|
430 | 429 |
|
431 |
- # _message()
|
|
432 |
- #
|
|
433 |
- # Local message propagator
|
|
434 |
- #
|
|
435 |
- def _message(self, message_type, message, **kwargs):
|
|
436 |
- args = dict(kwargs)
|
|
437 |
- self._context.message(
|
|
438 |
- Message(None, message_type, message, **args))
|
|
439 |
- |
|
440 | 430 |
|
441 | 431 |
# _Planner()
|
442 | 432 |
#
|
... | ... | @@ -22,7 +22,6 @@ import subprocess |
22 | 22 |
from .. import _site
|
23 | 23 |
from .. import utils
|
24 | 24 |
from .._artifactcache.cascache import CASCache
|
25 |
-from .._message import Message, MessageType
|
|
26 | 25 |
from ..sandbox import SandboxBwrap
|
27 | 26 |
|
28 | 27 |
from . import Platform
|
... | ... | @@ -75,9 +74,9 @@ class Linux(Platform): |
75 | 74 |
return True
|
76 | 75 |
|
77 | 76 |
else:
|
78 |
- context.message(
|
|
79 |
- Message(None, MessageType.WARN,
|
|
80 |
- "Unable to create user namespaces with bubblewrap, resorting to fallback",
|
|
81 |
- detail="Some builds may not function due to lack of uid / gid 0, " +
|
|
82 |
- "artifacts created will not be trusted for push purposes."))
|
|
77 |
+ context.warn(
|
|
78 |
+ "Unable to create user namespaces with bubblewrap, resorting to fallback",
|
|
79 |
+ detail="Some builds may not function due to lack of uid / gid 0, " +
|
|
80 |
+ "artifacts created will not be trusted for push purposes."
|
|
81 |
+ )
|
|
83 | 82 |
return False
|
... | ... | @@ -36,7 +36,6 @@ from ._projectrefs import ProjectRefs, ProjectRefStorage |
36 | 36 |
from ._versions import BST_FORMAT_VERSION
|
37 | 37 |
from ._loader import Loader
|
38 | 38 |
from .element import Element
|
39 |
-from ._message import Message, MessageType
|
|
40 | 39 |
from ._includes import Includes
|
41 | 40 |
|
42 | 41 |
|
... | ... | @@ -334,8 +333,7 @@ class Project(): |
334 | 333 |
for source, ref in redundant_refs
|
335 | 334 |
]
|
336 | 335 |
detail += "\n".join(lines)
|
337 |
- self._context.message(
|
|
338 |
- Message(None, MessageType.WARN, "Ignoring redundant source references", detail=detail))
|
|
336 |
+ self._context.warn("Ignoring redundant source references", detail=detail)
|
|
339 | 337 |
|
340 | 338 |
return elements
|
341 | 339 |
|
... | ... | @@ -492,13 +490,9 @@ class Project(): |
492 | 490 |
|
493 | 491 |
# Deprecation check
|
494 | 492 |
if fail_on_overlap is not None:
|
495 |
- self._context.message(
|
|
496 |
- Message(
|
|
497 |
- None,
|
|
498 |
- MessageType.WARN,
|
|
499 |
- "Use of fail-on-overlap within project.conf " +
|
|
500 |
- "is deprecated. Consider using fatal-warnings instead."
|
|
501 |
- )
|
|
493 |
+ self._context.warn(
|
|
494 |
+ "Use of fail-on-overlap within project.conf " +
|
|
495 |
+ "is deprecated. Consider using fatal-warnings instead."
|
|
502 | 496 |
)
|
503 | 497 |
|
504 | 498 |
# Load project.refs if it exists, this may be ignored.
|
... | ... | @@ -18,8 +18,6 @@ |
18 | 18 |
#
|
19 | 19 |
from ruamel import yaml
|
20 | 20 |
|
21 |
-from ..._message import Message, MessageType
|
|
22 |
- |
|
23 | 21 |
from .job import Job
|
24 | 22 |
|
25 | 23 |
|
... | ... | @@ -86,9 +84,8 @@ class ElementJob(Job): |
86 | 84 |
# This should probably be omitted for non-build tasks but it's harmless here
|
87 | 85 |
elt_env = self._element.get_environment()
|
88 | 86 |
env_dump = yaml.round_trip_dump(elt_env, default_flow_style=False, allow_unicode=True)
|
89 |
- self.message(MessageType.LOG,
|
|
90 |
- "Build environment for element {}".format(self._element.name),
|
|
91 |
- detail=env_dump)
|
|
87 |
+ self._log("Build environment for element {}".format(self._element.name),
|
|
88 |
+ detail=env_dump)
|
|
92 | 89 |
|
93 | 90 |
# Run the action
|
94 | 91 |
return self._action_cb(self._element)
|
... | ... | @@ -96,15 +93,6 @@ class ElementJob(Job): |
96 | 93 |
def parent_complete(self, success, result):
|
97 | 94 |
self._complete_cb(self, self._element, success, self._result)
|
98 | 95 |
|
99 |
- def message(self, message_type, message, **kwargs):
|
|
100 |
- args = dict(kwargs)
|
|
101 |
- args['scheduler'] = True
|
|
102 |
- self._scheduler.context.message(
|
|
103 |
- Message(self._element._get_unique_id(),
|
|
104 |
- message_type,
|
|
105 |
- message,
|
|
106 |
- **args))
|
|
107 |
- |
|
108 | 96 |
def child_process_data(self):
|
109 | 97 |
data = {}
|
110 | 98 |
|
... | ... | @@ -119,3 +107,33 @@ class ElementJob(Job): |
119 | 107 |
data['cache_size'] = cache_size
|
120 | 108 |
|
121 | 109 |
return data
|
110 |
+ |
|
111 |
+ def _start(self, text, **kwargs):
|
|
112 |
+ self._scheduler.context.start(text, scheduler=True, **kwargs)
|
|
113 |
+ |
|
114 |
+ def _success(self, text, **kwargs):
|
|
115 |
+ self._scheduler.context.success(text, scheduler=True, **kwargs)
|
|
116 |
+ |
|
117 |
+ def _failure(self, text, **kwargs):
|
|
118 |
+ self._scheduler.context.failure(text, scheduler=True, **kwargs)
|
|
119 |
+ |
|
120 |
+ def _debug(self, text, **kwargs):
|
|
121 |
+ self._scheduler.context.debug(text, scheduler=True, **kwargs)
|
|
122 |
+ |
|
123 |
+ def _status(self, text, **kwargs):
|
|
124 |
+ self._scheduler.context.status(text, scheduler=True, **kwargs)
|
|
125 |
+ |
|
126 |
+ def _info(self, text, **kwargs):
|
|
127 |
+ self._scheduler.context.info(text, scheduler=True, **kwargs)
|
|
128 |
+ |
|
129 |
+ def _warn(self, text, **kwargs):
|
|
130 |
+ self._scheduler.context.warn(text, scheduler=True, **kwargs)
|
|
131 |
+ |
|
132 |
+ def _error(self, text, **kwargs):
|
|
133 |
+ self._scheduler.context.error(text, scheduler=True, **kwargs)
|
|
134 |
+ |
|
135 |
+ def _bug(self, text, **kwargs):
|
|
136 |
+ self._scheduler.context.bug(text, scheduler=True, **kwargs)
|
|
137 |
+ |
|
138 |
+ def _log(self, text, **kwargs):
|
|
139 |
+ self._scheduler.context.log(text, scheduler=True, **kwargs)
|
... | ... | @@ -32,7 +32,7 @@ import psutil |
32 | 32 |
|
33 | 33 |
# BuildStream toplevel imports
|
34 | 34 |
from ..._exceptions import ImplError, BstError, set_last_task_error
|
35 |
-from ..._message import Message, MessageType, unconditional_messages
|
|
35 |
+from ..._message import MessageType, unconditional_messages
|
|
36 | 36 |
from ... import _signals, utils
|
37 | 37 |
|
38 | 38 |
# Return code values shutdown of job handling child processes
|
... | ... | @@ -179,7 +179,7 @@ class Job(): |
179 | 179 |
# First resume the job if it's suspended
|
180 | 180 |
self.resume(silent=True)
|
181 | 181 |
|
182 |
- self.message(MessageType.STATUS, "{} terminating".format(self.action_name))
|
|
182 |
+ self._status("{} terminating".format(self.action_name))
|
|
183 | 183 |
|
184 | 184 |
# Make sure there is no garbage on the queue
|
185 | 185 |
self._parent_stop_listening()
|
... | ... | @@ -210,8 +210,8 @@ class Job(): |
210 | 210 |
def kill(self):
|
211 | 211 |
|
212 | 212 |
# Force kill
|
213 |
- self.message(MessageType.WARN,
|
|
214 |
- "{} did not terminate gracefully, killing".format(self.action_name))
|
|
213 |
+ self._warn("{} did not terminate gracefully, killing"
|
|
214 |
+ .format(self.action_name))
|
|
215 | 215 |
|
216 | 216 |
try:
|
217 | 217 |
utils._kill_process_tree(self._process.pid)
|
... | ... | @@ -226,8 +226,7 @@ class Job(): |
226 | 226 |
#
|
227 | 227 |
def suspend(self):
|
228 | 228 |
if not self._suspended:
|
229 |
- self.message(MessageType.STATUS,
|
|
230 |
- "{} suspending".format(self.action_name))
|
|
229 |
+ self._status("{} suspending".format(self.action_name))
|
|
231 | 230 |
|
232 | 231 |
try:
|
233 | 232 |
# Use SIGTSTP so that child processes may handle and propagate
|
... | ... | @@ -251,8 +250,7 @@ class Job(): |
251 | 250 |
def resume(self, silent=False):
|
252 | 251 |
if self._suspended:
|
253 | 252 |
if not silent:
|
254 |
- self.message(MessageType.STATUS,
|
|
255 |
- "{} resuming".format(self.action_name))
|
|
253 |
+ self._status("{} resuming".format(self.action_name))
|
|
256 | 254 |
|
257 | 255 |
os.kill(self._process.pid, signal.SIGCONT)
|
258 | 256 |
self._suspended = False
|
... | ... | @@ -305,21 +303,6 @@ class Job(): |
305 | 303 |
raise ImplError("Job '{kind}' does not implement child_process()"
|
306 | 304 |
.format(kind=type(self).__name__))
|
307 | 305 |
|
308 |
- # message():
|
|
309 |
- #
|
|
310 |
- # Logs a message, this will be logged in the task's logfile and
|
|
311 |
- # conditionally also be sent to the frontend.
|
|
312 |
- #
|
|
313 |
- # Args:
|
|
314 |
- # message_type (MessageType): The type of message to send
|
|
315 |
- # message (str): The message
|
|
316 |
- # kwargs: Remaining Message() constructor arguments
|
|
317 |
- #
|
|
318 |
- def message(self, message_type, message, **kwargs):
|
|
319 |
- args = dict(kwargs)
|
|
320 |
- args['scheduler'] = True
|
|
321 |
- self._scheduler.context.message(Message(None, message_type, message, **args))
|
|
322 |
- |
|
323 | 306 |
# child_process_data()
|
324 | 307 |
#
|
325 | 308 |
# Abstract method to retrieve additional data that should be
|
... | ... | @@ -346,6 +329,36 @@ class Job(): |
346 | 329 |
#
|
347 | 330 |
#######################################################
|
348 | 331 |
|
332 |
+ def _start(self, text, **kwargs):
|
|
333 |
+ self._scheduler.context.start(text, **kwargs)
|
|
334 |
+ |
|
335 |
+ def _success(self, text, **kwargs):
|
|
336 |
+ self._scheduler.context.success(text, **kwargs)
|
|
337 |
+ |
|
338 |
+ def _failure(self, text, **kwargs):
|
|
339 |
+ self._scheduler.context.failure(text, **kwargs)
|
|
340 |
+ |
|
341 |
+ def _debug(self, text, **kwargs):
|
|
342 |
+ self._scheduler.context.debug(text, **kwargs)
|
|
343 |
+ |
|
344 |
+ def _status(self, text, **kwargs):
|
|
345 |
+ self._scheduler.context.status(text, **kwargs)
|
|
346 |
+ |
|
347 |
+ def _info(self, text, **kwargs):
|
|
348 |
+ self._scheduler.context.info(text, **kwargs)
|
|
349 |
+ |
|
350 |
+ def _warn(self, text, **kwargs):
|
|
351 |
+ self._scheduler.context.warn(text, **kwargs)
|
|
352 |
+ |
|
353 |
+ def _error(self, text, **kwargs):
|
|
354 |
+ self._scheduler.context.error(text, **kwargs)
|
|
355 |
+ |
|
356 |
+ def _bug(self, text, **kwargs):
|
|
357 |
+ self._scheduler.context.bug(text, **kwargs)
|
|
358 |
+ |
|
359 |
+ def _log(self, text, **kwargs):
|
|
360 |
+ self._scheduler.context.log(text, **kwargs)
|
|
361 |
+ |
|
349 | 362 |
# _child_action()
|
350 | 363 |
#
|
351 | 364 |
# Perform the action in the child process, this calls the action_cb.
|
... | ... | @@ -391,7 +404,7 @@ class Job(): |
391 | 404 |
with _signals.suspendable(stop_time, resume_time), \
|
392 | 405 |
self._scheduler.context.recorded_messages(self._logfile) as filename:
|
393 | 406 |
|
394 |
- self.message(MessageType.START, self.action_name, logfile=filename)
|
|
407 |
+ self._start(self.action_name, logfile=filename)
|
|
395 | 408 |
|
396 | 409 |
try:
|
397 | 410 |
# Try the task action
|
... | ... | @@ -401,13 +414,11 @@ class Job(): |
401 | 414 |
self._retry_flag = e.temporary
|
402 | 415 |
|
403 | 416 |
if self._retry_flag and (self._tries <= self._max_retries):
|
404 |
- self.message(MessageType.FAIL,
|
|
405 |
- "Try #{} failed, retrying".format(self._tries),
|
|
406 |
- elapsed=elapsed)
|
|
417 |
+ self._failure("Try #{} failed, retrying".format(self._tries), elapsed=elapsed)
|
|
407 | 418 |
else:
|
408 |
- self.message(MessageType.FAIL, str(e),
|
|
409 |
- elapsed=elapsed, detail=e.detail,
|
|
410 |
- logfile=filename, sandbox=e.sandbox)
|
|
419 |
+ self._failure(str(e), elapsed=elapsed,
|
|
420 |
+ detail=e.detail, logfile=filename,
|
|
421 |
+ sandbox=e.sandbox)
|
|
411 | 422 |
|
412 | 423 |
self._queue.put(Envelope('child_data', self.child_process_data()))
|
413 | 424 |
|
... | ... | @@ -427,19 +438,15 @@ class Job(): |
427 | 438 |
elapsed = datetime.datetime.now() - starttime
|
428 | 439 |
detail = "An unhandled exception occured:\n\n{}".format(traceback.format_exc())
|
429 | 440 |
|
430 |
- self.message(MessageType.BUG, self.action_name,
|
|
431 |
- elapsed=elapsed, detail=detail,
|
|
432 |
- logfile=filename)
|
|
441 |
+ self._bug(self.action_name, elapsed=elapsed, detail=detail, logfile=filename)
|
|
433 | 442 |
self._child_shutdown(RC_FAIL)
|
434 |
- |
|
435 | 443 |
else:
|
436 | 444 |
# No exception occurred in the action
|
437 | 445 |
self._queue.put(Envelope('child_data', self.child_process_data()))
|
438 | 446 |
self._child_send_result(result)
|
439 | 447 |
|
440 | 448 |
elapsed = datetime.datetime.now() - starttime
|
441 |
- self.message(MessageType.SUCCESS, self.action_name, elapsed=elapsed,
|
|
442 |
- logfile=filename)
|
|
449 |
+ self._success(self.action_name, elapsed=elapsed, logfile=filename)
|
|
443 | 450 |
|
444 | 451 |
# Shutdown needs to stay outside of the above context manager,
|
445 | 452 |
# make sure we dont try to handle SIGTERM while the process
|
... | ... | @@ -574,7 +581,7 @@ class Job(): |
574 | 581 |
if envelope._message_type == 'message':
|
575 | 582 |
# Propagate received messages from children
|
576 | 583 |
# back through the context.
|
577 |
- self._scheduler.context.message(envelope._message)
|
|
584 |
+ self._scheduler.context._send_message(envelope._message)
|
|
578 | 585 |
elif envelope._message_type == 'error':
|
579 | 586 |
# For regression tests only, save the last error domain / reason
|
580 | 587 |
# reported from a child task in the main process, this global state
|
... | ... | @@ -23,7 +23,6 @@ from datetime import timedelta |
23 | 23 |
from . import Queue, QueueStatus
|
24 | 24 |
from ..jobs import ElementJob
|
25 | 25 |
from ..resources import ResourceType
|
26 |
-from ..._message import MessageType
|
|
27 | 26 |
|
28 | 27 |
|
29 | 28 |
# A queue which assembles elements
|
... | ... | @@ -50,7 +49,7 @@ class BuildQueue(Queue): |
50 | 49 |
self._tried.add(element)
|
51 | 50 |
_, description, detail = element._get_build_result()
|
52 | 51 |
logfile = element._get_build_log()
|
53 |
- self._message(element, MessageType.FAIL, description,
|
|
52 |
+ self._failure(description, element=element,
|
|
54 | 53 |
detail=detail, action_name=self.action_name,
|
55 | 54 |
elapsed=timedelta(seconds=0),
|
56 | 55 |
logfile=logfile)
|
... | ... | @@ -30,7 +30,6 @@ from ..resources import ResourceType |
30 | 30 |
|
31 | 31 |
# BuildStream toplevel imports
|
32 | 32 |
from ..._exceptions import BstError, set_last_task_error
|
33 |
-from ..._message import Message, MessageType
|
|
34 | 33 |
|
35 | 34 |
|
36 | 35 |
# Queue status for a given element
|
... | ... | @@ -280,11 +279,12 @@ class Queue(): |
280 | 279 |
try:
|
281 | 280 |
workspaces.save_config()
|
282 | 281 |
except BstError as e:
|
283 |
- self._message(element, MessageType.ERROR, "Error saving workspaces", detail=str(e))
|
|
282 |
+ element._get_context().error("Error saving workspaces",
|
|
283 |
+ detail=str(e),
|
|
284 |
+ plugin=element._get_unique_id())
|
|
284 | 285 |
except Exception as e: # pylint: disable=broad-except
|
285 |
- self._message(element, MessageType.BUG,
|
|
286 |
- "Unhandled exception while saving workspaces",
|
|
287 |
- detail=traceback.format_exc())
|
|
286 |
+ self._bug("Unhandled exception while saving workspaces",
|
|
287 |
+ plugin=element, detail=traceback.format_exc())
|
|
288 | 288 |
|
289 | 289 |
# _job_done()
|
290 | 290 |
#
|
... | ... | @@ -314,7 +314,9 @@ class Queue(): |
314 | 314 |
|
315 | 315 |
# Report error and mark as failed
|
316 | 316 |
#
|
317 |
- self._message(element, MessageType.ERROR, "Post processing error", detail=str(e))
|
|
317 |
+ self._error("Post processing error",
|
|
318 |
+ plugin=element,
|
|
319 |
+ detail=str(e))
|
|
318 | 320 |
self.failed_elements.append(element)
|
319 | 321 |
|
320 | 322 |
# Treat this as a task error as it's related to a task
|
... | ... | @@ -328,9 +330,9 @@ class Queue(): |
328 | 330 |
|
329 | 331 |
# Report unhandled exceptions and mark as failed
|
330 | 332 |
#
|
331 |
- self._message(element, MessageType.BUG,
|
|
332 |
- "Unhandled exception in post processing",
|
|
333 |
- detail=traceback.format_exc())
|
|
333 |
+ self._bug("Unhandled exception in post processing",
|
|
334 |
+ plugin=element,
|
|
335 |
+ detail=traceback.format_exc())
|
|
334 | 336 |
self.failed_elements.append(element)
|
335 | 337 |
else:
|
336 | 338 |
|
... | ... | @@ -346,12 +348,35 @@ class Queue(): |
346 | 348 |
else:
|
347 | 349 |
self.failed_elements.append(element)
|
348 | 350 |
|
349 |
- # Convenience wrapper for Queue implementations to send
|
|
350 |
- # a message for the element they are processing
|
|
351 |
- def _message(self, element, message_type, brief, **kwargs):
|
|
352 |
- context = element._get_context()
|
|
353 |
- message = Message(element._get_unique_id(), message_type, brief, **kwargs)
|
|
354 |
- context.message(message)
|
|
351 |
+ def _start(self, text, **kwargs):
|
|
352 |
+ self._scheduler.context.start(text, **kwargs)
|
|
353 |
+ |
|
354 |
+ def _success(self, text, **kwargs):
|
|
355 |
+ self._scheduler.context.success(text, **kwargs)
|
|
356 |
+ |
|
357 |
+ def _failure(self, text, **kwargs):
|
|
358 |
+ self._scheduler.context.failure(text, **kwargs)
|
|
359 |
+ |
|
360 |
+ def _debug(self, text, **kwargs):
|
|
361 |
+ self._scheduler.context.debug(text, **kwargs)
|
|
362 |
+ |
|
363 |
+ def _status(self, text, **kwargs):
|
|
364 |
+ self._scheduler.context.status(text, **kwargs)
|
|
365 |
+ |
|
366 |
+ def _info(self, text, **kwargs):
|
|
367 |
+ self._scheduler.context.info(text, **kwargs)
|
|
368 |
+ |
|
369 |
+ def _warn(self, text, **kwargs):
|
|
370 |
+ self._scheduler.context.warn(text, **kwargs)
|
|
371 |
+ |
|
372 |
+ def _error(self, text, **kwargs):
|
|
373 |
+ self._scheduler.context.error(text, **kwargs)
|
|
374 |
+ |
|
375 |
+ def _bug(self, text, **kwargs):
|
|
376 |
+ self._scheduler.context.bug(text, **kwargs)
|
|
377 |
+ |
|
378 |
+ def _log(self, text, **kwargs):
|
|
379 |
+ self._scheduler.context.log(text, **kwargs)
|
|
355 | 380 |
|
356 | 381 |
def _element_log_path(self, element):
|
357 | 382 |
project = element._get_project()
|
... | ... | @@ -29,7 +29,6 @@ from contextlib import contextmanager |
29 | 29 |
from tempfile import TemporaryDirectory
|
30 | 30 |
|
31 | 31 |
from ._exceptions import StreamError, ImplError, BstError, set_last_task_error
|
32 |
-from ._message import Message, MessageType
|
|
33 | 32 |
from ._scheduler import Scheduler, SchedStatus, TrackQueue, FetchQueue, BuildQueue, PullQueue, PushQueue
|
34 | 33 |
from ._pipeline import Pipeline, PipelineSelection
|
35 | 34 |
from ._platform import Platform
|
... | ... | @@ -512,7 +511,7 @@ class Stream(): |
512 | 511 |
target._open_workspace()
|
513 | 512 |
|
514 | 513 |
workspaces.save_config()
|
515 |
- self._message(MessageType.INFO, "Saved workspace configuration")
|
|
514 |
+ self._context.info("Saved workspace configuration")
|
|
516 | 515 |
|
517 | 516 |
# workspace_close
|
518 | 517 |
#
|
... | ... | @@ -539,7 +538,7 @@ class Stream(): |
539 | 538 |
# Delete the workspace and save the configuration
|
540 | 539 |
workspaces.delete_workspace(element_name)
|
541 | 540 |
workspaces.save_config()
|
542 |
- self._message(MessageType.INFO, "Closed workspace for {}".format(element_name))
|
|
541 |
+ self._context.info("Closed workspace for {}".format(element_name))
|
|
543 | 542 |
|
544 | 543 |
# workspace_reset
|
545 | 544 |
#
|
... | ... | @@ -580,8 +579,8 @@ class Stream(): |
580 | 579 |
workspace_path = workspace.get_absolute_path()
|
581 | 580 |
if soft:
|
582 | 581 |
workspace.prepared = False
|
583 |
- self._message(MessageType.INFO, "Reset workspace state for {} at: {}"
|
|
584 |
- .format(element.name, workspace_path))
|
|
582 |
+ self._context.info("Reset workspace state for {} at: {}"
|
|
583 |
+ .format(element.name, workspace.path))
|
|
585 | 584 |
continue
|
586 | 585 |
|
587 | 586 |
with element.timed_activity("Removing workspace directory {}"
|
... | ... | @@ -598,9 +597,8 @@ class Stream(): |
598 | 597 |
with element.timed_activity("Staging sources to {}".format(workspace_path)):
|
599 | 598 |
element._open_workspace()
|
600 | 599 |
|
601 |
- self._message(MessageType.INFO,
|
|
602 |
- "Reset workspace for {} at: {}".format(element.name,
|
|
603 |
- workspace_path))
|
|
600 |
+ self._context.info("Reset workspace for {} at: {}"
|
|
601 |
+ .format(element.name, workspace._path))
|
|
604 | 602 |
|
605 | 603 |
workspaces.save_config()
|
606 | 604 |
|
... | ... | @@ -676,7 +674,7 @@ class Stream(): |
676 | 674 |
# source-bundle only supports one target
|
677 | 675 |
target = self.targets[0]
|
678 | 676 |
|
679 |
- self._message(MessageType.INFO, "Bundling sources for target {}".format(target.name))
|
|
677 |
+ self._context.info("Bundling sources for target {}".format(target.name))
|
|
680 | 678 |
|
681 | 679 |
# Find the correct filename for the compression algorithm
|
682 | 680 |
tar_location = os.path.join(directory, target.normal_name + ".tar")
|
... | ... | @@ -958,15 +956,6 @@ class Stream(): |
958 | 956 |
|
959 | 957 |
return selected, track_selected
|
960 | 958 |
|
961 |
- # _message()
|
|
962 |
- #
|
|
963 |
- # Local message propagator
|
|
964 |
- #
|
|
965 |
- def _message(self, message_type, message, **kwargs):
|
|
966 |
- args = dict(kwargs)
|
|
967 |
- self._context.message(
|
|
968 |
- Message(None, message_type, message, **args))
|
|
969 |
- |
|
970 | 959 |
# _add_queue()
|
971 | 960 |
#
|
972 | 961 |
# Adds a queue to the stream
|
... | ... | @@ -1017,10 +1006,10 @@ class Stream(): |
1017 | 1006 |
for element in self.total_elements:
|
1018 | 1007 |
element._update_state()
|
1019 | 1008 |
except BstError as e:
|
1020 |
- self._message(MessageType.ERROR, "Error resolving final state", detail=str(e))
|
|
1009 |
+ self._context.error("Error resolving final state", detail=str(e))
|
|
1021 | 1010 |
set_last_task_error(e.domain, e.reason)
|
1022 | 1011 |
except Exception as e: # pylint: disable=broad-except
|
1023 |
- self._message(MessageType.BUG, "Unhandled exception while resolving final state", detail=str(e))
|
|
1012 |
+ self._context.bug("Unhandled exception while resolving final state", detail=str(e))
|
|
1024 | 1013 |
|
1025 | 1014 |
if status == SchedStatus.ERROR:
|
1026 | 1015 |
raise StreamError()
|
... | ... | @@ -117,7 +117,6 @@ from weakref import WeakValueDictionary |
117 | 117 |
from . import _yaml
|
118 | 118 |
from . import utils
|
119 | 119 |
from ._exceptions import PluginError, ImplError
|
120 |
-from ._message import Message, MessageType
|
|
121 | 120 |
|
122 | 121 |
|
123 | 122 |
class Plugin():
|
... | ... | @@ -464,7 +463,7 @@ class Plugin(): |
464 | 463 |
detail (str): An optional detailed message, can be multiline output
|
465 | 464 |
"""
|
466 | 465 |
if self.__context.log_debug:
|
467 |
- self.__message(MessageType.DEBUG, brief, detail=detail)
|
|
466 |
+ self.__context.debug(brief, detail=detail)
|
|
468 | 467 |
|
469 | 468 |
def status(self, brief, *, detail=None):
|
470 | 469 |
"""Print a status message
|
... | ... | @@ -475,7 +474,7 @@ class Plugin(): |
475 | 474 |
|
476 | 475 |
Note: Status messages tell about what a plugin is currently doing
|
477 | 476 |
"""
|
478 |
- self.__message(MessageType.STATUS, brief, detail=detail)
|
|
477 |
+ self.__context.status(brief, detail=detail)
|
|
479 | 478 |
|
480 | 479 |
def info(self, brief, *, detail=None):
|
481 | 480 |
"""Print an informative message
|
... | ... | @@ -487,7 +486,7 @@ class Plugin(): |
487 | 486 |
Note: Informative messages tell the user something they might want
|
488 | 487 |
to know, like if refreshing an element caused it to change.
|
489 | 488 |
"""
|
490 |
- self.__message(MessageType.INFO, brief, detail=detail)
|
|
489 |
+ self.__context.info(brief, detail=detail)
|
|
491 | 490 |
|
492 | 491 |
def warn(self, brief, *, detail=None, warning_token=None):
|
493 | 492 |
"""Print a warning message, checks warning_token against project configuration
|
... | ... | @@ -510,7 +509,16 @@ class Plugin(): |
510 | 509 |
if project._warning_is_fatal(warning_token):
|
511 | 510 |
raise PluginError(message="{}\n{}".format(brief, detail), reason=warning_token)
|
512 | 511 |
|
513 |
- self.__message(MessageType.WARN, brief=brief, detail=detail)
|
|
512 |
+ self.__context.warn(brief, detail=detail)
|
|
513 |
+ |
|
514 |
+ def skipped(self, brief, *, detail=None):
|
|
515 |
+ """Prints a message indicating that an action has been skipped.
|
|
516 |
+ |
|
517 |
+ Args:
|
|
518 |
+ brief (str): The brief message
|
|
519 |
+ detail (str): An optional detailed message, can be multiline output
|
|
520 |
+ """
|
|
521 |
+ self.__context.skipped(brief, detail=detail)
|
|
514 | 522 |
|
515 | 523 |
def log(self, brief, *, detail=None):
|
516 | 524 |
"""Log a message into the plugin's log file
|
... | ... | @@ -522,7 +530,7 @@ class Plugin(): |
522 | 530 |
brief (str): The brief message
|
523 | 531 |
detail (str): An optional detailed message, can be multiline output
|
524 | 532 |
"""
|
525 |
- self.__message(MessageType.LOG, brief, detail=detail)
|
|
533 |
+ self.__context.log(brief, detail=detail)
|
|
526 | 534 |
|
527 | 535 |
@contextmanager
|
528 | 536 |
def timed_activity(self, activity_name, *, detail=None, silent_nested=False):
|
... | ... | @@ -718,10 +726,6 @@ class Plugin(): |
718 | 726 |
|
719 | 727 |
return (exit_code, output)
|
720 | 728 |
|
721 |
- def __message(self, message_type, brief, **kwargs):
|
|
722 |
- message = Message(self.__unique_id, message_type, brief, **kwargs)
|
|
723 |
- self.__context.message(message)
|
|
724 |
- |
|
725 | 729 |
def __note_command(self, output, *popenargs, **kwargs):
|
726 | 730 |
workdir = os.getcwd()
|
727 | 731 |
if 'cwd' in kwargs:
|