aboutsummaryrefslogtreecommitdiff
path: root/youtube_dl/FileDownloader.py
diff options
context:
space:
mode:
authorJaime Marquínez Ferrándiz <jaimemf93@gmail.com>2013-03-04 11:27:25 +0100
committerJaime Marquínez Ferrándiz <jaimemf93@gmail.com>2013-03-04 11:27:25 +0100
commit4e1582f372d74d551e19d319e5b345002def480d (patch)
tree1b5864ac2bb3a8fb9ccb3fb2a5145d29ccec3a1c /youtube_dl/FileDownloader.py
parent967897fd227c85ebe3368b359a4f8c471e513de6 (diff)
Use red color when printing error messages
Diffstat (limited to 'youtube_dl/FileDownloader.py')
-rw-r--r--youtube_dl/FileDownloader.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/youtube_dl/FileDownloader.py b/youtube_dl/FileDownloader.py
index 57f741c30..2f6c393a4 100644
--- a/youtube_dl/FileDownloader.py
+++ b/youtube_dl/FileDownloader.py
@@ -246,6 +246,18 @@ class FileDownloader(object):
warning_message=u'%s %s' % (_msg_header,message)
self.to_stderr(warning_message)
+ def report_error(self, message, tb=None):
+ '''
+ Do the same as trouble, but prefixes the message with 'ERROR:', colored
+ in red if stderr is a tty file.
+ '''
+ if sys.stderr.isatty():
+ _msg_header = u'\033[0;31mERROR:\033[0m'
+ else:
+ _msg_header = u'ERROR:'
+ error_message = u'%s %s' % (_msg_header, message)
+ self.trouble(error_message, tb)
+
def slow_down(self, start_time, byte_counter):
"""Sleep if the download speed is over the rate limit."""
rate_limit = self.params.get('ratelimit', None)