Esempio n. 1
0
 def _connection_result(self):
     result = self.attempt_connection(self.profile)
     if result is not None:
         self.messages.append(result)
         self.any_failure = True
         return red('ERROR')
     return green('OK connection ok')
Esempio n. 2
0
 def test_git(self):
     try:
         dbt.clients.system.run_cmd(os.getcwd(), ['git', '--help'])
     except dbt.exceptions.ExecutableError as exc:
         self.messages.append('Error from git --help: {!s}'.format(exc))
         return red('ERROR')
     return green('OK found')
Esempio n. 3
0
 def _profile_found(self):
     if not self.raw_profile_data:
         return red('ERROR not found')
     assert self.raw_profile_data is not None
     if self.profile_name in self.raw_profile_data:
         return green('OK found')
     else:
         return red('ERROR not found')
Esempio n. 4
0
def print_hook_end_line(statement: str, status: str, index: int, total: int,
                        execution_time: float) -> None:
    msg = 'OK hook: {}'.format(statement)
    # hooks don't fail into this path, so always green
    print_fancy_output_line(msg,
                            ui.green(status),
                            logger.info,
                            index,
                            total,
                            execution_time=execution_time,
                            truncate=True)
Esempio n. 5
0
def get_printable_result(result, success: str,
                         error: str) -> Tuple[str, str, Callable]:
    if result.status == NodeStatus.Error:
        info = 'ERROR {}'.format(error)
        status = ui.red(result.status.upper())
        logger_fn = logger.error
    else:
        info = 'OK {}'.format(success)
        status = ui.green(result.message)
        logger_fn = logger.info

    return info, status, logger_fn
Esempio n. 6
0
def get_printable_result(result, success: str,
                         error: str) -> Tuple[str, str, Callable]:
    if result.error is not None:
        info = 'ERROR {}'.format(error)
        status = ui.red(result.status)
        logger_fn = logger.error
    else:
        info = 'OK {}'.format(success)
        status = ui.green(result.status)
        logger_fn = logger.info

    return info, status, logger_fn
Esempio n. 7
0
 def _target_found(self):
     requirements = (self.raw_profile_data and self.profile_name
                     and self.target_name)
     if not requirements:
         return red('ERROR not found')
     # mypy appeasement, we checked just above
     assert self.raw_profile_data is not None
     assert self.profile_name is not None
     assert self.target_name is not None
     if self.profile_name not in self.raw_profile_data:
         return red('ERROR not found')
     profiles = self.raw_profile_data[self.profile_name]['outputs']
     if self.target_name not in profiles:
         return red('ERROR not found')
     return green('OK found')
Esempio n. 8
0
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))
Esempio n. 9
0
    def _load_profile(self):
        if not os.path.exists(self.profile_path):
            self.profile_fail_details = FILE_NOT_FOUND
            self.messages.append(MISSING_PROFILE_MESSAGE.format(
                path=self.profile_path, url=ProfileConfigDocs
            ))
            return red('ERROR not found')

        try:
            raw_profile_data = load_yaml_text(
                dbt.clients.system.load_file_contents(self.profile_path)
            )
        except Exception:
            pass  # we'll report this when we try to load the profile for real
        else:
            if isinstance(raw_profile_data, dict):
                self.raw_profile_data = raw_profile_data

        profile_errors = []
        profile_names = self._choose_profile_names()
        renderer = ProfileRenderer(generate_base_context(self.cli_vars))
        for profile_name in profile_names:
            try:
                profile: Profile = QueryCommentedProfile.render_from_args(
                    self.args, renderer, profile_name
                )
            except dbt.exceptions.DbtConfigError as exc:
                profile_errors.append(str(exc))
            else:
                if len(profile_names) == 1:
                    # if a profile was specified, set it on the task
                    self.target_name = self._choose_target_name(profile_name)
                    self.profile = profile

        if profile_errors:
            self.profile_fail_details = '\n\n'.join(profile_errors)
            return red('ERROR invalid')
        return green('OK found and valid')
Esempio n. 10
0
    def _load_project(self):
        if not os.path.exists(self.project_path):
            self.project_fail_details = FILE_NOT_FOUND
            return red('ERROR not found')

        if self.profile is None:
            ctx = generate_base_context(self.cli_vars)
        else:
            ctx = generate_target_context(self.profile, self.cli_vars)

        renderer = DbtProjectYamlRenderer(ctx)

        try:
            self.project = Project.from_project_root(
                self.project_dir,
                renderer,
                verify_version=getattr(self.args, 'version_check', False),
            )
        except dbt.exceptions.DbtConfigError as exc:
            self.project_fail_details = str(exc)
            return red('ERROR invalid')

        return green('OK found and valid')