summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Pollard <tom.pollard@codethink.co.uk>2019-08-13 12:16:56 +0100
committerTom Pollard <tom.pollard@codethink.co.uk>2019-08-15 12:25:47 +0100
commite5b677e2e02f4cab44ed61d4843e9b18a686ab1b (patch)
treefe590d3cbd7c6096ed5a218e639c9bfc7e32ad60
parentcf3f925764cfe6949aedbdcd313a93654f7c7657 (diff)
downloadbuildstream-e5b677e2e02f4cab44ed61d4843e9b18a686ab1b.tar.gz
_frontend/app.py: shell_prompt() explicit name/key instead of Element
By explicitly having the element_name & element_key as paramaters the Element instance does not need to be passed for simply generating a prompt. This is needed for working towards process separation.
-rw-r--r--src/buildstream/_frontend/app.py11
-rw-r--r--src/buildstream/_frontend/cli.py5
2 files changed, 10 insertions, 6 deletions
diff --git a/src/buildstream/_frontend/app.py b/src/buildstream/_frontend/app.py
index 87575b675..4e442f6ab 100644
--- a/src/buildstream/_frontend/app.py
+++ b/src/buildstream/_frontend/app.py
@@ -408,14 +408,15 @@ class App():
# if they are available in the execution context.
#
# Args:
- # element (Element): The Element object to resolve a prompt for
+ # element_name (str): The element's full name
+ # element_key (tuple): The element's display key
#
# Returns:
# (str): The formatted prompt to display in the shell
#
- def shell_prompt(self, element):
- _, key, dim = element._get_display_key()
- element_name = element._get_full_name()
+ def shell_prompt(self, element_name, element_key):
+
+ _, key, dim = element_key
if self.colors:
prompt = self._format_profile.fmt('[') + \
@@ -645,7 +646,7 @@ class App():
if choice == 'shell':
click.echo("\nDropping into an interactive shell in the failed build sandbox\n", err=True)
try:
- prompt = self.shell_prompt(element)
+ prompt = self.shell_prompt(element._get_full_name(), element._get_display_key())
self.stream.shell(element, Scope.BUILD, prompt, isolate=True, usebuildtree='always')
except BstError as e:
click.echo("Error while attempting to create interactive shell: {}".format(e), err=True)
diff --git a/src/buildstream/_frontend/cli.py b/src/buildstream/_frontend/cli.py
index 220d10477..b65da3301 100644
--- a/src/buildstream/_frontend/cli.py
+++ b/src/buildstream/_frontend/cli.py
@@ -584,7 +584,10 @@ def shell(app, element, sysroot, mount, isolate, build_, cli_buildtree, pull_, c
element = elements[-1]
pull_dependencies = elements[:-1] if pull_ else None
- prompt = app.shell_prompt(element)
+ element_name = element._get_full_name()
+ element_key = element._get_display_key()
+
+ prompt = app.shell_prompt(element_name, element_key)
mounts = [
HostMount(path, host_path)
for host_path, path in mount