Tristan Van Berkom pushed to branch tristan/notifications at BuildStream / buildstream
Commits:
-
b62c361c
by Tiago Gomes at 2018-08-16T13:54:54Z
-
1e3e2a93
by Tiago Gomes at 2018-08-16T15:00:12Z
-
10f27f3f
by Tristan Van Berkom at 2018-08-17T06:20:40Z
2 changed files:
Changes:
... | ... | @@ -25,6 +25,7 @@ import signal |
25 | 25 |
import stat
|
26 | 26 |
import tempfile
|
27 | 27 |
import uuid
|
28 |
+import errno
|
|
28 | 29 |
from urllib.parse import urlparse
|
29 | 30 |
|
30 | 31 |
import grpc
|
... | ... | @@ -82,7 +83,8 @@ class CASCache(ArtifactCache): |
82 | 83 |
|
83 | 84 |
tree = self.resolve_ref(ref, update_mtime=True)
|
84 | 85 |
|
85 |
- dest = os.path.join(self.extractdir, element._get_project().name, element.normal_name, tree.hash)
|
|
86 |
+ dest = os.path.join(self.extractdir, element._get_project().name,
|
|
87 |
+ element.normal_name, tree.hash)
|
|
86 | 88 |
if os.path.isdir(dest):
|
87 | 89 |
# artifact has already been extracted
|
88 | 90 |
return dest
|
... | ... | @@ -100,7 +102,7 @@ class CASCache(ArtifactCache): |
100 | 102 |
#
|
101 | 103 |
# If rename fails with these errors, another process beat
|
102 | 104 |
# us to it so just ignore.
|
103 |
- if e.errno not in [os.errno.ENOTEMPTY, os.errno.EEXIST]:
|
|
105 |
+ if e.errno not in [errno.ENOTEMPTY, errno.EEXIST]:
|
|
104 | 106 |
raise ArtifactError("Failed to extract artifact for ref '{}': {}"
|
105 | 107 |
.format(ref, e)) from e
|
106 | 108 |
|
... | ... | @@ -269,6 +269,9 @@ class App(): |
269 | 269 |
else:
|
270 | 270 |
self._message(MessageType.FAIL, session_name, elapsed=elapsed)
|
271 | 271 |
|
272 |
+ # Notify session failure
|
|
273 |
+ self._notify("{} failed".format(session_name), "{}".format(e))
|
|
274 |
+ |
|
272 | 275 |
if self._started:
|
273 | 276 |
self._print_summary()
|
274 | 277 |
|
... | ... | @@ -286,6 +289,9 @@ class App(): |
286 | 289 |
if self._started:
|
287 | 290 |
self._print_summary()
|
288 | 291 |
|
292 |
+ # Notify session success
|
|
293 |
+ self._notify("{} succeeded".format(session_name), "")
|
|
294 |
+ |
|
289 | 295 |
# init_project()
|
290 | 296 |
#
|
291 | 297 |
# Initialize a new BuildStream project, either with the explicitly passed options,
|
... | ... | @@ -419,6 +425,12 @@ class App(): |
419 | 425 |
# Local Functions #
|
420 | 426 |
############################################################
|
421 | 427 |
|
428 |
+ # Local function for calling the notify() virtual method
|
|
429 |
+ #
|
|
430 |
+ def _notify(self, title, text):
|
|
431 |
+ if self.interactive:
|
|
432 |
+ self.notify(title, text)
|
|
433 |
+ |
|
422 | 434 |
# Local message propagator
|
423 | 435 |
#
|
424 | 436 |
def _message(self, message_type, message, **kwargs):
|
... | ... | @@ -571,8 +583,8 @@ class App(): |
571 | 583 |
while choice not in ['continue', 'quit', 'terminate', 'retry']:
|
572 | 584 |
click.echo(summary, err=True)
|
573 | 585 |
|
574 |
- self.notify("BuildStream failure", "{} on element {}"
|
|
575 |
- .format(failure.action_name, element.name))
|
|
586 |
+ self._notify("BuildStream failure", "{} on element {}"
|
|
587 |
+ .format(failure.action_name, element.name))
|
|
576 | 588 |
|
577 | 589 |
try:
|
578 | 590 |
choice = click.prompt("Choice:", default='continue', err=True,
|