Merge lp:~jml/pkgme-devportal/better-error-when-no-objects into lp:pkgme-devportal

Proposed by Jonathan Lange
Status: Merged
Approved by: James Westby
Approved revision: 18
Merged at revision: 17
Proposed branch: lp:~jml/pkgme-devportal/better-error-when-no-objects
Merge into: lp:pkgme-devportal
Diff against target: 78 lines (+19/-3)
3 files modified
devportalbinary/binary.py (+10/-3)
devportalbinary/tests/test_binary.py (+8/-0)
setup.py (+1/-0)
To merge this branch: bzr merge lp:~jml/pkgme-devportal/better-error-when-no-objects
Reviewer Review Type Date Requested Status
James Westby Approve
Review via email: mp+83148@code.launchpad.net

Description of the change

Hello,

This branch fixes bug 890520. It also correctly specifies all of the dependencies for pkgme-binary, since I had to develop this in a no-site-packages virtualenv in order to avoid bugs like bug 893970 and bug 893520.

There's not much to see here. I added a new exception type, made sure that it inherited from PkgmeError to avoid nasty stack traces and raise it when there are no binaries found.

Thanks,
jml

To post a comment you must log in.
Revision history for this message
James Westby (james-w) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'devportalbinary/binary.py'
2--- devportalbinary/binary.py 2011-11-16 15:59:44 +0000
3+++ devportalbinary/binary.py 2011-11-23 12:30:29 +0000
4@@ -38,11 +38,10 @@
5 ]
6
7
8-import bsddb
9-import gzip
10 import os
11 import subprocess
12
13+from pkgme.errors import PkgmeError
14 from pkgme.info_elements import (
15 ApplicationName,
16 Categories,
17@@ -77,6 +76,12 @@
18
19 # XXX: No idea about how icons will be there. Ignoring for now.
20
21+
22+class NoBinariesFound(PkgmeError):
23+ """Raised when we cannot find any binaries to examine for dependencies.
24+ """
25+
26+
27 def guess_executable(package_name, executables):
28 """
29 From a list of executables, guess which one is likely to be the main
30@@ -165,7 +170,9 @@
31
32 def needed_libraries_from_objdump(binary_paths):
33 binary_paths = list(binary_paths)
34- cmd = [OBJDUMP, '-f', '-p'] + list(binary_paths)
35+ if not binary_paths:
36+ raise NoBinariesFound()
37+ cmd = [OBJDUMP, '-f', '-p'] + binary_paths
38 output = run_subprocess(cmd)
39 libraries = {}
40 last_line_was_blank = True
41
42=== modified file 'devportalbinary/tests/test_binary.py'
43--- devportalbinary/tests/test_binary.py 2011-10-24 21:48:58 +0000
44+++ devportalbinary/tests/test_binary.py 2011-11-23 12:30:29 +0000
45@@ -24,6 +24,8 @@
46 iter_executables,
47 ldd,
48 METADATA_FILE,
49+ needed_libraries_from_objdump,
50+ NoBinariesFound,
51 )
52 from devportalbinary.testing import DatabaseFixture
53
54@@ -34,6 +36,12 @@
55 self.assertEqual('devportal-metadata.json', METADATA_FILE)
56
57
58+class TestObjDump(TestCase):
59+
60+ def test_no_binaries(self):
61+ self.assertRaises(NoBinariesFound, needed_libraries_from_objdump, [])
62+
63+
64 class InstallFileTests(TestCase):
65
66 def test_install_file(self):
67
68=== modified file 'setup.py'
69--- setup.py 2011-11-16 16:46:06 +0000
70+++ setup.py 2011-11-23 12:30:29 +0000
71@@ -27,6 +27,7 @@
72 test_suite='devportalbinary.tests',
73 install_requires = [
74 'bzr',
75+ 'launchpadlib',
76 'pkgme',
77 ],
78 entry_points = {

Subscribers

People subscribed via source and target branches