Allow output redirection on Windows.

Closes #88.
This commit is contained in:
Jakub Roztocil 2012-09-21 04:30:59 +02:00
parent 4a6f32a0f4
commit a41dd7ac6d
3 changed files with 3 additions and 17 deletions

View File

@ -1026,6 +1026,7 @@ Changelog
*You can click a version name to see a diff with the previous one.* *You can click a version name to see a diff with the previous one.*
* `0.2.8-alpha`_ * `0.2.8-alpha`_
* Allow output redirection on Windows.
* Added config file. * Added config file.
* Added persistent session support. * Added persistent session support.
* Renamed ``--allow-redirects`` to ``--follow``. * Renamed ``--allow-redirects`` to ``--follow``.

View File

@ -96,10 +96,6 @@ class Parser(ArgumentParser):
self.env = env self.env = env
if env.is_windows and not env.stdout_isatty:
self.error('Output redirection is not supported on Windows.'
' Please use `--output FILE\' instead.')
args = super(Parser, self).parse_args(args, namespace) args = super(Parser, self).parse_args(args, namespace)
if not args.json and env.config.implicit_content_type == 'form': if not args.json and env.config.implicit_content_type == 'form':
@ -244,7 +240,7 @@ class Parser(ArgumentParser):
if args.prettify == PRETTY_STDOUT_TTY_ONLY: if args.prettify == PRETTY_STDOUT_TTY_ONLY:
args.prettify = PRETTY_MAP['all' if env.stdout_isatty else 'none'] args.prettify = PRETTY_MAP['all' if env.stdout_isatty else 'none']
elif args.prettify and env.is_windows: elif args.prettify and env.is_windows:
self.error('Only terminal output can be prettified on Windows.') self.error('Only terminal output can be colorized on Windows.')
else: else:
args.prettify = PRETTY_MAP[args.prettify] args.prettify = PRETTY_MAP[args.prettify]

View File

@ -941,17 +941,6 @@ class WindowsOnlyTests(BaseTestCase):
class FakeWindowsTest(BaseTestCase): class FakeWindowsTest(BaseTestCase):
def test_stdout_redirect_not_supported_on_windows(self):
env = TestEnvironment(is_windows=True, stdout_isatty=False)
r = http(
'GET',
httpbin('/get'),
env=env
)
self.assertNotEqual(r.exit_status, EXIT.OK)
self.assertIn('Windows', r.stderr)
self.assertIn('--output', r.stderr)
def test_output_file_pretty_not_allowed_on_windows(self): def test_output_file_pretty_not_allowed_on_windows(self):
r = http( r = http(
@ -963,7 +952,7 @@ class FakeWindowsTest(BaseTestCase):
env=TestEnvironment(is_windows=True) env=TestEnvironment(is_windows=True)
) )
self.assertIn( self.assertIn(
'Only terminal output can be prettified on Windows', r.stderr) 'Only terminal output can be colorized on Windows', r.stderr)
class StreamTest(BaseTestCase): class StreamTest(BaseTestCase):