]> gitweb @ CieloNegro.org - youtube-dl.git/blobdiff - youtube_dl/FileDownloader.py
Disable colored messages in Windows (related #794)
[youtube-dl.git] / youtube_dl / FileDownloader.py
index 7139adf6bb6490b31dc3661b0fc220df30b0dad2..30ab68278a85c7e561a74f00e927b8fe30f8ae80 100644 (file)
@@ -121,7 +121,7 @@ class FileDownloader(object):
             exponent = 0
         else:
             exponent = int(math.log(bytes, 1024.0))
-        suffix = 'bkMGTPEZY'[exponent]
+        suffix = ['B','KiB','MiB','GiB','TiB','PiB','EiB','ZiB','YiB'][exponent]
         converted = float(bytes) / float(1024 ** exponent)
         return '%.2f%s' % (converted, suffix)
 
@@ -254,7 +254,7 @@ class FileDownloader(object):
         Print the message to stderr, it will be prefixed with 'WARNING:'
         If stderr is a tty file the 'WARNING:' will be colored
         '''
-        if sys.stderr.isatty():
+        if sys.stderr.isatty() and os.name != 'nt':
             _msg_header=u'\033[0;33mWARNING:\033[0m'
         else:
             _msg_header=u'WARNING:'
@@ -266,7 +266,7 @@ class FileDownloader(object):
         Do the same as trouble, but prefixes the message with 'ERROR:', colored
         in red if stderr is a tty file.
         '''
-        if sys.stderr.isatty():
+        if sys.stderr.isatty() and os.name != 'nt':
             _msg_header = u'\033[0;31mERROR:\033[0m'
         else:
             _msg_header = u'ERROR:'