Re: [Freeipa-devel] thin client regressions: otptoken

2016-06-08 Thread Jan Cholasta

On 8.6.2016 15:41, Alexander Bokovoy wrote:

On Wed, 08 Jun 2016, Jan Cholasta wrote:

On 7.6.2016 10:41, Alexander Bokovoy wrote:

On Tue, 07 Jun 2016, Jan Cholasta wrote:

On 7.6.2016 10:17, Alexander Bokovoy wrote:

ipa: ERROR: AttributeError: 'str' object has no attribute 'decode'
Traceback (most recent call last):
File "/usr/lib/python3.5/site-packages/ipalib/cli.py", line 1345,
in run
 sys.exit(api.Backend.cli.run(argv))
File "/usr/lib/python3.5/site-packages/ipalib/cli.py", line 1110,
in run
 rv = cmd.output_for_cli(self.api.Backend.textui, result, *args,
**options)
File "/usr/lib/python3.5/site-packages/ipaclient/plugins/otptoken.py",
line 103, in output_for_cli
 qr = self._get_qrcode(output, uri, options['version'])
File "/usr/lib/python3.5/site-packages/ipaclient/plugins/otptoken.py",
line 61, in _get_qrcode
 qr_code = qr_output.getvalue().decode(encoding)
AttributeError: 'str' object has no attribute 'decode' ipa: ERROR: an
internal error has occurred


Looks rather like a py3 regression to me.


Fix attached, made a ticket https://fedorahosted.org/freeipa/ticket/5938


The check is incorrect actually - a proper fix would be to use encode
instead of decode.

Updated patch attached. It indeed works.


Thanks, ACK.

Pushed to:
master: 29d669fec18c089619c199d66195ec3b73df7ee1
ipa-4-3: 94822209c4b6d4902188fc461578b819dfd2f7fc

--
Jan Cholasta

--
Manage your subscription for the Freeipa-devel mailing list:
https://www.redhat.com/mailman/listinfo/freeipa-devel
Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code


Re: [Freeipa-devel] thin client regressions: otptoken

2016-06-08 Thread Alexander Bokovoy

On Wed, 08 Jun 2016, Jan Cholasta wrote:

On 7.6.2016 10:41, Alexander Bokovoy wrote:

On Tue, 07 Jun 2016, Jan Cholasta wrote:

On 7.6.2016 10:17, Alexander Bokovoy wrote:

ipa: ERROR: AttributeError: 'str' object has no attribute 'decode'
Traceback (most recent call last):
File "/usr/lib/python3.5/site-packages/ipalib/cli.py", line 1345, in run
 sys.exit(api.Backend.cli.run(argv))
File "/usr/lib/python3.5/site-packages/ipalib/cli.py", line 1110, in run
 rv = cmd.output_for_cli(self.api.Backend.textui, result, *args,
**options)
File "/usr/lib/python3.5/site-packages/ipaclient/plugins/otptoken.py",
line 103, in output_for_cli
 qr = self._get_qrcode(output, uri, options['version'])
File "/usr/lib/python3.5/site-packages/ipaclient/plugins/otptoken.py",
line 61, in _get_qrcode
 qr_code = qr_output.getvalue().decode(encoding)
AttributeError: 'str' object has no attribute 'decode' ipa: ERROR: an
internal error has occurred


Looks rather like a py3 regression to me.


Fix attached, made a ticket https://fedorahosted.org/freeipa/ticket/5938


The check is incorrect actually - a proper fix would be to use encode 
instead of decode.

Updated patch attached. It indeed works.
--
/ Alexander Bokovoy
From be6167d050d30a9204a65c10519a23ff2a7f93f7 Mon Sep 17 00:00:00 2001
From: Alexander Bokovoy 
Date: Tue, 7 Jun 2016 11:37:41 +0300
Subject: [PATCH 5/7] otptoken: support Python 3 for the qr code

When IPA client is using Python 3, there is no str.decode() method
anymore.

ipa: ERROR: AttributeError: 'str' object has no attribute 'decode'
Traceback (most recent call last):
 File "/usr/lib/python3.5/site-packages/ipalib/cli.py", line 1345, in run
   sys.exit(api.Backend.cli.run(argv))
 File "/usr/lib/python3.5/site-packages/ipalib/cli.py", line 1110, in run
   rv = cmd.output_for_cli(self.api.Backend.textui, result, *args, **options)
 File "/usr/lib/python3.5/site-packages/ipaclient/plugins/otptoken.py", line 
103, in output_for_cli
   qr = self._get_qrcode(output, uri, options['version'])
 File "/usr/lib/python3.5/site-packages/ipaclient/plugins/otptoken.py", line 
61, in _get_qrcode
   qr_code = qr_output.getvalue().decode(encoding)
AttributeError: 'str' object has no attribute 'decode' ipa: ERROR: an internal 
error has occurred

Fixes https://fedorahosted.org/freeipa/ticket/5938
---
 ipaclient/plugins/otptoken.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ipaclient/plugins/otptoken.py b/ipaclient/plugins/otptoken.py
index 5d3f1f8..d7d5356 100644
--- a/ipaclient/plugins/otptoken.py
+++ b/ipaclient/plugins/otptoken.py
@@ -58,7 +58,7 @@ class otptoken_add(MethodOverride):
 encoding = locale.getpreferredencoding(False)
 
 try:
-qr_code = qr_output.getvalue().decode(encoding)
+qr_code = qr_output.getvalue().encode(encoding)
 except UnicodeError:
 add_message(
 version,
-- 
2.7.4

-- 
Manage your subscription for the Freeipa-devel mailing list:
https://www.redhat.com/mailman/listinfo/freeipa-devel
Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code

Re: [Freeipa-devel] thin client regressions: otptoken

2016-06-08 Thread Jan Cholasta

On 7.6.2016 10:41, Alexander Bokovoy wrote:

On Tue, 07 Jun 2016, Jan Cholasta wrote:

On 7.6.2016 10:17, Alexander Bokovoy wrote:

ipa: ERROR: AttributeError: 'str' object has no attribute 'decode'
Traceback (most recent call last):
File "/usr/lib/python3.5/site-packages/ipalib/cli.py", line 1345, in run
  sys.exit(api.Backend.cli.run(argv))
File "/usr/lib/python3.5/site-packages/ipalib/cli.py", line 1110, in run
  rv = cmd.output_for_cli(self.api.Backend.textui, result, *args,
**options)
File "/usr/lib/python3.5/site-packages/ipaclient/plugins/otptoken.py",
line 103, in output_for_cli
  qr = self._get_qrcode(output, uri, options['version'])
File "/usr/lib/python3.5/site-packages/ipaclient/plugins/otptoken.py",
line 61, in _get_qrcode
  qr_code = qr_output.getvalue().decode(encoding)
AttributeError: 'str' object has no attribute 'decode' ipa: ERROR: an
internal error has occurred


Looks rather like a py3 regression to me.


Fix attached, made a ticket https://fedorahosted.org/freeipa/ticket/5938


The check is incorrect actually - a proper fix would be to use encode 
instead of decode.


--
Jan Cholasta

--
Manage your subscription for the Freeipa-devel mailing list:
https://www.redhat.com/mailman/listinfo/freeipa-devel
Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code


Re: [Freeipa-devel] thin client regressions: otptoken

2016-06-07 Thread Alexander Bokovoy

On Tue, 07 Jun 2016, Jan Cholasta wrote:

On 7.6.2016 10:17, Alexander Bokovoy wrote:

ipa: ERROR: AttributeError: 'str' object has no attribute 'decode'
Traceback (most recent call last):
File "/usr/lib/python3.5/site-packages/ipalib/cli.py", line 1345, in run
  sys.exit(api.Backend.cli.run(argv))
File "/usr/lib/python3.5/site-packages/ipalib/cli.py", line 1110, in run
  rv = cmd.output_for_cli(self.api.Backend.textui, result, *args,
**options)
File "/usr/lib/python3.5/site-packages/ipaclient/plugins/otptoken.py",
line 103, in output_for_cli
  qr = self._get_qrcode(output, uri, options['version'])
File "/usr/lib/python3.5/site-packages/ipaclient/plugins/otptoken.py",
line 61, in _get_qrcode
  qr_code = qr_output.getvalue().decode(encoding)
AttributeError: 'str' object has no attribute 'decode' ipa: ERROR: an
internal error has occurred


Looks rather like a py3 regression to me.


Fix attached, made a ticket https://fedorahosted.org/freeipa/ticket/5938
--
/ Alexander Bokovoy
From 398d3c0decb6b39207a2f9dcd8d27291800de1dd Mon Sep 17 00:00:00 2001
From: Alexander Bokovoy 
Date: Tue, 7 Jun 2016 11:37:41 +0300
Subject: [PATCH 5/5] otptoken: only decode the token output for Python 2

When IPA client is using Python 3, there is no str.decode() method
anymore.

ipa: ERROR: AttributeError: 'str' object has no attribute 'decode'
Traceback (most recent call last):
 File "/usr/lib/python3.5/site-packages/ipalib/cli.py", line 1345, in run
   sys.exit(api.Backend.cli.run(argv))
 File "/usr/lib/python3.5/site-packages/ipalib/cli.py", line 1110, in run
   rv = cmd.output_for_cli(self.api.Backend.textui, result, *args, **options)
 File "/usr/lib/python3.5/site-packages/ipaclient/plugins/otptoken.py", line 
103, in output_for_cli
   qr = self._get_qrcode(output, uri, options['version'])
 File "/usr/lib/python3.5/site-packages/ipaclient/plugins/otptoken.py", line 
61, in _get_qrcode
   qr_code = qr_output.getvalue().decode(encoding)
AttributeError: 'str' object has no attribute 'decode' ipa: ERROR: an internal 
error has occurred

Fixes https://fedorahosted.org/freeipa/ticket/5938
---
 ipaclient/plugins/otptoken.py | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/ipaclient/plugins/otptoken.py b/ipaclient/plugins/otptoken.py
index 5d3f1f8..968b01e 100644
--- a/ipaclient/plugins/otptoken.py
+++ b/ipaclient/plugins/otptoken.py
@@ -58,7 +58,9 @@ class otptoken_add(MethodOverride):
 encoding = locale.getpreferredencoding(False)
 
 try:
-qr_code = qr_output.getvalue().decode(encoding)
+qr_code = qr_output.getvalue()
+if not six.PY3:
+qr_code = qr_code.decode(encoding)
 except UnicodeError:
 add_message(
 version,
-- 
2.7.4

-- 
Manage your subscription for the Freeipa-devel mailing list:
https://www.redhat.com/mailman/listinfo/freeipa-devel
Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code

Re: [Freeipa-devel] thin client regressions: otptoken

2016-06-07 Thread Jan Cholasta

On 7.6.2016 10:17, Alexander Bokovoy wrote:

ipa: ERROR: AttributeError: 'str' object has no attribute 'decode'
Traceback (most recent call last):
 File "/usr/lib/python3.5/site-packages/ipalib/cli.py", line 1345, in run
   sys.exit(api.Backend.cli.run(argv))
 File "/usr/lib/python3.5/site-packages/ipalib/cli.py", line 1110, in run
   rv = cmd.output_for_cli(self.api.Backend.textui, result, *args,
**options)
 File "/usr/lib/python3.5/site-packages/ipaclient/plugins/otptoken.py",
line 103, in output_for_cli
   qr = self._get_qrcode(output, uri, options['version'])
 File "/usr/lib/python3.5/site-packages/ipaclient/plugins/otptoken.py",
line 61, in _get_qrcode
   qr_code = qr_output.getvalue().decode(encoding)
AttributeError: 'str' object has no attribute 'decode' ipa: ERROR: an
internal error has occurred


Looks rather like a py3 regression to me.

--
Jan Cholasta

--
Manage your subscription for the Freeipa-devel mailing list:
https://www.redhat.com/mailman/listinfo/freeipa-devel
Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code