Bug 1052840

Summary: The rct tool "cat-cert" module got a traceback when system environment language is not English.
Product: Red Hat Enterprise Linux 7 Reporter: xingge <gxing>
Component: subscription-managerAssignee: candlepin-bugs
Status: CLOSED DUPLICATE QA Contact: John Sefler <jsefler>
Severity: high Docs Contact:
Priority: high    
Version: 7.0CC: alikins, ckozak, ldai
Target Milestone: rcKeywords: Reopened
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-01-15 13:35:24 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: 863175    

Description xingge 2014-01-14 07:50:34 UTC
Description of problem:
The rct tool "cat-cert" module got a traceback when system environment language is not English

Version-Release number of selected component (if applicable):
subscription-manager-firstboot-1.10.10-1.el7.x86_64
subscription-manager-1.10.10-1.el7.x86_64
subscription-manager-gui-1.10.10-1.el7.x86_64
python-rhsm-1.10.10-1.el7.x86_64

How reproducible:
always

Steps to Reproduce:
1.Register the system and attach some subscriptions.
2.Run rct tool with cmd:
LANG=zh rct cat-cert /etc/pki/entitlement/***.pem

Actual results:
[root@dhcp-13-59 ~]# LANG=zh rct cat-cert /etc/pki/entitlement/8337640300296218469.pem 
Traceback (most recent call last):
  File "/usr/bin/rct", line 47, in <module>
    sys.exit(abs(main() or 0))
  File "/usr/bin/rct", line 42, in main
    return RctCLI().main()
  File "/usr/share/rhsm/subscription_manager/cli.py", line 166, in main
    return cmd.main()
  File "/usr/share/rhsm/rct/commands.py", line 39, in main
    return_code = self._do_command()
  File "/usr/share/rhsm/rct/cert_commands.py", line 76, in _do_command
    skip_products=self.options.no_products)
  File "/usr/share/rhsm/rct/printing.py", line 228, in printc
    printer.printc(cert)
  File "/usr/share/rhsm/rct/printing.py", line 124, in printc
    print self.cert_to_str(cert)
  File "/usr/share/rhsm/rct/printing.py", line 191, in cert_to_str
    return "%s\n%s%s" % (ProductCertificatePrinter.cert_to_str(self, cert),
  File "/usr/share/rhsm/rct/printing.py", line 172, in cert_to_str
    return "%s\n%s" % (CertificatePrinter.cert_to_str(self, cert), "\n".join(s))
  File "/usr/share/rhsm/rct/printing.py", line 118, in cert_to_str
    self._append_to_cert_section(cert, s)
  File "/usr/share/rhsm/rct/printing.py", line 198, in _append_to_cert_section
    str_parts_list.append("\t%s: %s" % (_("Pool ID"), pool_id))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe6 in position 1: ordinal not in range(128)

Expected results:
The info of the entitlement cert should be shown.

Additional info:
1.Not only zh but also all other language will meet this traceback.
2.If I use a system that default lang is zh, the error message appears too.
3.The module state-cert works fine like below:
[root@dhcp-13-59 ~]# rct stat-cert /etc/pki/entitlement/8337640300296218469.pem 
Type: Entitlement Certificate
Version: 3.2
DER size: 1462b
Subject Key ID size: 20b
Content sets: 0
[root@dhcp-13-59 ~]# LANG=zh rct stat-cert /etc/pki/entitlement/8337640300296218469.pem 
类型:授权证书
版本:3.2
DER 大小:1462b
主题键 ID 大小:20b
内容:0

Comment 2 Adrian Likins 2014-01-14 17:23:11 UTC
LANG=zh is not a valid locale.

Try:

    LANG=zh_CN.utf8

Comment 3 xingge 2014-01-15 02:53:57 UTC
The results that I tried LANG=zh_CN.utf8. I just use LANG=*** to show the bug easily. I fact when I use rct cat-cert in a system which use zh_CN as default language the traceback shows too.

[root@dhcp-13-59 ~]# LANG=zh_CN.utf8 rct cat-cert /etc/pki/entitlement/8337640300296218469.pem 
Traceback (most recent call last):
  File "/usr/bin/rct", line 47, in <module>
    sys.exit(abs(main() or 0))
  File "/usr/bin/rct", line 42, in main
    return RctCLI().main()
  File "/usr/share/rhsm/subscription_manager/cli.py", line 166, in main
    return cmd.main()
  File "/usr/share/rhsm/rct/commands.py", line 39, in main
    return_code = self._do_command()
  File "/usr/share/rhsm/rct/cert_commands.py", line 76, in _do_command
    skip_products=self.options.no_products)
  File "/usr/share/rhsm/rct/printing.py", line 228, in printc
    printer.printc(cert)
  File "/usr/share/rhsm/rct/printing.py", line 124, in printc
    print self.cert_to_str(cert)
  File "/usr/share/rhsm/rct/printing.py", line 191, in cert_to_str
    return "%s\n%s%s" % (ProductCertificatePrinter.cert_to_str(self, cert),
  File "/usr/share/rhsm/rct/printing.py", line 172, in cert_to_str
    return "%s\n%s" % (CertificatePrinter.cert_to_str(self, cert), "\n".join(s))
  File "/usr/share/rhsm/rct/printing.py", line 118, in cert_to_str
    self._append_to_cert_section(cert, s)
  File "/usr/share/rhsm/rct/printing.py", line 198, in _append_to_cert_section
    str_parts_list.append("\t%s: %s" % (_("Pool ID"), pool_id))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe6 in position 1: ordinal not in range(128)

Comment 4 John Sefler 2014-01-15 13:24:48 UTC
I believe this is a dup of bug 1048325

Comment 5 Carter Kozak 2014-01-15 13:35:24 UTC
You are correct.  The fix is in master, I'll probably do a build in the next day or so.

*** This bug has been marked as a duplicate of bug 1048325 ***