Bug 893368 - spacecmd fails when piping errata information when errata description contains special characters
Summary: spacecmd fails when piping errata information when errata description contain...
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Spacewalk
Classification: Community
Component: Server
Version: 1.8
Hardware: x86_64
OS: Linux
unspecified
low
Target Milestone: ---
Assignee: Milan Zázrivec
QA Contact: Red Hat Satellite QA List
URL:
Whiteboard:
Depends On:
Blocks: space22
TreeView+ depends on / blocked
 
Reported: 2013-01-09 08:54 UTC by Tore Loenoey
Modified: 2014-07-17 08:41 UTC (History)
2 users (show)

Fixed In Version: spacecmd-2.2.2-1
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2014-07-17 08:41:08 UTC
Embargoed:


Attachments (Terms of Use)

Description Tore Loenoey 2013-01-09 08:54:13 UTC
Description of problem:
Spacecmd have troubles outputting text that is uses certain characters, example \u201c and \u2019

Version-Release number of selected component (if applicable):
spacecmd-1.8.14-1.el.noarch

How reproducible:
* Always?

Steps to Reproduce:
1. Import EPEL channel to Satellite
2. Use spacecmd to get errata details (e.g. errata FEDORA-EPEL-2012-13557 contains mentioned characters. If output is piped to something it will complain: "ERROR: 'ascii codec can't encode character u'\u201c' in position 275: ordinal not in range(128)"
3. You want to find packages affected by an errata:
# spacecmd -q -- errata_details FEDORA-EPEL-2012-13557 | grep "Affected Packages" -A 1000 | grep -e "Affected Packages"  -e "\-\-\-\-\-\-\-" -v  | sort | uniq
ERROR: 'ascii' codec can't encode character u'\u201c' in position 275: ordinal not in range(128)
4. The problem lies in the characters used in the errata's description field.
  
Actual results:
# spacecmd -q -- errata_details FEDORA-EPEL-2012-13557 | grep "Affected Packages" -A 1000 | grep -e "Affected Packages"  -e "\-\-\-\-\-\-\-" -v  | sort | uniq
ERROR: 'ascii' codec can't encode character u'\u201c' in position 275: ordinal not in range(128)

Expected results:
# spacecmd -q -- errata_details FEDORA-EPEL-2012-13557 | grep "Affected Packages" -A 1000 | grep -e "Affected Packages"  -e "\-\-\-\-\-\-\-" -v  | sort | uniq
pytest-2.3.4-1.el6.noarch
python-py-1.4.12-1.el6.noarch
 

Additional info:
This can be fixed by setting the encoding in the following file:
_/usr/lib/python2.6/site-packages/spacecmd/errata.py_
Add:
import sys
import codecs
import locale
sys.stdout = codecs.getwriter(locale.getpreferredencoding())(sys.stdout)

There is probably a more sane approach to fix this, hopefully someone can either consider this as a fix, or provide a better way of solving this.

Comment 1 Miroslav Suchý 2013-01-09 09:23:52 UTC
Forwarding to upstream.

Comment 2 Milan Zázrivec 2014-04-04 11:41:36 UTC
Fixed in spacewalk.git master: b1a88c309b7b20b715f82834078a8c84749ebfc3

Comment 3 Milan Zázrivec 2014-07-17 08:41:08 UTC
Spacewalk 2.2 has been released:

    https://fedorahosted.org/spacewalk/wiki/ReleaseNotes22


Note You need to log in before you can comment on or make changes to this bug.