Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.

Bug 893368

Summary: spacecmd fails when piping errata information when errata description contains special characters
Product: [Community] Spacewalk Reporter: Tore Loenoey <tore.lonoy>
Component: ServerAssignee: Milan Zázrivec <mzazrivec>
Status: CLOSED CURRENTRELEASE QA Contact: Red Hat Satellite QA List <satqe-list>
Severity: low Docs Contact:
Priority: unspecified    
Version: 1.8CC: msuchy, tore.lonoy
Target Milestone: ---   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: spacecmd-2.2.2-1 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-07-17 08:41:08 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1119298    

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