diff options
author | rzhxeo <rzhxeot7z81b4700@mailcatch.com> | 2013-11-18 00:27:06 +0100 |
---|---|---|
committer | rzhxeo <rzhxeot7z81b4700@mailcatch.com> | 2013-11-18 00:27:06 +0100 |
commit | 2b35c9ef742bf261078ea10c6c0bba848db1a0df (patch) | |
tree | fe80c838c7529c8cab6f1b44d730a2849cd68c48 /test/helper.py | |
parent | 4894fe8c5baec8b1f21ac6fdebe08175abc7f094 (diff) | |
parent | 73c566695fac926e7e9e6922fe4e6d82c64a1850 (diff) |
Merge branch 'master' into rtmpdump
Conflicts:
youtube_dl/FileDownloader.py
Merge
Diffstat (limited to 'test/helper.py')
-rw-r--r-- | test/helper.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/test/helper.py b/test/helper.py index 777119ea5..d7bf7a828 100644 --- a/test/helper.py +++ b/test/helper.py @@ -5,9 +5,11 @@ import json import os.path import re import types +import sys import youtube_dl.extractor from youtube_dl import YoutubeDL +from youtube_dl.utils import preferredencoding def global_setup(): @@ -33,6 +35,21 @@ def try_rm(filename): raise +def report_warning(message): + ''' + 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() and os.name != 'nt': + _msg_header = u'\033[0;33mWARNING:\033[0m' + else: + _msg_header = u'WARNING:' + output = u'%s %s\n' % (_msg_header, message) + if 'b' in getattr(sys.stderr, 'mode', '') or sys.version_info[0] < 3: + output = output.encode(preferredencoding()) + sys.stderr.write(output) + + class FakeYDL(YoutubeDL): def __init__(self, override=None): # Different instances of the downloader can't share the same dictionary |