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)
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}"}
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))
def print_error(message: str): logger.info(yellow("\n" + message))