iot-lab/cli-tools

experiment-cli -a raises a TypeError

Closed this issue · 3 comments

$ experiment-cli get -a -i 7959
Traceback (most recent call last):
  File "/home/harter/work/iot-lab/parts/cli-tools/experiment-cli", line 4, in <module>
    experiment_parser.main()
  File "/home/harter/work/iot-lab/parts/cli-tools/iotlabcli/experiment_parser.py", line 405, in main
    get_experiment(parser_options, request, parser)
  File "/home/harter/work/iot-lab/parts/cli-tools/iotlabcli/experiment_parser.py", line 311, in get_experiment
    data = request.get_experiment_archive(experiment_id)
  File "/home/harter/work/iot-lab/parts/cli-tools/iotlabcli/rest.py", line 190, in get_experiment_archive
    return self.method('experiments/%s?data' % expid)
  File "/home/harter/work/iot-lab/parts/cli-tools/iotlabcli/rest.py", line 57, in method
    return req.text
  File "/usr/local/lib/python2.7/dist-packages/requests/models.py", line 824, in text
    content = str(self.content, encoding, errors='replace')
TypeError: unicode() argument 2 must be string, not None

Should investigate on versions and all.

Fails with production 1.3.1, with different stacktrace though.

fambon@carolus:~$ experiment-cli -v
1.3.1
fambon@carolus:~$ which experiment-cli 
/usr/local/bin/experiment-cli

fambon@carolus:~$ experiment-cli get -a -i 9735
Traceback (most recent call last):
  File "/usr/local/bin/experiment-cli", line 5, in <module>
    pkg_resources.run_script('iotlabcli==1.3.1', 'experiment-cli')
  File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 528, in run_script
    self.require(requires)[0].run_script(script_name, ns)
  File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 1401, in run_script
    exec(script_code, namespace, namespace)
  File "/usr/local/lib/python2.7/dist-packages/iotlabcli-1.3.1-py2.7.egg/EGG-INFO/scripts/experiment-cli", line 4, in <module>
    import pkg_resources
  File "build/bdist.linux-x86_64/egg/iotlabcli/experiment_parser.py", line 397, in main
  File "build/bdist.linux-x86_64/egg/iotlabcli/experiment_parser.py", line 306, in get_experiment
  File "build/bdist.linux-x86_64/egg/iotlabcli/helpers.py", line 101, in write_experiment_archive
UnicodeEncodeError: 'ascii' codec can't encode character u'\ufffd' in position 1: ordinal not in range(128)

fambon@carolus:~$ 

I think the result depends of the archive content.
Using 'req.content' instead of 'req.text' in 'rest.py' looks to solve the issue and still work for others requests. Will test it a bit more.

Tested on some other commands, was working for me, let us know if any other commands stopped working.