openlmi / openlmi-scripts

Client-side python modules and command line utilities
Other
13 stars 13 forks source link

unicode failures #25

Closed miminar closed 10 years ago

miminar commented 11 years ago

Scripts can not work with unicode arguments. I've tested only LogicalFile providers and scripts. Steps to reproduce:

  1. install openlmi-logicalfile and related scripts (openlmi-scripts-logicalfile)
  2. make some file or directory with non-ascii characters e.g.:

     /root/složka
  3. try to list /root:

     lmi --trace -h localhost lf list '/root'
  4. watch the output (below)
  5. try to show it:

     lmi --trace -h localhost lf show '/root/složka'
  6. watch the output (below)

    Output of list looks like this:

lmi --hosts-file hosts-file lf list '/root'
ERROR: invocation failed for host "http://kvm-fedora20:5988"
Traceback (most recent call last):
  File "/home/miminar/workspace/openlmi-scripts/lmi/scripts/common/command/session.py", line 105, in process_session
    self.process_host_result(connection.hostname, True, result)
  File "/home/miminar/workspace/openlmi-scripts/lmi/scripts/common/command/session.py", line 133, in process_host_result
    self.produce_output(result)
  File "/home/miminar/workspace/openlmi-scripts/lmi/scripts/common/command/endpoint.py", line 317, in produce_output
    self.formatter.produce_output(data)
  File "/home/miminar/workspace/openlmi-scripts/lmi/scripts/common/formatter/__init__.py", line 342, in produce_output
    super(TableFormatter, self).produce_output(rows)
  File "/home/miminar/workspace/openlmi-scripts/lmi/scripts/common/formatter/__init__.py", line 238, in produce_output
    for row in rows:
  File "/home/miminar/workspace/openlmi-scripts/commands/logicalfile/lmi/scripts/logicalfile/logicalfile.py", line 143, in lf_list
    ident = f.associators(AssocClass='LMI_FileIdentity')[0]
  File "/home/miminar/.local/lib/python2.7/site-packages/openlmi_tools-0.7-py2.7.egg/lmi/shell/LMIDecorators.py", line 210, in wrapper
    return fn(self_wr, *args, **kwargs)
  File "/home/miminar/.local/lib/python2.7/site-packages/openlmi_tools-0.7-py2.7.egg/lmi/shell/LMIDecorators.py", line 85, in wrapper
    return fn(self_wr, *args, **kwargs)
  File "/home/miminar/.local/lib/python2.7/site-packages/openlmi_tools-0.7-py2.7.egg/lmi/shell/LMIInstance.py", line 327, in associators
    associators_list = self._conn._client._get_associators(self._cim_instance, **kwargs)
  File "/home/miminar/.local/lib/python2.7/site-packages/openlmi_tools-0.7-py2.7.egg/lmi/shell/LMIBaseClient.py", line 538, in _get_associators
    return self._cliconn.Associators(instance.path, **params)
  File "/usr/lib/python2.7/site-packages/pywbem/cim_operations.py", line 695, in Associators
    **params)
  File "/usr/lib/python2.7/site-packages/pywbem/cim_operations.py", line 167, in imethodcall
    verify_callback = self.verify_callback)
  File "/usr/lib/python2.7/site-packages/pywbem/cim_http.py", line 212, in wbem_request
    h.send(data)
  File "/usr/lib/python2.7/site-packages/pywbem/cim_http.py", line 91, in send
    self.sock.sendall(str)
  File "/usr/lib64/python2.7/socket.py", line 224, in meth
    return getattr(self._sock,name)(*args)
UnicodeEncodeError: 'ascii' codec can't encode character u'\u017e' in position 582: ordinal not in range(128)
There was 1 error:
host http://kvm-fedora20:5988
    (UnicodeEncodeError) 'ascii' codec can't encode character u'\u017e' in position 582: ordinal not in range(128)

Output of show looks like this:

ERROR: invocation failed for host "http://kvm-fedora20:5988"
Traceback (most recent call last):
  File "/home/miminar/workspace/openlmi-scripts/lmi/scripts/common/command/session.py", line 105, in process_session
    self.process_host_result(connection.hostname, True, result)
  File "/home/miminar/workspace/openlmi-scripts/lmi/scripts/common/command/session.py", line 133, in process_host_result
    self.produce_output(result)
  File "/home/miminar/workspace/openlmi-scripts/lmi/scripts/common/command/endpoint.py", line 317, in produce_output
    self.formatter.produce_output(data)
  File "/home/miminar/workspace/openlmi-scripts/lmi/scripts/common/formatter/__init__.py", line 342, in produce_output
    super(TableFormatter, self).produce_output(rows)
  File "/home/miminar/workspace/openlmi-scripts/lmi/scripts/common/formatter/__init__.py", line 238, in produce_output
    for row in rows:
  File "/home/miminar/workspace/openlmi-scripts/commands/logicalfile/lmi/scripts/logicalfile/logicalfile.py", line 192, in lf_show
    raise LmiFailed("Could not get target: %s" % target)
LmiFailed: Could not get target: /root/složka
There was 1 error:
host http://kvm-fedora20:5988
    Could not get target: /root/složka
jsynacek commented 11 years ago

Happens with 'mount' as well.

$ lmi --trace -h localhost mount create /dev/mapper/vg1-lv2 /root/složka/ ERROR: failed to execute wrapped function Traceback (most recent call last): File "/home/jsynacek/openlmi-scripts-nfs/lmi/scripts/common/command/command.py", line 818, in take_action res = self.execute_on_connection(connection, _args, _kwargs) File "/home/jsynacek/openlmi-scripts-nfs/lmi/scripts/common/command/command.py", line 508, in execute_on_connection return self.execute(connection, _args, _kwargs) File "/home/jsynacek/openlmi-scripts-nfs/commands/storage/lmi/scripts/storage/mount_cmd.py", line 159, in execute return mount.mount_create(ns, device, mountpoint, fs_type, options, other_options) File "/home/jsynacek/openlmi-scripts-nfs/commands/storage/lmi/scripts/storage/mount.py", line 172, in mount_create FileSystemSpec=device) File "/home/jsynacek/openlmi-tools-nfs/cli/lmi/shell/LMIMethod.py", line 369, in call self._method.name, _method_args) File "/home/jsynacek/openlmi-tools-nfs/cli/lmi/shell/LMIBaseClient.py", line 416, in _call_method_raw (rval, rparams) = self._cliconn.InvokeMethod(method, instance.path, _params) File "/usr/lib/python2.7/site-packages/pywbem/cim_operations.py", line 800, in InvokeMethod result = self.methodcall(MethodName, obj, **params) File "/usr/lib/python2.7/site-packages/pywbem/cim_operations.py", line 301, in methodcall for x in params.items()] File "/usr/lib/python2.7/site-packages/pywbem/cim_operations.py", line 276, in paramvalue return cim_xml.VALUE(cim_types.atomic_to_cim_xml(obj)) File "/usr/lib/python2.7/site-packages/pywbem/cim_types.py", line 261, in atomic_to_cim_xml return unicode(obj) UnicodeDecodeError: 'ascii' codec can't decode byte 0xc5 in position 9: ordinal not in range(128) WARNING: invocation failed on host "https://localhost": 'ascii' codec can't decode byte 0xc5 in position 9: ordinal not in range(128)

There were 1 errors: Host Error
https://localhost 'ascii' codec can't decode byte 0xc5 in position 9: ordinal not in range(128)

miminar commented 10 years ago

This is already resolved with commit fdb75fe3a6cf82cca3a975b2bb5683169598e551 And it needs patched pywbem (with unicode support) - svn revision 629.