HewlettPackard / python-redfish-utility

Python-based utility for interacting with devices supporting a Redfish Service
Other
86 stars 41 forks source link

codec can't {decode,encode} #35

Closed JohnAZoidberg closed 3 years ago

JohnAZoidberg commented 3 years ago

Took the release binary 3.1.1-11 from the SDR

$ ilorest serverinfo –power --url https://15.111.111.111 -u username -p password               
Traceback (most recent call last):                                                                
  File "rdmc.py", line 800, in <module>                                                           
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 19: ordinal not in range(128)
Failed to execute script rdmc                                                                     
$ ilorest
iLOrest : RESTful Interface Tool version 3.1.1
Copyright (c) 2014-2020 Hewlett Packard Enterprise Development LP
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Both remote and local mode is accessible when RESTful Interface Tool is run as administrator. Only remote mode is available for non-admin user groups.
iLOrest > serverinfo –power --url https://15.111.111.111 -u username -p password                                    
Traceback (most recent call last):
  File "rdmc.py", line 810, in <module>
  File "rdmc.py", line 314, in run
  File "rdmc.py", line 380, in cmdloop
  File "shlex.py", line 275, in split
  File "shlex.py", line 25, in __init__
UnicodeEncodeError: 'ascii' codec can't encode character u'\u2013' in position 11: ordinal not in range(128)
Failed to execute script rdmc

Is it built with Python2 or Python3?

rajeevkallur commented 3 years ago

3.1.1 was python2. But the above error will be resolved in next versions of ilorest (3.2.1 which is python3). To be released sometime in April.

JohnAZoidberg commented 3 years ago

Great, thanks!

knumskull commented 3 years ago

@JohnAZoidberg I just recently recognized, by copying information from HP website, it contains wrong characters. Maybe it's worth to write the whole command manually on the shell.

JohnAZoidberg commented 3 years ago

What contains wrong characters? As you can see I did both, write the command in the ilorest shell and also completely in bash.

knumskull commented 3 years ago

If I copy your command from above and paste it into bash shell on my system, you will see same error as you got.

$ ilorest serverinfo –power --url https://15.111.111.111 -u username -p password
Traceback (most recent call last):
  File "rdmc.py", line 800, in <module>
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 19: ordinal not in range(128)
Failed to execute script rdmc

writing the same command manually, entering each character by each, it will work and trying to establish a connection.

$ ilorest serverinfo -power --url https://15.111.111.111 -u username -p password
iLOrest : RESTful Interface Tool version 3.1.1
Copyright (c) 2014-2020 Hewlett Packard Enterprise Development LP
----------------------------------------------------------------------------------------------
^CTraceback (most recent call last):
  File "rdmc.py", line 810, in <module>
  File "rdmc.py", line 302, in run
  File "rdmc.py", line 187, in _run_command
  File "extensions/iLO COMMANDS/ServerInfoCommand.py", line 67, in run
  File "extensions/iLO COMMANDS/ServerInfoCommand.py", line 424, in serverinfovalidation
  File "rdmc_base_classes.py", line 206, in login_select_validation
  File "extensions/COMMANDS/LoginCommand.py", line 100, in loginfunction
  File "build/bdist.linux-x86_64/egg/redfish/ris/rmc.py", line 201, in login
  File "build/bdist.linux-x86_64/egg/redfish/ris/gen_compat.py", line 94, in getgen
  File "build/bdist.linux-x86_64/egg/redfish/rest/v1.py", line 347, in _get_root
  File "build/bdist.linux-x86_64/egg/redfish/rest/v1.py", line 109, in get
  File "build/bdist.linux-x86_64/egg/redfish/rest/connections.py", line 225, in rest_request
  File "urllib3/request.py", line 66, in request
  File "urllib3/request.py", line 87, in request_encode_url
  File "urllib3/poolmanager.py", line 321, in urlopen
  File "urllib3/connectionpool.py", line 622, in urlopen
KeyboardInterrupt
Failed to execute script rdmc

Same applies when running the command in ilorest interactive shell. For me it works.

some details of my system

[cloud-user@rhel7 ~]$ rpm -q ilorest
ilorest-3.1.1-11.x86_64
[cloud-user@rhel7 ~]$ uname -a
Linux rhel7.crazy.lab 3.10.0-1127.8.2.el7.x86_64 #1 SMP Thu May 7 19:30:37 EDT 2020 x86_64 x86_64 x86_64 GNU/Linux
[cloud-user@rhel7 ~]$ cat /etc/redhat-release 
Red Hat Enterprise Linux Server release 7.8 (Maipo)
[cloud-user@rhel7 ~]$ python --version
Python 2.7.5
[cloud-user@rhel7 ~]$ python3 --version
-bash: python3: command not found
JohnAZoidberg commented 3 years ago

You're right! The issue is the - sign in front of power. It's 0xe2 0x80 0x93 instead of 0x2d: https://www.fileformat.info/info/unicode/char/2013/index.htm

I guess I must've copied it from somewhere.

JohnAZoidberg commented 3 years ago

It's present a couple times in this repo. Please replace it with the ascii character: https://sourcegraph.com/search?q=repo:%5Egithub%5C.com/HewlettPackard/python-redfish-utility%24+%E2%80%93&patternType=literal

rajeevkallur commented 3 years ago

Please use version 3.2.2 and let us know if there is any issue.

JohnAZoidberg commented 3 years ago

You're right. It does work now, thanks! But still let's remove those weird minus signs :)