poise / python

THIS COOKBOOK IS DEPRECATED – Chef cookbook to install Python and related tools

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

incorrect error handling for 'pip list'

uwebartels opened this issue · comments

commented

Hiho,

on redhat 6 I have a python 2.6 installed via rpm including the corresponding pip package python-pip.
I want to install the python package setuptools (3.4.0) and have currently installed setuptools (0.6c11)

root@chef-test1:~# pip show setuptools

Name: setuptools
Version: 0.6c11
Location: /usr/lib/python2.6/site-packages
Requires:
root@chef-test1:~#

the lwrp python_pip seems to successfully install setuptools (3.4.0), but it doesn't.
the method current_installed_version() stumbles over the output which ends with test below and does not realize the pip internal error.
I also worked with shellout and you could improve the code by using this code piece:
cmdStr = "test -f #{new_resource.file}"
Chef::Log.debug "calling: #{cmdStr}"
shell = Mixlib::ShellOut.new(cmdStr)
shell.run_command
shell.error! # raise an exception on error
Chef::Log.debug "stdout: #{shell.stdout.gsub(/\n$/,'')}"
Chef::Log.debug "stderr: #{shell.stderr.gsub(/\n$/,'')}"

output extract from 'pip list':
argparse (1.2.1)
...
setools (1.0)
Exception:
Traceback (most recent call last):
File "/usr/lib/python2.6/site-packages/pip/basecommand.py", line 134, in main
status = self.run(options, args)
File "/usr/lib/python2.6/site-packages/pip/commands/list.py", line 80, in run
self.run_listing(options)
File "/usr/lib/python2.6/site-packages/pip/commands/list.py", line 127, in run_listing
self.output_package_listing(installed_packages)
File "/usr/lib/python2.6/site-packages/pip/commands/list.py", line 136, in output_package_listing
if dist_is_editable(dist):
File "/usr/lib/python2.6/site-packages/pip/util.py", line 347, in dist_is_editable
req = FrozenRequirement.from_dist(dist, [])
File "/usr/lib/python2.6/site-packages/pip/init.py", line 194, in from_dist
assert len(specs) == 1 and specs[0][0] == '=='
AssertionError

Storing complete log in /root/.pip/pip.log

Let me know if you need more information.

Best Regards,
Uwe

https://github.com/poise/poise-python has entirely new code for parsing pip output and I don't think this applies any longer.