Execute input notebook and save it to file.

        If no output path given, the output will be printed to stdout.

        If any errors occur from executing the notebook's paragraphs, they will
        be displayed in stderr.

def execute_notebook(self, data):
        """Execute input notebook and save it to file.

        If no output path given, the output will be printed to stdout.

        If any errors occur from executing the notebook's paragraphs, they will
        be displayed in stderr.
        """
        self.create_notebook(data)
        self.run_notebook()
        self.wait_for_notebook_to_execute()
        body = self.get_executed_notebook()

        err = False
        output = []
        for paragraph in body['paragraphs']:
            if 'results' in paragraph and paragraph['results']['code'] == 'ERROR':
                output.append(paragraph['results']['msg'][0]['data'])
                err = True

            elif 'result' in paragraph and paragraph['result']['code'] == 'ERROR':
                output.append(paragraph['result']['msg'])
                err = True

        [print(e.strip() + '\n', file=sys.stderr) for e in output if e]

        if err:
            sys.exit(1)

        if not self.output_path:
            print(json.dumps(body, indent=2))
        else:
            self.save_notebook(body)