GithubHelp home page GithubHelp logo

Comments (20)

lllama avatar lllama commented on April 28, 2024

It does look like the colorama module could be a fairly simple way to address this:
http://pypi.python.org/pypi/colorama

from httpie.

dethstryke avatar dethstryke commented on April 28, 2024

Bummed to find this bug, colored output would be nice.

from httpie.

jkbrzt avatar jkbrzt commented on April 28, 2024

This should be fixed now. Thanks for the tip for colorama, it works very well. I've tested it on Python 2.7 under Windows 7 with PowerShell and cmd.exe.

It would be great if you could test it and provide feedback (I don't use Windows very often):

pip install -U https://github.com/jkbr/httpie/tarball/master

There is one remaining Windows-related issue (unicode in terminal #71).

httpie on windows

from httpie.

obmarg avatar obmarg commented on April 28, 2024

I've just tested with powershell, zsh & cmd.exe using Python 2.7 - seems to work perfectly. Thanks for the fix.

from httpie.

jkbrzt avatar jkbrzt commented on April 28, 2024

Glad to hear that. Thanks for the feedback.

from httpie.

GuiSim avatar GuiSim commented on April 28, 2024

I get the following warnings when running httpie under PyPy 1.6 :

path\to\colorama\win32.py:17: RuntimeWarning: C function without declared arguments called
  STDOUT: windll.kernel32.GetStdHandle(STDOUT),
path\to\colorama\win32.py:18: RuntimeWarning: C function without declared arguments called
  STDERR: windll.kernel32.GetStdHandle(STDERR),
path\to\colorama\win32.py:64: RuntimeWarning: C function without declared arguments called
  handle, byref(csbi))
path\to\colorama\win32.py:70: RuntimeWarning: C function without declared arguments called
  return windll.kernel32.SetConsoleTextAttribute(handle, attrs)

I think that this is caused by PyPy (see http://mail.python.org/pipermail/pypy-commit/2011-April/049781.html)
but I suspect that the code could be changed to avoid this warning.

EDIT: Nevermind, these warnings are coming from Colorama.

http://code.google.com/p/colorama/issues/detail?id=26

from httpie.

dethstryke avatar dethstryke commented on April 28, 2024

I'm still getting this using ActivePython 3.2.2.3 I ran the update command you listed and am still getting the same output as before. Am I missing anything?

from httpie.

jkbrzt avatar jkbrzt commented on April 28, 2024

@dethstryke What is the output of http --version? If it says something else than 0.2.6dev, then please try to uninstall the old version first and then install the dev one again:

pip uninstall httpie
pip install -U https://github.com/jkbr/httpie/tarball/master

from httpie.

kaplas avatar kaplas commented on April 28, 2024

I'm sorry that I didn't notice this issue thread when making the pull request. Also when I named my fork, I didn't know that you have already included colorama in the project. However, the dev branch did not work for me. (http --version gives 0.2.6dev for me) As I mention in my pull request, I had to change the stdout writing to a single print statement to get it working.

As a proof, here's a screenshot showing installation from the dev branch (on the left) and then from my fork (on the right):
http://grab.by/eRsq

I also had to install 'requests' separately, because the one provided by pip didn't work on my system. But by installing requests directly from their git repo worked flawesly.

I'm totally newbie with python, pip and colorama, and quite newbie also with github, so I'm sorry if this is just some Stupid User Error. But I still think that there is something wrong with outputting to the cmd.exe window, and my pull request seems to fix it.

from httpie.

mieky avatar mieky commented on April 28, 2024

At a quick glance it would seem that a simple 'print output' (without any explicit encoding being done) works nicely on both Windows and OS X. I just want to understand the details involved - what would break if we were to remove the check for stdout.buffer and/or the encoding parts?

from httpie.

jkbrzt avatar jkbrzt commented on April 28, 2024

@mieky Encoding the output ensures that unicode characters (like ě, not colors) are displayed correctly on the terminal. The way it's done now seems to work well under OS X and Linux on all the supported Pythons, but on Windows it's still displayed incorrectly (#71).

The color problem that some people are still seing on Windows is most likely caused by the fact that colorama is unable to process the output on some configurations (due to the way it's being written/encoded for OSX/Linux).

So, @cido's patch seems to solve the occasional color-related problems on Windows, but the output still needs to be encoded (somehow) to ensure that unicode works.

It's quite tricky to solve it universally. Any help appreciated.

from httpie.

mariodev avatar mariodev commented on April 28, 2024

@jkbr Is there any changes I need to make to my win cmd.exe to prettify the output? Since I've installed 0.2.6-dev and still I get escape codes..

from httpie.

jkbrzt avatar jkbrzt commented on April 28, 2024

Please try the current master:

pip install -U https://github.com/jkbr/httpie/tarball/master

from httpie.

mariodev avatar mariodev commented on April 28, 2024

@jkbr Thank you, that worked.

from httpie.

jkbrzt avatar jkbrzt commented on April 28, 2024

This seems to be fixed in 0.2.6. Please feel free to reopen this issue if the problem persists.

from httpie.

hickford avatar hickford commented on April 28, 2024

Thanks

pip install --upgrade httpie

from httpie.

mykwillis avatar mykwillis commented on April 28, 2024

I'm not sure if there was a regression of if there is some problem with my local terminal, but the most recent version is showing this behavior for me.

python --version
Python 3.4.3

http --version
0.9.2
←[0m

http httpie.org
←[38;5;33mHTTP←[39m←[38;5;245m/←[39m←[38;5;37m1.1←[39m←[38;5;245m ←[39m←[38;5;37m302←[39m←[38;5;245m ←[39m←[38;5;136mFound←[39m
←[38;5;245mConnection←[39m←[38;5;245m:←[39m←[38;5;245m ←[39m←[38;5;37mclose←[39m
←[38;5;245mContent-Length←[39m←[38;5;245m:←[39m←[38;5;245m ←[39m←[38;5;37m292←[39m
[...]

from httpie.

bryanbak avatar bryanbak commented on April 28, 2024

I just installed this on windows and am having the same issue as @mykwillis, but only in powershell. If I use httpie in the regular cmd prompt it looks fine.

Windows 7
python 2.7.10
httpie 0.9.2

from httpie.

mykwillis avatar mykwillis commented on April 28, 2024

I notice that if I

pip install colorama==0.3.2

as opposed to using the latest colorama (0.3.3), then I don't get the control characters in the output.

It's not in color, but at least it's not garbled.

So this is likely something to do with a change in colorama between 0.3.2 and 0.3.3

from httpie.

bryanbak avatar bryanbak commented on April 28, 2024

Just downgraded colorama to 0.3.2 based on @mykwillis suggestion and powershell output looks much better now. Thanks for the advice!

from httpie.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.