Revision 386538386430 () - Diff

Link to this snippet: https://friendpaste.com/4IpYnXoV83AAKd1KxT5TO3
Embed:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
--- easy_install.rb 2010-11-23 05:24:57.000000000 +0000
+++ easy_install.rb.orig 2010-11-23 04:53:48.000000000 +0000
@@ -34,18 +34,16 @@
begin
# first check to see if we can import it
- output = shell_out!("python -c \"import #{name}\"", :returns=>[0,1]).stderr
- if output.include? "ImportError"
- # then check to see if its on the path
- output = shell_out!("python -c \"import sys; print sys.path\"", :returns=>[0,1]).stdout
- if output.downcase.include? "#{name.downcase}"
- check = true
- end
- else
+ output = shell_out!("python -c \"import #{name}\"").stderr
+ unless output.include? "ImportError"
check = true
end
rescue
- # it's probably not installed
+ # then check to see if its on the path
+ output = shell_out!("python -c \"import sys; print sys.path\"").stdout
+ if output.downcase.include? "#{name.downcase}"
+ check = true
+ end
end
check
@@ -68,18 +66,8 @@
output = shell_out!("python -c \"import #{@new_resource.package_name}; print #{@new_resource.package_name}.__version__\"").stdout
package_version = output.strip
rescue
- output = shell_out!("python -c \"import sys; print sys.path\"", :returns=>[0,1]).stdout
-
- output_array = output.gsub(/[\[\]]/,'').split(/\s*,\s*/)
- package_path = ""
-
- output_array.each do |entry|
- if entry.downcase.include?(@new_resource.package_name)
- package_path = entry
- end
- end
-
- package_path[/\S\S(.*)\/(.*)-(.*)-py(.*).egg\S/]
+ output = shell_out!("python -c \"import #{@new_resource.package_name}; print #{@new_resource.package_name}.__path__\"").stdout
+ output[/\S\S(.*)\/(.*)-(.*)-py(.*).egg\S/]
package_version = $3
end
end
@@ -123,4 +111,4 @@
end
end
end
-end
+end