summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAngelos Evripiotis <jevripiotis@bloomberg.net>2019-03-15 14:54:31 +0000
committerAngelos Evripiotis <jevripiotis@bloomberg.net>2019-03-19 12:51:49 +0000
commit7df9a8660b637043d0cf7cdbad487d1512a65c01 (patch)
tree5720f70385a5c961dd0557c59829c78e6ee70e0a
parent964261032b8ad1864680a9a38da9c27d8e1bf3c7 (diff)
downloadbuildstream-aevri/str_e.tar.gz
app.py: str(e) instead of "{}".format(e)aevri/str_e
We're not implementing __format__ anywhere, so there's no reason to prefer format() over the more conventional conversion with str(). In one case no conversion is needed at all, so remove it. In another case the conversion is better done in the called function (_notify), not where the function is called. For the _message case, there are quite a few places that might need fixing up, so that is left for later work. Note that SubprocessError is a vanilla subclass of Exception: https://github.com/python/cpython/blob/bafa8487f77fa076de3a06755399daf81cb75598/Lib/subprocess.py#L96
-rw-r--r--buildstream/_frontend/app.py8
-rw-r--r--buildstream/_frontend/widget.py2
-rw-r--r--buildstream/_stream.py2
-rw-r--r--buildstream/sandbox/_sandboxchroot.py2
4 files changed, 7 insertions, 7 deletions
diff --git a/buildstream/_frontend/app.py b/buildstream/_frontend/app.py
index c1a5e57b7..67fcc8370 100644
--- a/buildstream/_frontend/app.py
+++ b/buildstream/_frontend/app.py
@@ -272,7 +272,7 @@ class App():
self._message(MessageType.FAIL, session_name, elapsed=elapsed)
# Notify session failure
- self._notify("{} failed".format(session_name), "{}".format(e))
+ self._notify("{} failed".format(session_name), e)
if self._started:
self._print_summary()
@@ -431,7 +431,7 @@ class App():
#
def _notify(self, title, text):
if self.interactive:
- self.notify(title, text)
+ self.notify(str(title), str(text))
# Local message propagator
#
@@ -658,7 +658,7 @@ class App():
#
def _error_exit(self, error, prefix=None):
click.echo("", err=True)
- main_error = "{}".format(error)
+ main_error = str(error)
if prefix is not None:
main_error = "{}: {}".format(prefix, main_error)
@@ -666,7 +666,7 @@ class App():
if error.detail:
indent = " " * INDENT
detail = '\n' + indent + indent.join(error.detail.splitlines(True))
- click.echo("{}".format(detail), err=True)
+ click.echo(detail, err=True)
sys.exit(-1)
diff --git a/buildstream/_frontend/widget.py b/buildstream/_frontend/widget.py
index 15bd9cf79..45be6d136 100644
--- a/buildstream/_frontend/widget.py
+++ b/buildstream/_frontend/widget.py
@@ -486,7 +486,7 @@ class LogLine(Widget):
values["Session Start"] = starttime.strftime('%A, %d-%m-%Y at %H:%M:%S')
values["Project"] = "{} ({})".format(project.name, project.directory)
values["Targets"] = ", ".join([t.name for t in stream.targets])
- values["Cache Usage"] = "{}".format(context.get_cache_usage())
+ values["Cache Usage"] = str(context.get_cache_usage())
text += self._format_values(values)
# User configurations
diff --git a/buildstream/_stream.py b/buildstream/_stream.py
index 4a21f5002..3276b4081 100644
--- a/buildstream/_stream.py
+++ b/buildstream/_stream.py
@@ -553,7 +553,7 @@ class Stream():
try:
self._artifacts.remove(ref, defer_prune=True)
except CASCacheError as e:
- self._message(MessageType.WARN, "{}".format(e))
+ self._message(MessageType.WARN, str(e))
continue
self._message(MessageType.INFO, "Removed: {}".format(ref))
diff --git a/buildstream/sandbox/_sandboxchroot.py b/buildstream/sandbox/_sandboxchroot.py
index 71422476a..7266a00e3 100644
--- a/buildstream/sandbox/_sandboxchroot.py
+++ b/buildstream/sandbox/_sandboxchroot.py
@@ -188,7 +188,7 @@ class SandboxChroot(Sandbox):
# Exceptions in preexec_fn are simply reported as
# 'Exception occurred in preexec_fn', turn these into
# a more readable message.
- if '{}'.format(e) == 'Exception occurred in preexec_fn.':
+ if str(e) == 'Exception occurred in preexec_fn.':
raise SandboxError('Could not chroot into {} or chdir into {}. '
'Ensure you are root and that the relevant directory exists.'
.format(rootfs, cwd)) from e