示例#1
0
文件: printer.py 项目: clrcrl/Fonz
def print_fancy_line(msg: str, status: str, index: int, total: int) -> None:
    progress = "{} of {} ".format(index, total)
    prefix = "{timestamp} | {progress}{message}".format(
        timestamp=get_timestamp(), progress=progress, message=msg
    )

    justified = prefix.ljust(PRINTER_WIDTH, ".")

    status_txt = status

    output = "{justified} [{status}]".format(justified=justified, status=status_txt)

    logger.info(output)
示例#2
0
    def connect(self) -> None:
        """Authenticate, start a dev session, check out specified branch."""

        logger.info("Authenticating Looker credentials. \n")

        url = utils.compose_url(self.base_url, path=["login"])
        body = {
            "client_id": self.client_id,
            "client_secret": self.client_secret
        }
        response = self.session.post(url=url, data=body)
        try:
            response.raise_for_status()
        except requests.exceptions.HTTPError as error:
            raise ConnectionError(
                f"Failed to authenticate to {url}\n"
                f'Attempted authentication with client ID "{self.client_id}"\n'
                f'Error raised: "{error}"')

        access_token = response.json()["access_token"]
        self.session.headers = {"Authorization": f"token {access_token}"}
示例#3
0
文件: printer.py 项目: clrcrl/Fonz
def print_stats(errors: int, total: int) -> None:
    stats = {"error": errors, "pass": total - errors, "total": total}

    stats_line = "\nDone. PASS={pass} ERROR={error} TOTAL={total}"
    logger.info(stats_line.format(**stats))
示例#4
0
文件: printer.py 项目: clrcrl/Fonz
def print_error(message: str):
    logger.info(yellow("\n" + message))