def show_response(cls, response, callback=None): if callable(callback): response = callback(response) if response is not None: LOG.echo(response)
def echo_outputs(self, cell): LOG.echo('-' * self.LINE_WIDTH) if not hasattr(cell, 'outputs') or len(cell.outputs) == 0: return [self._print_cell_output(out) for out in cell.outputs] LOG.echo('-' * self.LINE_WIDTH)
def _print_cell_output(self, out): dyct = out.dict() if dyct.get('output_type') == 'error': ename, evalue = dyct.get('ename', ''), dyct.get('evalue', '') LOG.error('{}: {}'.format(ename, evalue)) else: text = dyct.get('text', '') LOG.echo(text.strip())
def version(): """Framework's version""" LOG.echo("Noronha Dataops v%s" % FrameworkConst.FW_VERSION) pkg = pkg_resources.require(FrameworkConst.FW_NAME)[0] try: meta = pkg.get_metadata_lines('METADATA') except FileNotFoundError: meta = pkg.get_metadata_lines('PKG-INFO') for line in meta: if not line.startswith('Requires'): LOG.info(line)
def __call__(self, objs: List[SmartBaseDoc]): if len(objs) == 0: LOG.echo("No {}(s) found".format(self.obj_title)) else: LOG.echo("Listing {}(s):".format(self.obj_title)) for obj in objs: if self.expand: LOG.echo(obj.pretty()) else: LOG.echo(obj.show())
def cell_start(self, cell, *args, **kwargs): self.index += 1 LOG.echo(self.format_source(cell)) super().cell_start(cell, *args, **kwargs)