Skip to content

Commit

Permalink
Using display-information from cauldron.json to control whether code …
Browse files Browse the repository at this point in the history
…and errors are rendered in the output
  • Loading branch information
larsrinn committed Jun 25, 2017
1 parent d3cb0e1 commit b4b5ab0
Showing 1 changed file with 19 additions and 16 deletions.
35 changes: 19 additions & 16 deletions cauldron/session/projects/steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,16 +171,19 @@ def dumps(self) -> str:
:return:
"""
kwargs = dict()
display = self.project.settings.fetch('display', dict())

code_file_path = os.path.join(
self.project.source_directory,
self.filename
)
code = dict(
filename=self.filename,
path=code_file_path,
code=render.code_file(code_file_path)
)
if display.get('code', True):
code_file_path = os.path.join(
self.project.source_directory,
self.filename
)
kwargs['code'] = dict(
filename=self.filename,
path=code_file_path,
code=render.code_file(code_file_path)
)

if not self.is_running:
# If no longer running, make sure to flush the stdout buffer so
Expand Down Expand Up @@ -211,16 +214,16 @@ def dumps(self) -> str:
body.find('<li') != -1
)

std_err = (
self.report.read_stderr()
if self.is_running else
self.report.flush_stderr()
).strip('\n').rstrip()
if display.get('errors', True):
kwargs['std_err'] = (
self.report.read_stderr()
if self.is_running else
self.report.flush_stderr()
).strip('\n').rstrip()

dom = templating.render_template(
'step-body.html',
last_display_update=self.report.last_update_time,
code=code,
body=body,
has_body=has_body,
id=self.definition.name,
Expand All @@ -234,7 +237,7 @@ def dumps(self) -> str:
progress=int(round(max(0, min(100, 100 * self.progress)))),
sub_progress_message=self.sub_progress_message,
sub_progress=int(round(max(0, min(100, 100 * self.sub_progress)))),
std_err=std_err
**kwargs
)

if not self.is_running:
Expand Down

0 comments on commit b4b5ab0

Please sign in to comment.