Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with printing unicode non-english characters #8425

Closed
alozovskoy opened this issue Aug 4, 2014 · 12 comments
Closed

Issue with printing unicode non-english characters #8425

alozovskoy opened this issue Aug 4, 2014 · 12 comments
Labels
bug This issue/PR relates to a bug. P1 Priority 1 - Immediate Attention Required; Release Immediately After Fixed

Comments

@alozovskoy
Copy link
Contributor

Issue Type:

Bug Report

Ansible Version:

$ ansible --version
1.7

Environment:

RHEL 5

Summary:

Ansible cant correctly print an non-english characters, returned UnicodeDecodeError.

Steps To Reproduce:

Use non-english characters to printing in, f.e., debug module. A similar problem was in issue #6842.

Expected Results:
$ ansible 127.0.0.1 -m debug -a "msg=АБВГД"
127.0.0.1 | success >> {
    "msg": "АБВГД"
}
Actual Results:
$ ansible 127.0.0.1 -m debug -a "msg=АБВГД"
127.0.0.1 | FAILED => Traceback (most recent call last):
  File "/home/ansible/ansible/lib/python2.6/site-packages/ansible-1.7-py2.6.egg/ansible/runner/__init__.py", line 558, in _executor
    exec_rc = self._executor_internal(host, new_stdin)
  File "/home/ansible/ansible/lib/python2.6/site-packages/ansible-1.7-py2.6.egg/ansible/runner/__init__.py", line 663, in _executor_internal
    return self._executor_internal_inner(host, self.module_name, self.module_args, inject, port, complex_args=complex_args)
  File "/home/ansible/ansible/lib/python2.6/site-packages/ansible-1.7-py2.6.egg/ansible/runner/__init__.py", line 881, in _executor_internal_inner
    result = handler.run(conn, tmp, module_name, module_args, inject, complex_args)
  File "/home/ansible/ansible/lib/python2.6/site-packages/ansible-1.7-py2.6.egg/ansible/runner/action_plugins/debug.py", line 41, in run
    kv = utils.parse_kv(module_args)
  File "/home/ansible/ansible/lib/python2.6/site-packages/ansible-1.7-py2.6.egg/ansible/utils/__init__.py", line 698, in parse_kv
    args = args.encode('utf-8')
UnicodeDecodeError: 'ascii' codec can't decode byte 0xd0 in position 4: ordinal not in range(128)
@mpdehaan
Copy link
Contributor

mpdehaan commented Aug 4, 2014

Thanks, we're on it!

@jimi-c
Copy link
Member

jimi-c commented Aug 4, 2014

You're using the devel branch, however what is your most recent commit? I believe we fixed this here: 63bcbd0

@mpdehaan
Copy link
Contributor

mpdehaan commented Aug 4, 2014

I can still reproduce this.

@jimi-c
Copy link
Member

jimi-c commented Aug 4, 2014

Yes I see where the issue is. I've got a patch for this, which I'm testing now.

@jimi-c jimi-c closed this as completed in 6d94ae6 Aug 4, 2014
@jimi-c
Copy link
Member

jimi-c commented Aug 4, 2014

I have pushed the above commit, which should resolve this issue. If you continue seeing any problems related to this issue, please let us know. Thanks!

@alozovskoy
Copy link
Contributor Author

@jimi-c
First, now i've got this error:

$ ansible local -m debug -a "msg=АБВГД"
localhost | FAILED => Traceback (most recent call last):
  File "/home/ansible/ansible/lib/python2.6/site-packages/ansible-1.7-py2.6.egg/ansible/runner/__init__.py", line 557, in _executor
    exec_rc = self._executor_internal(host, new_stdin)
  File "/home/ansible/ansible/lib/python2.6/site-packages/ansible-1.7-py2.6.egg/ansible/runner/__init__.py", line 662, in _executor_internal
    return self._executor_internal_inner(host, self.module_name, self.module_args, inject, port, complex_args=complex_args)
  File "/home/ansible/ansible/lib/python2.6/site-packages/ansible-1.7-py2.6.egg/ansible/runner/__init__.py", line 833, in _executor_internal_inner
    conn = self.connector.connect(actual_host, actual_port, actual_user, actual_pass, actual_transport, actual_private_key_file)
  File "/home/ansible/ansible/lib/python2.6/site-packages/ansible-1.7-py2.6.egg/ansible/runner/connection.py", line 31, in connect
    conn = utils.plugins.connection_loader.get(transport, self.runner, host, port, user=user, password=password, private_key_file=private_key_file)
  File "/home/ansible/ansible/lib/python2.6/site-packages/ansible-1.7-py2.6.egg/ansible/utils/plugins.py", line 180, in get
    self._module_cache[path] = imp.load_source('.'.join([self.package, name]), path)
  File "/home/ansible/ansible/lib/python2.6/site-packages/ansible-1.7-py2.6.egg/ansible/runner/connection_plugins/paramiko_ssh.py", line 42, in <module>
    from ansible.module_utils.basic import atomic_move
ImportError: cannot import name atomic_move

Second, a commit not solved this problem:

$ ansible local -m debug -a "msg=ABCDE" --connection=local
127.0.0.1 | success >> {
    "msg": "ABCDE"
}

localhost | success >> {
    "msg": "ABCDE"
}

$ ansible local -m debug -a "msg=АБВГД" --connection=local
127.0.0.1 | success >> {
    "msg": "\u0410\u0411\u0412\u0413\u0414"
}

localhost | success >> {
    "msg": "\u0410\u0411\u0412\u0413\u0414"
}

P.S. I used virtualenv if this important.

@alozovskoy
Copy link
Contributor Author

If replase in ansible/runner/connection_plugins/paramiko_ssh.py

from ansible.module_utils.basic import atomic_move

on this

import ansible.module_utils.basic

I don't get privous exeption, but now i get

Traceback (most recent call last):
  File "<...my ansible path...>ansible/runner/connection_plugins/paramiko_ssh.py", line 388, in close
    tmp_keyfile = tempfile.NamedTemporaryFile()
NameError: global name 'tempfile' is not defined

Also, in this case paramiko worked well in first look. Ssh connection type also worked well all time.

@alozovskoy alozovskoy changed the title Issue with printing unicode nonenglish characters Issue with printing unicode non-english characters Aug 4, 2014
@jimi-c
Copy link
Member

jimi-c commented Aug 4, 2014

@alozovskoy yes sorry about that, that was a bug from another issue we were working on. It should be resolved now.

@alozovskoy
Copy link
Contributor Author

Yes, first problem was resolved in #8433. A second problem still actual.

@alozovskoy
Copy link
Contributor Author

$ ansible 127.0.0.1 -m debug -a "msg=АБВГД"
127.0.0.1 | success >> {
    "msg": "\u0410\u0411\u0412\u0413\u0414"
}
$ ansible --version
ansible 1.7

$ git log --pretty=oneline -n1
4e6685d77297a85565650abd630e6cda536643bb Merge pull request #8442 from Jmainguy/rpm_key_8424

@mpdehaan
Copy link
Contributor

mpdehaan commented Aug 6, 2014

Thanks, reopening this one and looking at your ticket!

@mpdehaan mpdehaan added P1 and removed P2 labels Aug 21, 2014
@jimi-c
Copy link
Member

jimi-c commented Aug 21, 2014

Closing This Ticket

Hi!

We believe the above commit should resolve this problem for you. This will also be included in the next major release.

If you continue seeing any problems related to this issue, or if you have any further questions, please let us know by stopping by one of the two mailing lists, as appropriate:

Because this project is very active, we're unlikely to see comments made on closed tickets, but the mailing list is a great way to ask questions, or post if you don't think this particular issue is resolved.

Thank you!

@jimi-c jimi-c closed this as completed Aug 21, 2014
@ansibot ansibot added bug This issue/PR relates to a bug. and removed bug_report labels Mar 6, 2018
@ansible ansible locked and limited conversation to collaborators Apr 25, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug This issue/PR relates to a bug. P1 Priority 1 - Immediate Attention Required; Release Immediately After Fixed
Projects
None yet
Development

No branches or pull requests

4 participants