def print_end_of_run_summary(num_errors: int, num_warnings: int, keyboard_interrupt: bool = False) -> None: error_plural = utils.pluralize(num_errors, 'error') warn_plural = utils.pluralize(num_warnings, 'warning') if keyboard_interrupt: message = ui.yellow('Exited because of keyboard interrupt.') elif num_errors > 0: message = ui.red("Completed with {} and {}:".format( error_plural, warn_plural)) elif num_warnings > 0: message = ui.yellow('Completed with {}:'.format(warn_plural)) else: message = ui.green('Completed successfully') with TextOnly(): logger.info('') logger.info('{}'.format(message))
def _fetch_metadata(self, project, renderer) -> ProjectPackageMetadata: path = self._checkout() if self.unpinned_msg() and self.warn_unpinned: warn_or_error( 'The git package "{}" \n\tis {}.\n\tThis can introduce ' 'breaking changes into your project without warning!\n\nSee {}' .format(self.git, self.unpinned_msg(), PIN_PACKAGE_URL), log_fmt=ui.yellow('WARNING: {}')) loaded = Project.from_project_root(path, renderer) return ProjectPackageMetadata.from_project(loaded)
def print_run_result_error(result, newline: bool = True, is_warning: bool = False) -> None: if newline: with TextOnly(): logger.info("") if result.status == NodeStatus.Fail or (is_warning and result.status == NodeStatus.Warn): if is_warning: color = ui.yellow info = 'Warning' logger_fn = logger.warning else: color = ui.red info = 'Failure' logger_fn = logger.error logger_fn( color("{} in {} {} ({})").format(info, result.node.resource_type, result.node.name, result.node.original_file_path)) try: # if message is int, must be rows returned for a test int(result.message) except ValueError: logger.error(" Status: {}".format(result.status)) else: num_rows = utils.pluralize(result.message, 'result') logger.error(" Got {}, expected 0.".format(num_rows)) if result.node.build_path is not None: with TextOnly(): logger.info("") logger.info(" compiled SQL at {}".format(result.node.build_path)) elif result.message is not None: first = True for line in result.message.split("\n"): if first: logger.error(ui.yellow(line)) first = False else: logger.error(line)
def print_skip_line(model, schema: str, relation: str, index: int, num_models: int) -> None: msg = 'SKIP relation {}.{}'.format(schema, relation) print_fancy_output_line(msg, ui.yellow('SKIP'), logger.info, index, num_models)