JackWink/Weather

can't pipe hourly

Closed this issue · 2 comments

wxl commented

using weather -o | less, more, head, or tail i get the following error:

Traceback (most recent call last):
  File "/home/wxl/bin/weather", line 196, in <module>
    main(parser.parse_args())
  File "/home/wxl/bin/weather", line 181, in main
    parse_weather_data(r.content, args)
  File "/home/wxl/bin/weather", line 154, in parse_weather_data
    parse_hourly(data['hourly_forecast'], args.metric)
  File "/home/wxl/bin/weather", line 104, in parse_hourly
    print_table(sys.stdout, val)
  File "/home/wxl/bin/weather", line 38, in print_table
    print >> out, col,
UnicodeEncodeError: 'ascii' codec can't encode character u'\xb0' in position 11: ordinal 
not in range(128)   

Still looking for a cleaner solution, but you should be able to fix this by running export PYTHONIOENCODING='utf-8' in your terminal

Resolved by wrapping sys.stdout in a utf-8 stream writer