mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-10 15:28:34 +01:00
move footer from logger to main
This commit is contained in:
+1
-15
@@ -48,16 +48,6 @@ class ColorFormatter(logging.Formatter):
|
||||
"CRITICAL": colorama.Fore.RED,
|
||||
}
|
||||
|
||||
footer = (
|
||||
"{yellow}Having any troubles?{nc}"
|
||||
" Hit us up at {blue}https://dvc.org/support{nc},"
|
||||
" we are always happy to help!"
|
||||
).format(
|
||||
blue=colorama.Fore.BLUE,
|
||||
nc=colorama.Fore.RESET,
|
||||
yellow=colorama.Fore.YELLOW,
|
||||
)
|
||||
|
||||
def format(self, record):
|
||||
if record.levelname == "INFO":
|
||||
return record.msg
|
||||
@@ -66,10 +56,7 @@ class ColorFormatter(logging.Formatter):
|
||||
exception, stack_trace = self._parse_exc(record.exc_info)
|
||||
|
||||
return (
|
||||
"{color}{levelname}{nc}: {description}"
|
||||
"{stack_trace}\n"
|
||||
"\n"
|
||||
"{footer}"
|
||||
"{color}{levelname}{nc}: {description}" "{stack_trace}\n"
|
||||
).format(
|
||||
color=self.color_code.get(record.levelname, ""),
|
||||
nc=colorama.Fore.RESET,
|
||||
@@ -77,7 +64,6 @@ class ColorFormatter(logging.Formatter):
|
||||
description=self._description(record.msg, exception),
|
||||
msg=record.msg,
|
||||
stack_trace=stack_trace,
|
||||
footer=self.footer,
|
||||
)
|
||||
|
||||
return "{color}{levelname}{nc}: {msg}".format(
|
||||
|
||||
+14
@@ -3,6 +3,7 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import logging
|
||||
import colorama
|
||||
|
||||
from dvc.cli import parse_args
|
||||
from dvc.lock import LockError
|
||||
@@ -16,6 +17,16 @@ from dvc.utils.compat import is_py2
|
||||
|
||||
logger = logging.getLogger("dvc")
|
||||
|
||||
footer = (
|
||||
"\n{yellow}Having any troubles?{nc}"
|
||||
" Hit us up at {blue}https://dvc.org/support{nc},"
|
||||
" we are always happy to help!"
|
||||
).format(
|
||||
blue=colorama.Fore.BLUE,
|
||||
nc=colorama.Fore.RESET,
|
||||
yellow=colorama.Fore.YELLOW,
|
||||
)
|
||||
|
||||
|
||||
def main(argv=None):
|
||||
"""Run dvc CLI command.
|
||||
@@ -75,6 +86,9 @@ def main(argv=None):
|
||||
# so won't be reused by any other subsequent run anyway.
|
||||
clean_repos()
|
||||
|
||||
if ret != 0:
|
||||
logger.info(footer)
|
||||
|
||||
Analytics().send_cmd(cmd, args, ret)
|
||||
|
||||
return ret
|
||||
|
||||
+6
-2
@@ -515,7 +515,9 @@ class RemoteBASE(object):
|
||||
no_progress_bar=no_progress_bar,
|
||||
)
|
||||
except Exception:
|
||||
return 1, from_info, to_info, "upload" # 1 fail
|
||||
msg = "failed to upload '{}' to '{}'"
|
||||
logger.exception(msg.format(from_info, to_info))
|
||||
return 1 # 1 fail
|
||||
|
||||
return 0
|
||||
|
||||
@@ -553,7 +555,9 @@ class RemoteBASE(object):
|
||||
from_info, tmp_file, name=name, no_progress_bar=no_progress_bar
|
||||
)
|
||||
except Exception:
|
||||
return 1, from_info, to_info, "download" # 1 fail
|
||||
msg = "failed to upload '{}' to '{}'"
|
||||
logger.exception(msg.format(from_info, to_info))
|
||||
return 1 # 1 fail
|
||||
|
||||
move(tmp_file, to_info, mode=file_mode)
|
||||
|
||||
|
||||
+2
-17
@@ -358,26 +358,11 @@ class RemoteLOCAL(RemoteBASE):
|
||||
if len(plans[0]) == 0:
|
||||
return 0
|
||||
|
||||
fails = 0
|
||||
msgs = ""
|
||||
if jobs > 1:
|
||||
with TqdmThreadPoolExecutor(max_workers=jobs) as executor:
|
||||
failures = executor.map(func, *plans)
|
||||
fails = sum(executor.map(func, *plans))
|
||||
else:
|
||||
failures = list(map(func, *plans))
|
||||
|
||||
for failure in failures:
|
||||
if not isinstance(failure, tuple):
|
||||
continue
|
||||
fails += failure[0]
|
||||
from_info, to_info = failure[1], failure[2]
|
||||
operation = failure[3]
|
||||
msgs += "Failed to {} '{}' to '{}'\n".format(
|
||||
operation, from_info, to_info
|
||||
)
|
||||
|
||||
if msgs:
|
||||
logger.exception(msgs)
|
||||
fails = sum(map(func, *plans))
|
||||
|
||||
if fails:
|
||||
if download:
|
||||
|
||||
Reference in New Issue
Block a user