Merge lp:~jml/pkgme-devportal/remove-shim into lp:pkgme-devportal

Proposed by Jonathan Lange
Status: Merged
Approved by: James Westby
Approved revision: 183
Merged at revision: 148
Proposed branch: lp:~jml/pkgme-devportal/remove-shim
Merge into: lp:pkgme-devportal
Diff against target: 213 lines (+8/-78)
7 files modified
devportalbinary/binary.py (+4/-6)
devportalbinary/database.py (+1/-27)
devportalbinary/testing.py (+0/-8)
devportalbinary/tests/__init__.py (+2/-6)
devportalbinary/tests/test_database.py (+0/-26)
setup.py (+1/-3)
versions.cfg (+0/-2)
To merge this branch: bzr merge lp:~jml/pkgme-devportal/remove-shim
Reviewer Review Type Date Requested Status
James Westby Approve
Review via email: mp+134138@code.launchpad.net

Commit message

Remove the shim

Description of the change

We used to have four database backends for pkgme-devportal. Now we have
only one, libdep-service. So, rather than use an interface for talking to
it, we can just use the client directly.

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 2012-10-26 14:38:49 +0000
3+++ devportalbinary/binary.py 2012-11-13 15:49:25 +0000
4@@ -34,13 +34,11 @@
5 ]
6
7
8-from contextlib import closing
9 import os
10 import subprocess
11
12 from pkgme.errors import PkgmeError
13 from pkgme.run_script import run_subprocess
14-from pkgme import trace
15
16 from devportalbinary.configuration import load_configuration
17 from devportalbinary.database import get_dependency_database
18@@ -208,7 +206,7 @@
19
20 OBJDUMP = '/usr/bin/objdump'
21 # Map the objdump "architecture" value to the dpkg architecture,
22-# objdump report i386 as "i386" but amd64 as "i386:x86-64"
23+# objdump report i386 as "i386" but amd64 as "i386:x86-64"
24 OBJDUMP_MAPPING = {
25 "i386:x86-64" : "amd64",
26 }
27@@ -297,13 +295,13 @@
28 # XXX: we don't consider arch in overrides, do we need to?
29 # -- james_w
30 deps = set(lib_overrides[lib] for lib in needs_overrides)
31- with closing(get_dependency_database()) as db:
32- found = db.get_multiple_dependencies(library_names, arch)
33+ db = get_dependency_database()
34+ found = db.get_binaries_for_libraries(library_names, [arch])[arch]
35 missing = library_names - set(found.keys())
36 if missing:
37 raise UnknownDependency(missing)
38 for lib_deps in found.values():
39- deps |= lib_deps
40+ deps |= set(lib_deps)
41 return deps
42
43
44
45=== modified file 'devportalbinary/database.py'
46--- devportalbinary/database.py 2012-11-13 14:43:21 +0000
47+++ devportalbinary/database.py 2012-11-13 15:49:25 +0000
48@@ -10,33 +10,7 @@
49 download_file
50
51
52-class LibdepServiceClient(object):
53- """Implements the read part of PackageDatabase's interface."""
54-
55- DB_TYPE = 'libdep-service'
56-
57- def __init__(self, client):
58- self._client = client
59-
60- @classmethod
61- def from_options(cls, options):
62- return cls(Client(options.database_base_url))
63-
64- def get_multiple_dependencies(self, library_names, arch):
65- """Get the binary packages that provide libraries.
66-
67- :return: (deps, missing), where ``deps`` is a dict mapping library
68- names to sets of packages that provide them, and ``missing`` is a
69- set of library names for which no dependencies could be found.
70- """
71- deps = self._client.get_binaries_for_libraries(library_names, [arch])
72- return dict((lib, set(dep)) for (lib, dep) in deps[arch].items())
73-
74- def close(self):
75- pass
76-
77-
78 def get_dependency_database():
79 """Return an object that can get dependencies."""
80 options = load_configuration()
81- return LibdepServiceClient.from_options(options)
82+ return Client(options.database_base_url)
83
84=== modified file 'devportalbinary/testing.py'
85--- devportalbinary/testing.py 2012-11-13 14:08:14 +0000
86+++ devportalbinary/testing.py 2012-11-13 15:49:25 +0000
87@@ -27,12 +27,10 @@
88 )
89
90 from devportalbinary.binary import MetadataBackend
91-from devportalbinary.database import LibdepServiceClient
92
93 from devportalbinary.configuration import CONF_FILE_ENV_VAR
94
95 from djlibdep.test_double import LibdepServiceDouble
96-from libdep_service_client.client import Client
97
98
99 class IsChildPath(Matcher):
100@@ -120,7 +118,6 @@
101 ('database', {'db_type': 'libdep-service',
102 'base_url': double.base_url,
103 })))
104- self.client = LibdepServiceClient(Client(double.base_url))
105
106
107 def LibsConfigSettings(test_libs):
108@@ -243,8 +240,3 @@
109 for section, values in settings:
110 f.write(make_config_section(section, values))
111 f.write('\n')
112-
113-
114-def get_libdep_service_client(fixture, test_data):
115- double = fixture.useFixture(LibdepServiceDouble(test_data))
116- return LibdepServiceClient(Client(double.base_url))
117
118=== modified file 'devportalbinary/tests/__init__.py'
119--- devportalbinary/tests/__init__.py 2012-09-12 15:04:26 +0000
120+++ devportalbinary/tests/__init__.py 2012-11-13 15:49:25 +0000
121@@ -3,8 +3,6 @@
122
123 from unittest import TestLoader
124
125-from testresources import OptimisingTestSuite
126-
127
128 def test_suite():
129 """Insert an OptimizingTestSuite for testresources."""
130@@ -12,7 +10,6 @@
131 'devportalbinary.tests.test_backend',
132 'devportalbinary.tests.test_binary',
133 'devportalbinary.tests.test_configuration',
134- 'devportalbinary.tests.test_database',
135 'devportalbinary.tests.test_metadata',
136 'devportalbinary.tests.test_pdf',
137 'devportalbinary.tests.test_stubs',
138@@ -20,6 +17,5 @@
139 'devportalbinary.tests.test_utils',
140 ]
141 loader = TestLoader()
142- tests = OptimisingTestSuite()
143- tests.addTests(loader.loadTestsFromNames(module_names))
144- return tests
145+ return loader.loadTestsFromNames(module_names)
146+
147
148=== removed file 'devportalbinary/tests/test_database.py'
149--- devportalbinary/tests/test_database.py 2012-11-13 13:55:53 +0000
150+++ devportalbinary/tests/test_database.py 1970-01-01 00:00:00 +0000
151@@ -1,26 +0,0 @@
152-
153-from testtools import TestCase
154-
155-from devportalbinary.database import LibdepServiceClient
156-from devportalbinary.testing import get_libdep_service_client
157-
158-from libdep_service_client.client import Client
159-
160-
161-class TestLibdepServiceClient(TestCase):
162-
163- TEST_DATA = [('libfoo', {'i386': {'libfoo': 'libfoo-bin'}})]
164-
165- def test_wraps_libdep_service(self):
166- wrapper = get_libdep_service_client(self, self.TEST_DATA)
167- self.assertEqual(
168- {'libfoo': set(['libfoo-bin'])},
169- wrapper.get_multiple_dependencies(['libfoo'], 'i386'))
170- self.assertEqual(
171- {}, wrapper.get_multiple_dependencies(['libbar'], 'i386'))
172-
173- def test_has_close_method(self):
174- client = Client('http://localhost/')
175- wrapper = LibdepServiceClient(client)
176- # Check that there is no exception
177- wrapper.close()
178
179=== modified file 'setup.py'
180--- setup.py 2012-11-13 14:00:37 +0000
181+++ setup.py 2012-11-13 15:49:25 +0000
182@@ -42,7 +42,7 @@
183 'PIL',
184 'pkgme>=0.4.1',
185 'fixtures',
186- 'storm',
187+ 'storm', # Not actually used, but libdep-service does it wrong
188 ],
189 entry_points = {
190 'console_scripts': [
191@@ -53,8 +53,6 @@
192 },
193 extras_require = {
194 'testing': [
195- 'postgresfixture',
196- 'testresources',
197 'testtools',
198 'treeshape',
199 ],
200
201=== modified file 'versions.cfg'
202--- versions.cfg 2012-11-13 14:21:41 +0000
203+++ versions.cfg 2012-11-13 15:49:25 +0000
204@@ -50,9 +50,7 @@
205 paste = 1.7.5.1
206 pathod = 0.2.1
207 PIL = 1.1.7
208-postgresfixture = 0.1.2
209 pkgme = 0.4.1
210-psycopg2 = 2.4.5
211 pyasn1 = 0.1.4
212 pyopenssl = 0.13
213 python-dateutil = 1.5

Subscribers

People subscribed via source and target branches