4675.1.1
by Abel Deuring
initial data structures for HWDB submissions |
1 |
= Hardware database = |
2 |
||
3 |
== Storage of raw submissions for the hardware database == |
|
4 |
||
5 |
The hardware database clients submits an XML file with collected hardware |
|
6 |
information and other data. This file is stored without any parsing in a |
|
4675.1.3
by Abel Deuring
schema modifications by stub |
7 |
librarian file. A reference to this file is stored in the table HWSubmission, |
4675.1.1
by Abel Deuring
initial data structures for HWDB submissions |
8 |
together with the following data: |
9 |
||
7525.3.2
by Abel Deuring
implemented reviewer's comments |
10 |
|
10234.3.3
by Curtis Hovey
Migrated hardward database to lp. Updated test_doc to run the hwddb test. |
11 |
>>> from lp.hardwaredb.interfaces.hwdb import IHWSubmissionSet |
7525.3.2
by Abel Deuring
implemented reviewer's comments |
12 |
>>> sample_submission = getUtility(IHWSubmissionSet).getBySubmissionKey( |
13 |
... 'sample-submission') |
|
14 |
||
15 |
* reference to the librarian file. |
|
16 |
||
17 |
>>> print sample_submission.raw_submission |
|
18 |
<...LibraryFileAlias instance at ...> |
|
19 |
||
4675.1.1
by Abel Deuring
initial data structures for HWDB submissions |
20 |
* date_created: Date and time of the submission (generated by the client). |
4675.1.5
by Abel Deuring
improved HWDB docs; a new exception for HWDB submissions |
21 |
|
7310.2.1
by Abel Deuring
Added sample data for HWDB devices |
22 |
This value is not very reliable: |
6493.3.1
by Guilherme Salgado
Rename IPerson.timezone to IPerson.time_zone |
23 |
* Some users do not care to set the correct time, date and time zone. |
4675.1.5
by Abel Deuring
improved HWDB docs; a new exception for HWDB submissions |
24 |
* Some machines have a broken CMOS battery and the user does not set |
25 |
date and time after every boot. |
|
7525.3.2
by Abel Deuring
implemented reviewer's comments |
26 |
|
27 |
>>> print sample_submission.date_created |
|
28 |
2008-09-26 17:19:18+00:00 |
|
29 |
||
4675.1.1
by Abel Deuring
initial data structures for HWDB submissions |
30 |
* date_submitted: Date and time of the submission (generated by the server). |
7525.3.2
by Abel Deuring
implemented reviewer's comments |
31 |
|
32 |
>>> print sample_submission.date_submitted |
|
33 |
2008-09-30 08:19:00.222131+00:00 |
|
34 |
||
4675.1.1
by Abel Deuring
initial data structures for HWDB submissions |
35 |
* format: The format version of the submitted data, as given by the HWDB |
4675.1.3
by Abel Deuring
schema modifications by stub |
36 |
client. See HWSubmissionFormat for valid values. |
7525.3.2
by Abel Deuring
implemented reviewer's comments |
37 |
|
38 |
>>> print sample_submission.format.name |
|
39 |
VERSION_1 |
|
40 |
||
4675.1.4
by Abel Deuring
implemented reviewer's comments |
41 |
* status: The status of the submission. See HWSubmissionProcessingStatus for |
4675.1.1
by Abel Deuring
initial data structures for HWDB submissions |
42 |
valid values. |
7525.3.2
by Abel Deuring
implemented reviewer's comments |
43 |
|
44 |
>>> print sample_submission.status.name |
|
45 |
PROCESSED |
|
46 |
||
4675.1.1
by Abel Deuring
initial data structures for HWDB submissions |
47 |
* private: If True, the submitter allows public access to the data. If |
48 |
false, the data may be used only for statistical purposes. |
|
7525.3.2
by Abel Deuring
implemented reviewer's comments |
49 |
|
50 |
>>> print sample_submission.private |
|
51 |
False |
|
52 |
||
4675.1.1
by Abel Deuring
initial data structures for HWDB submissions |
53 |
* contactable: If True, the submitter agrees to be contacted by upstream |
54 |
developers and package maintainers for tests etc. |
|
7525.3.2
by Abel Deuring
implemented reviewer's comments |
55 |
|
56 |
>>> print sample_submission.contactable |
|
57 |
False |
|
58 |
||
4675.1.6
by Abel Deuring
dropped hwsubmission.live_cd; renamed hwsubmission.submisson_id to hwsubmission.submission_key |
59 |
* submission_key: A unique submission ID. |
7525.3.2
by Abel Deuring
implemented reviewer's comments |
60 |
|
61 |
>>> print sample_submission.submission_key |
|
62 |
sample-submission |
|
63 |
||
7525.3.1
by Abel Deuring
Webservice API for IHWSubmissionDevice |
64 |
* raw_emailaddress: The email address of the submitter. |
7525.3.2
by Abel Deuring
implemented reviewer's comments |
65 |
|
66 |
>>> print sample_submission.raw_emailaddress |
|
67 |
test@canonical.com |
|
68 |
||
7310.2.1
by Abel Deuring
Added sample data for HWDB devices |
69 |
* owner: A reference to the Person table. This value is null, if the email |
4974.3.2
by Abel Deuring
No automatic creation of Person records for HWDB from unknown email addresses |
70 |
address does not belong (yet) to an entry in Person table. |
7525.3.2
by Abel Deuring
implemented reviewer's comments |
71 |
|
72 |
>>> print sample_submission.owner.displayname |
|
73 |
Sample Person |
|
74 |
||
4912.1.3
by Christian Reis
Implement the plain-text view for HWDB submissions, check that submission IDs are really valid_names, rename submission_id to submission_key consistently, rename distro*release to distro*series consistently. What else.. |
75 |
* distroarchseries: A reference to the distroarchseries of the submission. |
7310.2.1
by Abel Deuring
Added sample data for HWDB devices |
76 |
This value is null, if the submitted values for distribution, |
77 |
distroseries and architecture do not match an existing entry in the |
|
4675.1.1
by Abel Deuring
initial data structures for HWDB submissions |
78 |
Distroarchrelease table. |
7525.3.2
by Abel Deuring
implemented reviewer's comments |
79 |
|
80 |
>>> print sample_submission.distroarchseries.architecturetag |
|
81 |
i386 |
|
82 |
||
83 |
>>> print sample_submission.distroarchseries.distroseries.name |
|
84 |
hoary |
|
85 |
||
86 |
>>> print sample_submission.distroarchseries.distroseries.distribution.name |
|
87 |
ubuntu |
|
88 |
||
4675.1.5
by Abel Deuring
improved HWDB docs; a new exception for HWDB submissions |
89 |
* system_fingerprint: A reference to an entry of the HWSystemFingerprint |
7310.2.1
by Abel Deuring
Added sample data for HWDB devices |
90 |
table. This table stores the system name as returned by HAL |
4675.1.5
by Abel Deuring
improved HWDB docs; a new exception for HWDB submissions |
91 |
(system.vendor, system.product). |
7525.3.2
by Abel Deuring
implemented reviewer's comments |
92 |
|
93 |
>>> print sample_submission.system_fingerprint.fingerprint |
|
94 |
MSI MS-7369 |
|
95 |
||
7525.3.1
by Abel Deuring
Webservice API for IHWSubmissionDevice |
96 |
* devices: The set set of HWSubmissionDevice records which belong to |
97 |
this submission. |
|
98 |
||
8805.9.2
by Abel Deuring
added doctest for HWDB related security checks; fixed now failing test |
99 |
Access to all data except submissions is restricted to members of |
100 |
the Canonical team. |
|
101 |
||
102 |
>>> login('foo.bar@canonical.com') |
|
7525.3.2
by Abel Deuring
implemented reviewer's comments |
103 |
>>> for submission_device in sample_submission.devices[:2]: |
104 |
... print submission_device.device.name |
|
105 |
MCP65 USB Controller |
|
106 |
MCP65 SATA Controller |
|
8805.9.2
by Abel Deuring
added doctest for HWDB related security checks; fixed now failing test |
107 |
>>> login(ANONYMOUS) |
7525.3.2
by Abel Deuring
implemented reviewer's comments |
108 |
|
7525.3.1
by Abel Deuring
Webservice API for IHWSubmissionDevice |
109 |
Limitations: |
110 |
* "No name" products like mainboards from companies like ASRock |
|
111 |
or Asus that are directly sold to end users have fingerprints like |
|
112 |
"American Megatrends Inc. Uknown 1.0". |
|
113 |
* A manufacturer may erroneously assign identical DMI values for product |
|
114 |
and vendor to different systems. |
|
115 |
* submissions for "counterfeit systems". |
|
116 |
* users submitting bogus values using a patched HWDB client. |
|
117 |
||
4675.1.3
by Abel Deuring
schema modifications by stub |
118 |
The system fingerprint is stored in a separate table, HWSystemFingerprint. |
119 |
IHWSystemFingerPrintSet.createFingerprint creates a new row in this table. |
|
4675.1.1
by Abel Deuring
initial data structures for HWDB submissions |
120 |
|
11716.1.12
by Curtis Hovey
Sorted imports in doctests. |
121 |
>>> from lp.hardwaredb.interfaces.hwdb import IHWSystemFingerprintSet |
5821.11.9
by James Henstridge
Fix hwdb.txt. |
122 |
>>> from storm.store import Store |
4675.1.3
by Abel Deuring
schema modifications by stub |
123 |
>>> hw_fingerprint_set = getUtility(IHWSystemFingerprintSet) |
124 |
>>> fp = hw_fingerprint_set.createFingerprint(u'IBM T41') |
|
4675.1.1
by Abel Deuring
initial data structures for HWDB submissions |
125 |
>>> fp.fingerprint |
126 |
u'IBM T41' |
|
127 |
||
4675.1.3
by Abel Deuring
schema modifications by stub |
128 |
Each fingerprint string in HWSystemFingerprint must be unique. |
4675.1.1
by Abel Deuring
initial data structures for HWDB submissions |
129 |
|
130 |
>>> import transaction |
|
131 |
>>> transaction.commit() |
|
4675.1.3
by Abel Deuring
schema modifications by stub |
132 |
>>> fp = hw_fingerprint_set.createFingerprint(u'IBM T41') |
5821.13.3
by Bjorn Tillenius
flush the created (duplicate) fingerprint. change the error message to match. makes hwdb.txt pass. |
133 |
>>> Store.of(fp).flush() |
4675.1.1
by Abel Deuring
initial data structures for HWDB submissions |
134 |
Traceback (most recent call last): |
135 |
... |
|
5821.13.3
by Bjorn Tillenius
flush the created (duplicate) fingerprint. change the error message to match. makes hwdb.txt pass. |
136 |
IntegrityError: ... violates unique constraint "hwsystemfingerprint... |
5821.11.9
by James Henstridge
Fix hwdb.txt. |
137 |
<BLANKLINE> |
4675.1.1
by Abel Deuring
initial data structures for HWDB submissions |
138 |
|
139 |
>>> transaction.abort() |
|
140 |
||
4675.1.3
by Abel Deuring
schema modifications by stub |
141 |
IHWSystemFingerprint.getByName returns a fingerprint... |
4675.1.1
by Abel Deuring
initial data structures for HWDB submissions |
142 |
|
4675.1.3
by Abel Deuring
schema modifications by stub |
143 |
>>> fp = hw_fingerprint_set.getByName(u'IBM T41') |
4675.1.1
by Abel Deuring
initial data structures for HWDB submissions |
144 |
>>> fp.fingerprint |
145 |
u'IBM T41' |
|
146 |
||
147 |
...or None, if no entry exists. |
|
148 |
||
4675.1.3
by Abel Deuring
schema modifications by stub |
149 |
>>> print hw_fingerprint_set.getByName(u'DEC PDP11') |
4675.1.1
by Abel Deuring
initial data structures for HWDB submissions |
150 |
None |
151 |
||
7310.2.1
by Abel Deuring
Added sample data for HWDB devices |
152 |
IHWSubmissionSet.createSubmission creates a new entry in the |
4675.1.4
by Abel Deuring
implemented reviewer's comments |
153 |
HWSubmission table. |
4675.1.1
by Abel Deuring
initial data structures for HWDB submissions |
154 |
|
155 |
>>> import pytz |
|
11716.1.12
by Curtis Hovey
Sorted imports in doctests. |
156 |
>>> from StringIO import StringIO |
4675.1.1
by Abel Deuring
initial data structures for HWDB submissions |
157 |
>>> from datetime import datetime |
11716.1.15
by Curtis Hovey
Fixed multiline import statements in doctests. |
158 |
>>> from lp.hardwaredb.interfaces.hwdb import ( |
11716.1.12
by Curtis Hovey
Sorted imports in doctests. |
159 |
... HWSubmissionFormat, |
160 |
... IHWSubmissionSet, |
|
161 |
... ) |
|
4675.1.1
by Abel Deuring
initial data structures for HWDB submissions |
162 |
>>> date_created = datetime(2007, 04, 01, tzinfo=pytz.timezone('UTC')) |
163 |
>>> date_submitted = datetime(2007, 04, 02, tzinfo=pytz.timezone('UTC')) |
|
164 |
>>> submission_data = 'submission data' |
|
4675.1.3
by Abel Deuring
schema modifications by stub |
165 |
>>> hw_submission_set = getUtility(IHWSubmissionSet) |
166 |
>>> submission = hw_submission_set.createSubmission( |
|
4675.1.1
by Abel Deuring
initial data structures for HWDB submissions |
167 |
... date_created=date_created, |
4675.1.3
by Abel Deuring
schema modifications by stub |
168 |
... format=HWSubmissionFormat.VERSION_1, |
4675.1.1
by Abel Deuring
initial data structures for HWDB submissions |
169 |
... private=False, |
170 |
... contactable=False, |
|
4912.1.3
by Christian Reis
Implement the plain-text view for HWDB submissions, check that submission IDs are really valid_names, rename submission_id to submission_key consistently, rename distro*release to distro*series consistently. What else.. |
171 |
... submission_key=u'unique-id-1', |
4675.1.1
by Abel Deuring
initial data structures for HWDB submissions |
172 |
... emailaddress=u'test@canonical.com', |
173 |
... distroarchseries=None, |
|
174 |
... raw_submission=StringIO(submission_data), |
|
175 |
... filename=u'hwinfo.txt', |
|
176 |
... filesize=len(submission_data), |
|
4675.1.2
by Abel Deuring
changed column names in HWDBSumissions; added two indexes for HWDBSumission |
177 |
... system_fingerprint=u'Dell Inspiron 1234') |
4675.1.1
by Abel Deuring
initial data structures for HWDB submissions |
178 |
|
4675.1.6
by Abel Deuring
dropped hwsubmission.live_cd; renamed hwsubmission.submisson_id to hwsubmission.submission_key |
179 |
submission_key must be unique. The attempt to create a HWSubmission entry |
180 |
with an already existing submission_key raises HWSubmissionError. |
|
4675.1.1
by Abel Deuring
initial data structures for HWDB submissions |
181 |
|
4675.1.3
by Abel Deuring
schema modifications by stub |
182 |
>>> submission = hw_submission_set.createSubmission( |
4675.1.1
by Abel Deuring
initial data structures for HWDB submissions |
183 |
... date_created=date_created, |
4675.1.3
by Abel Deuring
schema modifications by stub |
184 |
... format=HWSubmissionFormat.VERSION_1, |
4675.1.1
by Abel Deuring
initial data structures for HWDB submissions |
185 |
... private=False, |
186 |
... contactable=False, |
|
4912.1.3
by Christian Reis
Implement the plain-text view for HWDB submissions, check that submission IDs are really valid_names, rename submission_id to submission_key consistently, rename distro*release to distro*series consistently. What else.. |
187 |
... submission_key=u'unique-id-1', |
4675.1.1
by Abel Deuring
initial data structures for HWDB submissions |
188 |
... emailaddress=u'test@canonical.com', |
189 |
... distroarchseries=None, |
|
190 |
... raw_submission=StringIO(submission_data), |
|
191 |
... filename=u'hwinfo.txt', |
|
192 |
... filesize=len(submission_data), |
|
4675.1.2
by Abel Deuring
changed column names in HWDBSumissions; added two indexes for HWDBSumission |
193 |
... system_fingerprint=u'Dell Inspiron 1234') |
4675.1.1
by Abel Deuring
initial data structures for HWDB submissions |
194 |
Traceback (most recent call last): |
195 |
... |
|
4675.1.5
by Abel Deuring
improved HWDB docs; a new exception for HWDB submissions |
196 |
HWSubmissionKeyNotUnique: A submission with this ID already exists |
4675.1.1
by Abel Deuring
initial data structures for HWDB submissions |
197 |
|
4974.3.2
by Abel Deuring
No automatic creation of Person records for HWDB from unknown email addresses |
198 |
The field `owner` points to the Person record of the submitter, if the |
199 |
submitted emailaddress belongs to an existing Launchpad account. |
|
4675.1.1
by Abel Deuring
initial data structures for HWDB submissions |
200 |
|
201 |
>>> submission.owner.displayname |
|
202 |
u'Sample Person' |
|
203 |
||
4675.1.4
by Abel Deuring
implemented reviewer's comments |
204 |
If no Person record is yet known for the submitter's email address, |
4974.3.2
by Abel Deuring
No automatic creation of Person records for HWDB from unknown email addresses |
205 |
the field `owner` is None. |
4675.1.3
by Abel Deuring
schema modifications by stub |
206 |
|
11692.6.2
by Curtis Hovey
Use deglober to fixing simple glob imports in doctests. |
207 |
>>> from lp.registry.interfaces.person import IPersonSet |
4675.1.3
by Abel Deuring
schema modifications by stub |
208 |
>>> beeblebrox = getUtility(IPersonSet).getByEmail( |
209 |
... 'beeblebrox@example.com') |
|
210 |
>>> print beeblebrox |
|
211 |
None |
|
212 |
||
213 |
>>> submission = hw_submission_set.createSubmission( |
|
4675.1.1
by Abel Deuring
initial data structures for HWDB submissions |
214 |
... date_created=date_created, |
4675.1.3
by Abel Deuring
schema modifications by stub |
215 |
... format=HWSubmissionFormat.VERSION_1, |
4675.1.1
by Abel Deuring
initial data structures for HWDB submissions |
216 |
... private=False, |
217 |
... contactable=False, |
|
4912.1.3
by Christian Reis
Implement the plain-text view for HWDB submissions, check that submission IDs are really valid_names, rename submission_id to submission_key consistently, rename distro*release to distro*series consistently. What else.. |
218 |
... submission_key=u'unique-id-2', |
4675.1.1
by Abel Deuring
initial data structures for HWDB submissions |
219 |
... emailaddress=u'beeblebrox@example.com', |
220 |
... distroarchseries=None, |
|
221 |
... raw_submission=StringIO(submission_data), |
|
222 |
... filename=u'hwinfo.txt', |
|
223 |
... filesize=len(submission_data), |
|
4675.1.2
by Abel Deuring
changed column names in HWDBSumissions; added two indexes for HWDBSumission |
224 |
... system_fingerprint=u'Acer 6789') |
4974.3.2
by Abel Deuring
No automatic creation of Person records for HWDB from unknown email addresses |
225 |
>>> print submission.owner |
226 |
None |
|
4675.1.3
by Abel Deuring
schema modifications by stub |
227 |
|
4912.1.3
by Christian Reis
Implement the plain-text view for HWDB submissions, check that submission IDs are really valid_names, rename submission_id to submission_key consistently, rename distro*release to distro*series consistently. What else.. |
228 |
The submitted data can be retrieved via IHWSubmissionSet.getBySubmissionKey. |
4675.1.3
by Abel Deuring
schema modifications by stub |
229 |
|
4912.1.3
by Christian Reis
Implement the plain-text view for HWDB submissions, check that submission IDs are really valid_names, rename submission_id to submission_key consistently, rename distro*release to distro*series consistently. What else.. |
230 |
>>> submission = hw_submission_set.getBySubmissionKey(u'unique-id-1') |
4675.1.6
by Abel Deuring
dropped hwsubmission.live_cd; renamed hwsubmission.submisson_id to hwsubmission.submission_key |
231 |
>>> submission.submission_key, submission.system_fingerprint.fingerprint |
4912.1.3
by Christian Reis
Implement the plain-text view for HWDB submissions, check that submission IDs are really valid_names, rename submission_id to submission_key consistently, rename distro*release to distro*series consistently. What else.. |
232 |
(u'unique-id-1', u'Dell Inspiron 1234') |
4675.1.1
by Abel Deuring
initial data structures for HWDB submissions |
233 |
|
7310.2.1
by Abel Deuring
Added sample data for HWDB devices |
234 |
If a submission is marked as private, it is only returned by |
4912.1.3
by Christian Reis
Implement the plain-text view for HWDB submissions, check that submission IDs are really valid_names, rename submission_id to submission_key consistently, rename distro*release to distro*series consistently. What else.. |
235 |
IHWSubmissionSet.getBySubmissionKey if the parameter `user` matches the |
4675.1.4
by Abel Deuring
implemented reviewer's comments |
236 |
owner of the submission... |
4675.1.1
by Abel Deuring
initial data structures for HWDB submissions |
237 |
|
4675.1.3
by Abel Deuring
schema modifications by stub |
238 |
>>> submission = hw_submission_set.createSubmission( |
4675.1.1
by Abel Deuring
initial data structures for HWDB submissions |
239 |
... date_created=date_created, |
4675.1.3
by Abel Deuring
schema modifications by stub |
240 |
... format=HWSubmissionFormat.VERSION_1, |
4675.1.1
by Abel Deuring
initial data structures for HWDB submissions |
241 |
... private=True, |
242 |
... contactable=False, |
|
7465.7.2
by Abel Deuring
implemented reviewer's comments |
243 |
... submission_key=u'private-submission', |
4675.1.1
by Abel Deuring
initial data structures for HWDB submissions |
244 |
... emailaddress=u'test@canonical.com', |
245 |
... distroarchseries=None, |
|
246 |
... raw_submission=StringIO(submission_data), |
|
247 |
... filename=u'hwinfo.txt', |
|
248 |
... filesize=len(submission_data), |
|
4675.1.2
by Abel Deuring
changed column names in HWDBSumissions; added two indexes for HWDBSumission |
249 |
... system_fingerprint=u'Dell Inspiron 1234') |
7465.7.2
by Abel Deuring
implemented reviewer's comments |
250 |
>>> print hw_submission_set.getBySubmissionKey(u'private-submission') |
4675.1.1
by Abel Deuring
initial data structures for HWDB submissions |
251 |
None |
252 |
>>> sample_person = getUtility(IPersonSet).getByEmail('test@canonical.com') |
|
253 |
>>> sample_person.displayname |
|
254 |
u'Sample Person' |
|
4912.1.3
by Christian Reis
Implement the plain-text view for HWDB submissions, check that submission IDs are really valid_names, rename submission_id to submission_key consistently, rename distro*release to distro*series consistently. What else.. |
255 |
>>> submission = hw_submission_set.getBySubmissionKey( |
7465.7.2
by Abel Deuring
implemented reviewer's comments |
256 |
... u'private-submission', sample_person) |
4675.1.4
by Abel Deuring
implemented reviewer's comments |
257 |
>>> submission |
258 |
<HWSubmission at ...> |
|
259 |
||
260 |
... or if `user` is an admin. |
|
261 |
||
262 |
>>> foobar = getUtility(IPersonSet).getByEmail('foo.bar@canonical.com') |
|
4912.1.3
by Christian Reis
Implement the plain-text view for HWDB submissions, check that submission IDs are really valid_names, rename submission_id to submission_key consistently, rename distro*release to distro*series consistently. What else.. |
263 |
>>> submission = hw_submission_set.getBySubmissionKey( |
7465.7.2
by Abel Deuring
implemented reviewer's comments |
264 |
... u'private-submission', foobar) |
4675.1.4
by Abel Deuring
implemented reviewer's comments |
265 |
>>> submission |
266 |
<HWSubmission at ...> |
|
267 |
||
268 |
Only the owner and admins can view the submission details. |
|
269 |
||
4675.1.6
by Abel Deuring
dropped hwsubmission.live_cd; renamed hwsubmission.submisson_id to hwsubmission.submission_key |
270 |
>>> submission.submission_key, submission.system_fingerprint.fingerprint |
4675.1.4
by Abel Deuring
implemented reviewer's comments |
271 |
Traceback (most recent call last): |
272 |
... |
|
4675.1.6
by Abel Deuring
dropped hwsubmission.live_cd; renamed hwsubmission.submisson_id to hwsubmission.submission_key |
273 |
Unauthorized: (...'submission_key', 'launchpad.View') |
4675.1.4
by Abel Deuring
implemented reviewer's comments |
274 |
|
275 |
>>> login('test@canonical.com') |
|
4675.1.6
by Abel Deuring
dropped hwsubmission.live_cd; renamed hwsubmission.submisson_id to hwsubmission.submission_key |
276 |
>>> submission.submission_key, submission.system_fingerprint.fingerprint |
7465.7.2
by Abel Deuring
implemented reviewer's comments |
277 |
(u'private-submission', u'Dell Inspiron 1234') |
4675.1.4
by Abel Deuring
implemented reviewer's comments |
278 |
|
279 |
>>> login('foo.bar@canonical.com') |
|
4675.1.6
by Abel Deuring
dropped hwsubmission.live_cd; renamed hwsubmission.submisson_id to hwsubmission.submission_key |
280 |
>>> submission.submission_key, submission.system_fingerprint.fingerprint |
7465.7.2
by Abel Deuring
implemented reviewer's comments |
281 |
(u'private-submission', u'Dell Inspiron 1234') |
4675.1.4
by Abel Deuring
implemented reviewer's comments |
282 |
|
283 |
Passing another person than the owner or an admin as the parameter `user` |
|
284 |
does not return private submissions. |
|
4675.1.1
by Abel Deuring
initial data structures for HWDB submissions |
285 |
|
286 |
>>> no_priv = getUtility(IPersonSet).getByEmail('no-priv@canonical.com') |
|
287 |
>>> no_priv.displayname |
|
288 |
u'No Privileges Person' |
|
7465.7.2
by Abel Deuring
implemented reviewer's comments |
289 |
>>> print hw_submission_set.getBySubmissionKey(u'private-submission', |
290 |
... no_priv) |
|
4675.1.1
by Abel Deuring
initial data structures for HWDB submissions |
291 |
None |
292 |
||
4675.1.4
by Abel Deuring
implemented reviewer's comments |
293 |
>>> login(ANONYMOUS) |
294 |
||
4675.1.1
by Abel Deuring
initial data structures for HWDB submissions |
295 |
If no submission exists for a given ID, None is returned. |
296 |
||
4912.1.3
by Christian Reis
Implement the plain-text view for HWDB submissions, check that submission IDs are really valid_names, rename submission_id to submission_key consistently, rename distro*release to distro*series consistently. What else.. |
297 |
>>> print hw_submission_set.getBySubmissionKey(u'unknown-ID') |
4675.1.1
by Abel Deuring
initial data structures for HWDB submissions |
298 |
None |
299 |
||
4675.1.3
by Abel Deuring
schema modifications by stub |
300 |
IHWSubmissionSet.getByFingerprintName returns all submissions for a |
4675.1.1
by Abel Deuring
initial data structures for HWDB submissions |
301 |
given fingerprint name. Private submissions are excluded, if the parameter |
4675.1.4
by Abel Deuring
implemented reviewer's comments |
302 |
`user` is omitted or if user is neither the owner nor an admin. |
4675.1.1
by Abel Deuring
initial data structures for HWDB submissions |
303 |
|
4675.1.3
by Abel Deuring
schema modifications by stub |
304 |
>>> submissions = hw_submission_set.getByFingerprintName( |
4675.1.1
by Abel Deuring
initial data structures for HWDB submissions |
305 |
... u'Dell Inspiron 1234') |
4675.1.6
by Abel Deuring
dropped hwsubmission.live_cd; renamed hwsubmission.submisson_id to hwsubmission.submission_key |
306 |
>>> [(s.submission_key, s.system_fingerprint.fingerprint, s.private) |
4675.1.2
by Abel Deuring
changed column names in HWDBSumissions; added two indexes for HWDBSumission |
307 |
... for s in submissions] |
4912.1.3
by Christian Reis
Implement the plain-text view for HWDB submissions, check that submission IDs are really valid_names, rename submission_id to submission_key consistently, rename distro*release to distro*series consistently. What else.. |
308 |
[(u'unique-id-1', u'Dell Inspiron 1234', False)] |
4675.1.3
by Abel Deuring
schema modifications by stub |
309 |
>>> submissions = hw_submission_set.getByFingerprintName( |
4675.1.1
by Abel Deuring
initial data structures for HWDB submissions |
310 |
... u'Dell Inspiron 1234', no_priv) |
4675.1.6
by Abel Deuring
dropped hwsubmission.live_cd; renamed hwsubmission.submisson_id to hwsubmission.submission_key |
311 |
>>> [(s.submission_key, s.system_fingerprint.fingerprint, s.private) |
4675.1.2
by Abel Deuring
changed column names in HWDBSumissions; added two indexes for HWDBSumission |
312 |
... for s in submissions] |
4912.1.3
by Christian Reis
Implement the plain-text view for HWDB submissions, check that submission IDs are really valid_names, rename submission_id to submission_key consistently, rename distro*release to distro*series consistently. What else.. |
313 |
[(u'unique-id-1', u'Dell Inspiron 1234', False)] |
4675.1.4
by Abel Deuring
implemented reviewer's comments |
314 |
>>> login('test@canonical.com') |
4675.1.3
by Abel Deuring
schema modifications by stub |
315 |
>>> submissions = hw_submission_set.getByFingerprintName( |
4675.1.1
by Abel Deuring
initial data structures for HWDB submissions |
316 |
... u'Dell Inspiron 1234', sample_person) |
4675.1.6
by Abel Deuring
dropped hwsubmission.live_cd; renamed hwsubmission.submisson_id to hwsubmission.submission_key |
317 |
>>> [(s.submission_key, s.system_fingerprint.fingerprint, s.private) |
4675.1.4
by Abel Deuring
implemented reviewer's comments |
318 |
... for s in submissions] |
7465.7.2
by Abel Deuring
implemented reviewer's comments |
319 |
[(u'private-submission', u'Dell Inspiron 1234', True), |
320 |
(u'unique-id-1', u'Dell Inspiron 1234', False)] |
|
4675.1.4
by Abel Deuring
implemented reviewer's comments |
321 |
>>> submissions = hw_submission_set.getByFingerprintName( |
322 |
... u'Dell Inspiron 1234', foobar) |
|
4675.1.6
by Abel Deuring
dropped hwsubmission.live_cd; renamed hwsubmission.submisson_id to hwsubmission.submission_key |
323 |
>>> [(s.submission_key, s.system_fingerprint.fingerprint, s.private) |
4675.1.4
by Abel Deuring
implemented reviewer's comments |
324 |
... for s in submissions] |
7465.7.2
by Abel Deuring
implemented reviewer's comments |
325 |
[(u'private-submission', u'Dell Inspiron 1234', True), |
326 |
(u'unique-id-1', u'Dell Inspiron 1234', False)] |
|
4675.1.1
by Abel Deuring
initial data structures for HWDB submissions |
327 |
|
328 |
If no submissions exist for the given system fingerprint, an empty result |
|
329 |
set is returned. |
|
330 |
||
4675.1.3
by Abel Deuring
schema modifications by stub |
331 |
>>> list(hw_submission_set.getByFingerprintName('DEC PDP11')) |
4675.1.1
by Abel Deuring
initial data structures for HWDB submissions |
332 |
[] |
333 |
||
4675.1.3
by Abel Deuring
schema modifications by stub |
334 |
IHWSubmissionSet.getByOwner returns all submissions of a person. Again, |
4675.1.4
by Abel Deuring
implemented reviewer's comments |
335 |
only non-private submissions are returned if no parameter `user` is passed |
336 |
to the method, or if the passed parameter is neither the owner nor an admin. |
|
4675.1.1
by Abel Deuring
initial data structures for HWDB submissions |
337 |
|
4675.1.3
by Abel Deuring
schema modifications by stub |
338 |
>>> submissions = hw_submission_set.getByOwner(sample_person) |
4675.1.6
by Abel Deuring
dropped hwsubmission.live_cd; renamed hwsubmission.submisson_id to hwsubmission.submission_key |
339 |
>>> [(s.submission_key, s.system_fingerprint.fingerprint) |
4675.1.2
by Abel Deuring
changed column names in HWDBSumissions; added two indexes for HWDBSumission |
340 |
... for s in submissions] |
4912.1.3
by Christian Reis
Implement the plain-text view for HWDB submissions, check that submission IDs are really valid_names, rename submission_id to submission_key consistently, rename distro*release to distro*series consistently. What else.. |
341 |
[(u'unique-id-1', u'Dell Inspiron 1234'), |
7310.2.1
by Abel Deuring
Added sample data for HWDB devices |
342 |
(u'sample-submission', u'MSI MS-7369'), |
4675.1.5
by Abel Deuring
improved HWDB docs; a new exception for HWDB submissions |
343 |
(u'test_submission_id_1', u'TONKA TUFFBOOK2600')] |
4675.1.3
by Abel Deuring
schema modifications by stub |
344 |
>>> submissions = hw_submission_set.getByOwner(sample_person, |
4675.1.4
by Abel Deuring
implemented reviewer's comments |
345 |
... user=no_priv) |
4675.1.6
by Abel Deuring
dropped hwsubmission.live_cd; renamed hwsubmission.submisson_id to hwsubmission.submission_key |
346 |
>>> [(s.submission_key, s.system_fingerprint.fingerprint) |
4675.1.2
by Abel Deuring
changed column names in HWDBSumissions; added two indexes for HWDBSumission |
347 |
... for s in submissions] |
4912.1.3
by Christian Reis
Implement the plain-text view for HWDB submissions, check that submission IDs are really valid_names, rename submission_id to submission_key consistently, rename distro*release to distro*series consistently. What else.. |
348 |
[(u'unique-id-1', u'Dell Inspiron 1234'), |
7310.2.1
by Abel Deuring
Added sample data for HWDB devices |
349 |
(u'sample-submission', u'MSI MS-7369'), |
4675.1.5
by Abel Deuring
improved HWDB docs; a new exception for HWDB submissions |
350 |
(u'test_submission_id_1', u'TONKA TUFFBOOK2600')] |
4675.1.3
by Abel Deuring
schema modifications by stub |
351 |
>>> submissions = hw_submission_set.getByOwner(sample_person, |
4675.1.4
by Abel Deuring
implemented reviewer's comments |
352 |
... user=sample_person) |
4675.1.6
by Abel Deuring
dropped hwsubmission.live_cd; renamed hwsubmission.submisson_id to hwsubmission.submission_key |
353 |
>>> [(s.submission_key, s.system_fingerprint.fingerprint) |
4675.1.4
by Abel Deuring
implemented reviewer's comments |
354 |
... for s in submissions] |
7465.7.2
by Abel Deuring
implemented reviewer's comments |
355 |
[(u'private-submission', u'Dell Inspiron 1234'), |
356 |
(u'unique-id-1', u'Dell Inspiron 1234'), |
|
7310.2.1
by Abel Deuring
Added sample data for HWDB devices |
357 |
(u'sample-submission', u'MSI MS-7369'), |
4675.1.5
by Abel Deuring
improved HWDB docs; a new exception for HWDB submissions |
358 |
(u'test_submission_id_1', u'TONKA TUFFBOOK2600')] |
4675.1.4
by Abel Deuring
implemented reviewer's comments |
359 |
>>> submissions = hw_submission_set.getByOwner(sample_person, |
360 |
... user=foobar) |
|
4675.1.6
by Abel Deuring
dropped hwsubmission.live_cd; renamed hwsubmission.submisson_id to hwsubmission.submission_key |
361 |
>>> [(s.submission_key, s.system_fingerprint.fingerprint) |
4675.1.2
by Abel Deuring
changed column names in HWDBSumissions; added two indexes for HWDBSumission |
362 |
... for s in submissions] |
7465.7.2
by Abel Deuring
implemented reviewer's comments |
363 |
[(u'private-submission', u'Dell Inspiron 1234'), |
364 |
(u'unique-id-1', u'Dell Inspiron 1234'), |
|
7310.2.1
by Abel Deuring
Added sample data for HWDB devices |
365 |
(u'sample-submission', u'MSI MS-7369'), |
4675.1.5
by Abel Deuring
improved HWDB docs; a new exception for HWDB submissions |
366 |
(u'test_submission_id_1', u'TONKA TUFFBOOK2600')] |
4974.3.2
by Abel Deuring
No automatic creation of Person records for HWDB from unknown email addresses |
367 |
|
7310.2.1
by Abel Deuring
Added sample data for HWDB devices |
368 |
When an anonymous submitter later registers a Launchpad account, the field |
4974.3.2
by Abel Deuring
No automatic creation of Person records for HWDB from unknown email addresses |
369 |
`owner` is updated. |
370 |
||
14538.1.2
by Curtis Hovey
Moved account and email address to lp.services.identity. |
371 |
>>> from lp.services.identity.interfaces.emailaddress import IEmailAddressSet |
11716.1.6
by Curtis Hovey
Converted glob imports in doctests to import for the true module. |
372 |
>>> from lp.registry.interfaces.person import PersonCreationRationale |
4974.3.2
by Abel Deuring
No automatic creation of Person records for HWDB from unknown email addresses |
373 |
>>> user = getUtility(IPersonSet).ensurePerson( |
7310.2.1
by Abel Deuring
Added sample data for HWDB devices |
374 |
... u'beeblebrox@example.com', u'Beeblebrox', |
4974.3.2
by Abel Deuring
No automatic creation of Person records for HWDB from unknown email addresses |
375 |
... PersonCreationRationale.OWNER_CREATED_LAUNCHPAD) |
376 |
>>> email = getUtility(IEmailAddressSet).getByEmail( |
|
377 |
... u'beeblebrox@example.com') |
|
378 |
>>> user.validateAndEnsurePreferredEmail(email) |
|
8137.17.24
by Barry Warsaw
thread merge |
379 |
>>> transaction.commit() |
11703.1.1
by Tim Penhey
Move the garbo script into lp.scripts. |
380 |
>>> from lp.scripts.garbo import HWSubmissionEmailLinker |
12070.1.20
by Tim Penhey
Replace MockLogger with DevNullLogger. |
381 |
>>> from lp.services.log.logger import DevNullLogger |
382 |
>>> HWSubmissionEmailLinker(log=DevNullLogger()).run() |
|
4974.3.2
by Abel Deuring
No automatic creation of Person records for HWDB from unknown email addresses |
383 |
>>> submission = hw_submission_set.getBySubmissionKey(u'unique-id-2') |
384 |
>>> print submission.owner.displayname |
|
385 |
Beeblebrox |
|
386 |
||
387 |
If somebody has a Launchpad account, but submits HWDB test data using |
|
388 |
an email address which he has not added to his account, the submission |
|
8037.2.1
by Brad Crittenden
fixed annoying typos |
389 |
will have the `owner` field set to None. |
4974.3.2
by Abel Deuring
No automatic creation of Person records for HWDB from unknown email addresses |
390 |
|
391 |
>>> submission = hw_submission_set.createSubmission( |
|
392 |
... date_created=date_created, |
|
393 |
... format=HWSubmissionFormat.VERSION_1, |
|
394 |
... private=False, |
|
395 |
... contactable=False, |
|
396 |
... submission_key=u'unique-id-4', |
|
397 |
... emailaddress=u'beeblebrox@beeblebrox.net', |
|
398 |
... distroarchseries=None, |
|
399 |
... raw_submission=StringIO(submission_data), |
|
400 |
... filename=u'hwinfo.txt', |
|
401 |
... filesize=len(submission_data), |
|
402 |
... system_fingerprint=u'Acer 6789') |
|
6978.2.2
by Abel Deuring
implemented reviewer's comments |
403 |
>>> Store.of(submission).flush() |
4974.3.2
by Abel Deuring
No automatic creation of Person records for HWDB from unknown email addresses |
404 |
>>> print submission.owner |
405 |
None |
|
406 |
||
407 |
When he adds this email address to his list of addresses in Launchpad, |
|
4974.3.4
by Abel Deuring
implemented reviewer's comments |
408 |
the field `owner` is updated. |
4974.3.2
by Abel Deuring
No automatic creation of Person records for HWDB from unknown email addresses |
409 |
|
410 |
>>> email = getUtility(IEmailAddressSet).new( |
|
14632.1.1
by William Grant
EmailAddressSet.new now infers account from person where possible. Fix redundant tests. |
411 |
... u'beeblebrox@beeblebrox.net', user) |
7675.85.2
by Jonathan Lange
Undo revision generated by step 2 of process. |
412 |
>>> transaction.commit() |
7841.1.7
by Guilherme Salgado
Fix a couple tests |
413 |
>>> login_person(user) |
4974.3.2
by Abel Deuring
No automatic creation of Person records for HWDB from unknown email addresses |
414 |
>>> user.validateAndEnsurePreferredEmail(email) |
7675.85.2
by Jonathan Lange
Undo revision generated by step 2 of process. |
415 |
>>> transaction.commit() |
12070.1.20
by Tim Penhey
Replace MockLogger with DevNullLogger. |
416 |
>>> HWSubmissionEmailLinker(log=DevNullLogger()).run() |
4974.3.2
by Abel Deuring
No automatic creation of Person records for HWDB from unknown email addresses |
417 |
>>> submission = hw_submission_set.getBySubmissionKey(u'unique-id-2') |
418 |
>>> print submission.owner.displayname |
|
4974.3.4
by Abel Deuring
implemented reviewer's comments |
419 |
Beeblebrox |
6740.2.1
by Abel Deuring
fix for bug 250589: OOPS rendering +hwdb-submissions page |
420 |
|
421 |
=== Submission Records without an email address === |
|
422 |
||
423 |
A submission does not necessarily have an email address (anonymous |
|
6740.2.2
by Abel Deuring
implemented reviewer'c comments |
424 |
submission). In this case the owner is always None. |
6740.2.1
by Abel Deuring
fix for bug 250589: OOPS rendering +hwdb-submissions page |
425 |
|
6796.1.1
by Abel Deuring
Definition of HWSubmissionBug, linking HWDB submissions with bugs |
426 |
>>> submission_no_owner = hw_submission_set.createSubmission( |
6740.2.1
by Abel Deuring
fix for bug 250589: OOPS rendering +hwdb-submissions page |
427 |
... date_created=date_created, |
428 |
... format=HWSubmissionFormat.VERSION_1, |
|
429 |
... private=False, |
|
430 |
... contactable=False, |
|
431 |
... submission_key=u'unique-id-5', |
|
432 |
... emailaddress=None, |
|
433 |
... distroarchseries=None, |
|
434 |
... raw_submission=StringIO(submission_data), |
|
435 |
... filename=u'hwinfo.txt', |
|
436 |
... filesize=len(submission_data), |
|
437 |
... system_fingerprint=u'Dell Inspiron 1234') |
|
6978.2.2
by Abel Deuring
implemented reviewer's comments |
438 |
>>> Store.of(submission_no_owner).flush() |
6796.1.1
by Abel Deuring
Definition of HWSubmissionBug, linking HWDB submissions with bugs |
439 |
>>> print submission_no_owner.raw_emailaddress |
440 |
None |
|
441 |
>>> print submission_no_owner.owner |
|
442 |
None |
|
443 |
||
6978.2.1
by Abel Deuring
retrieve HWDB submissions by processing status |
444 |
== Retrieving Submissions by Status == |
445 |
||
446 |
The set of submissions with a given status can be retrieved by |
|
6978.2.4
by Abel Deuring
implemented reviewer's comments |
447 |
IHWSubmissionSet.getByStatus(). Only the publicly visible |
448 |
submissions are returned if no user is specified. |
|
6978.2.1
by Abel Deuring
retrieve HWDB submissions by processing status |
449 |
|
10234.3.3
by Curtis Hovey
Migrated hardward database to lp. Updated test_doc to run the hwddb test. |
450 |
>>> from lp.hardwaredb.interfaces.hwdb import ( |
6978.2.1
by Abel Deuring
retrieve HWDB submissions by processing status |
451 |
... HWSubmissionProcessingStatus) |
6978.2.4
by Abel Deuring
implemented reviewer's comments |
452 |
>>> def print_submissions(submissions): |
453 |
... for submission in submissions: |
|
454 |
... print submission.submission_key, submission.private, |
|
455 |
... if submission.owner is not None: |
|
456 |
... print submission.owner.displayname, |
|
457 |
... else: |
|
458 |
... print '(no owner)', |
|
459 |
... print submission.status.name |
|
6978.2.1
by Abel Deuring
retrieve HWDB submissions by processing status |
460 |
>>> new_submissions = hw_submission_set.getByStatus( |
461 |
... HWSubmissionProcessingStatus.SUBMITTED) |
|
6978.2.4
by Abel Deuring
implemented reviewer's comments |
462 |
>>> print_submissions(new_submissions) |
463 |
test_submission_id_1 False Sample Person SUBMITTED |
|
464 |
unique-id-1 False Sample Person SUBMITTED |
|
465 |
unique-id-2 False Beeblebrox SUBMITTED |
|
466 |
unique-id-4 False Beeblebrox SUBMITTED |
|
467 |
unique-id-5 False (no owner) SUBMITTED |
|
6978.2.1
by Abel Deuring
retrieve HWDB submissions by processing status |
468 |
|
469 |
If a user is passed, private submissions of this user are returned too. |
|
470 |
||
471 |
>>> login('test@canonical.com') |
|
10234.3.3
by Curtis Hovey
Migrated hardward database to lp. Updated test_doc to run the hwddb test. |
472 |
>>> from lp.hardwaredb.interfaces.hwdb import ( |
6978.2.1
by Abel Deuring
retrieve HWDB submissions by processing status |
473 |
... HWSubmissionProcessingStatus) |
474 |
>>> new_submissions = hw_submission_set.getByStatus( |
|
475 |
... HWSubmissionProcessingStatus.SUBMITTED, user=sample_person) |
|
6978.2.4
by Abel Deuring
implemented reviewer's comments |
476 |
>>> print_submissions(new_submissions) |
477 |
test_submission_id_1 False Sample Person SUBMITTED |
|
478 |
unique-id-1 False Sample Person SUBMITTED |
|
479 |
unique-id-2 False Beeblebrox SUBMITTED |
|
7465.7.2
by Abel Deuring
implemented reviewer's comments |
480 |
private-submission True Sample Person SUBMITTED |
6978.2.4
by Abel Deuring
implemented reviewer's comments |
481 |
unique-id-4 False Beeblebrox SUBMITTED |
482 |
unique-id-5 False (no owner) SUBMITTED |
|
483 |
||
484 |
Submissions of other users are not returned. |
|
485 |
||
10234.3.3
by Curtis Hovey
Migrated hardward database to lp. Updated test_doc to run the hwddb test. |
486 |
>>> from lp.hardwaredb.interfaces.hwdb import ( |
6978.2.4
by Abel Deuring
implemented reviewer's comments |
487 |
... HWSubmissionProcessingStatus) |
488 |
>>> new_submissions = hw_submission_set.getByStatus( |
|
489 |
... HWSubmissionProcessingStatus.SUBMITTED, user=no_priv) |
|
490 |
>>> print_submissions(new_submissions) |
|
491 |
test_submission_id_1 False Sample Person SUBMITTED |
|
492 |
unique-id-1 False Sample Person SUBMITTED |
|
493 |
unique-id-2 False Beeblebrox SUBMITTED |
|
494 |
unique-id-4 False Beeblebrox SUBMITTED |
|
495 |
unique-id-5 False (no owner) SUBMITTED |
|
6978.2.1
by Abel Deuring
retrieve HWDB submissions by processing status |
496 |
|
497 |
For admins, IHWSubmissionSet.getByStatus() returns private and public |
|
498 |
submissions... |
|
499 |
||
500 |
>>> foobar = getUtility(IPersonSet).getByEmail('foo.bar@canonical.com') |
|
501 |
>>> login('foo.bar@canonical.com') |
|
10234.3.3
by Curtis Hovey
Migrated hardward database to lp. Updated test_doc to run the hwddb test. |
502 |
>>> from lp.hardwaredb.interfaces.hwdb import ( |
6978.2.1
by Abel Deuring
retrieve HWDB submissions by processing status |
503 |
... HWSubmissionProcessingStatus) |
504 |
>>> new_submissions = hw_submission_set.getByStatus( |
|
505 |
... HWSubmissionProcessingStatus.SUBMITTED, user=foobar) |
|
6978.2.4
by Abel Deuring
implemented reviewer's comments |
506 |
>>> print_submissions(new_submissions) |
507 |
test_submission_id_1 False Sample Person SUBMITTED |
|
508 |
unique-id-1 False Sample Person SUBMITTED |
|
509 |
unique-id-2 False Beeblebrox SUBMITTED |
|
7465.7.2
by Abel Deuring
implemented reviewer's comments |
510 |
private-submission True Sample Person SUBMITTED |
6978.2.4
by Abel Deuring
implemented reviewer's comments |
511 |
unique-id-4 False Beeblebrox SUBMITTED |
512 |
unique-id-5 False (no owner) SUBMITTED |
|
6978.2.1
by Abel Deuring
retrieve HWDB submissions by processing status |
513 |
|
514 |
...as well as for the janitor. |
|
515 |
||
13130.1.6
by Curtis Hovey
Move ILaunchpadCelebrity to lp.app. |
516 |
>>> from lp.app.interfaces.launchpad import ILaunchpadCelebrities |
6978.2.1
by Abel Deuring
retrieve HWDB submissions by processing status |
517 |
>>> janitor = getUtility(ILaunchpadCelebrities).janitor |
518 |
>>> new_submissions = hw_submission_set.getByStatus( |
|
519 |
... HWSubmissionProcessingStatus.SUBMITTED, user=janitor) |
|
6978.2.4
by Abel Deuring
implemented reviewer's comments |
520 |
>>> print_submissions(new_submissions) |
521 |
test_submission_id_1 False Sample Person SUBMITTED |
|
522 |
unique-id-1 False Sample Person SUBMITTED |
|
523 |
unique-id-2 False Beeblebrox SUBMITTED |
|
7465.7.2
by Abel Deuring
implemented reviewer's comments |
524 |
private-submission True Sample Person SUBMITTED |
6978.2.4
by Abel Deuring
implemented reviewer's comments |
525 |
unique-id-4 False Beeblebrox SUBMITTED |
526 |
unique-id-5 False (no owner) SUBMITTED |
|
6978.2.1
by Abel Deuring
retrieve HWDB submissions by processing status |
527 |
|
528 |
Searching for other statuses is possible too. |
|
529 |
||
530 |
>>> submission_no_owner.status = HWSubmissionProcessingStatus.PROCESSED |
|
531 |
>>> processed_submissions = hw_submission_set.getByStatus( |
|
532 |
... HWSubmissionProcessingStatus.PROCESSED, user=foobar) |
|
6978.2.4
by Abel Deuring
implemented reviewer's comments |
533 |
>>> print_submissions(processed_submissions) |
7310.2.1
by Abel Deuring
Added sample data for HWDB devices |
534 |
sample-submission False Sample Person PROCESSED |
6978.2.4
by Abel Deuring
implemented reviewer's comments |
535 |
unique-id-5 False (no owner) PROCESSED |
6978.2.1
by Abel Deuring
retrieve HWDB submissions by processing status |
536 |
|
6796.1.1
by Abel Deuring
Definition of HWSubmissionBug, linking HWDB submissions with bugs |
537 |
== Links to Bugs == |
538 |
||
539 |
HWDB submissions can be linked to bugs. These links are created by |
|
540 |
IHWSubmissionBugSet.create(). |
|
541 |
||
8523.3.1
by Gavin Panella
Bugs tree reorg after automated migration. |
542 |
>>> from lp.bugs.interfaces.bug import IBugSet |
10234.3.3
by Curtis Hovey
Migrated hardward database to lp. Updated test_doc to run the hwddb test. |
543 |
>>> from lp.hardwaredb.interfaces.hwdb import IHWSubmissionBugSet |
6796.1.1
by Abel Deuring
Definition of HWSubmissionBug, linking HWDB submissions with bugs |
544 |
>>> bug_one = getUtility(IBugSet).get(1) |
545 |
>>> submission_bug_set = getUtility(IHWSubmissionBugSet) |
|
546 |
>>> submission_bug = submission_bug_set.create( |
|
547 |
... submission_no_owner, bug_one) |
|
548 |
>>> transaction.commit() |
|
549 |
>>> print submission_bug.submission.submission_key |
|
550 |
unique-id-5 |
|
551 |
>>> submission_bug.bug.id |
|
552 |
1 |
|
553 |
||
8486.18.5
by Abel Deuring
exposed bug.linkHWSubmission()m bug.unlinkHWSubmission and bug.getHWSubmissions() to the webservice API. |
554 |
Links between a bug and a submission are unique. If we call |
555 |
IHWSubmissionBugSet.create() twice for the same bug and HWDB submission, |
|
556 |
the method returns the existing record. |
|
557 |
||
558 |
>>> second_link = submission_bug_set.create(submission_no_owner, bug_one) |
|
559 |
>>> second_link.id == submission_bug.id |
|
560 |
True |
|
7465.7.1
by Abel Deuring
search method for IHWSubmissionSet |
561 |
|
8486.18.2
by Abel Deuring
changed method HWSubmissionSet._userHasAccessStormClause() into a function; privacy check added in HWSubmissionBugSet.submissionsForBug() added; tests added. |
562 |
HWSubmissionBugSet.submissionsForBug() returns all submissions linked to |
563 |
a given bug. |
|
564 |
||
565 |
>>> for submission in submission_bug_set.submissionsForBug(bug_one): |
|
566 |
... print submission.submission_key |
|
567 |
unique-id-5 |
|
568 |
||
569 |
Private submissions are only returned if the current user is an admin |
|
8486.18.8
by Abel Deuring
implemented reviewer's comments |
570 |
or the owner of the private submission. |
8486.18.2
by Abel Deuring
changed method HWSubmissionSet._userHasAccessStormClause() into a function; privacy check added in HWSubmissionBugSet.submissionsForBug() added; tests added. |
571 |
|
572 |
>>> submission = hw_submission_set.getBySubmissionKey( |
|
573 |
... u'private-submission', sample_person) |
|
574 |
>>> submission_bug_set.create(submission, bug_one) |
|
575 |
<HWSubmissionBug at... |
|
576 |
>>> for submission in submission_bug_set.submissionsForBug( |
|
577 |
... bug_one, user=sample_person): |
|
578 |
... print submission.submission_key |
|
579 |
private-submission |
|
580 |
unique-id-5 |
|
581 |
||
582 |
>>> for submission in submission_bug_set.submissionsForBug( |
|
583 |
... bug_one, user=foobar): |
|
584 |
... print submission.submission_key |
|
585 |
private-submission |
|
586 |
unique-id-5 |
|
587 |
||
588 |
Other registered persons can see only public submissions... |
|
589 |
||
590 |
>>> for submission in submission_bug_set.submissionsForBug( |
|
591 |
... bug_one, user=no_priv): |
|
592 |
... print submission.submission_key |
|
593 |
unique-id-5 |
|
594 |
||
595 |
...as well as anonymous users. |
|
596 |
||
597 |
>>> for submission in submission_bug_set.submissionsForBug( |
|
598 |
... bug_one): |
|
599 |
... print submission.submission_key |
|
600 |
unique-id-5 |
|
601 |
||
602 |
Existing links can also be removed. |
|
8486.18.4
by Abel Deuring
more tests added. |
603 |
|
8486.18.2
by Abel Deuring
changed method HWSubmissionSet._userHasAccessStormClause() into a function; privacy check added in HWSubmissionBugSet.submissionsForBug() added; tests added. |
604 |
>>> submission_bug_set.remove(submission_no_owner, bug_one) |
605 |
>>> submission_bug_set.submissionsForBug(bug_one).count() |
|
606 |
0 |
|
607 |
||
608 |
>>> for submission in submission_bug_set.submissionsForBug( |
|
609 |
... bug_one, user=foobar): |
|
610 |
... print submission.submission_key |
|
611 |
private-submission |
|
612 |
||
613 |
||
7465.7.1
by Abel Deuring
search method for IHWSubmissionSet |
614 |
== General Search Method == |
615 |
||
7465.7.2
by Abel Deuring
implemented reviewer's comments |
616 |
IHWSubmissionSet.search() allows the look up of submissions which |
617 |
contain a specfic device, a specific driver or which are made for a |
|
7465.7.1
by Abel Deuring
search method for IHWSubmissionSet |
618 |
specific distribution or processor architecture. |
619 |
||
620 |
All parameters are optional; if none are given, all publicly visible |
|
621 |
submissions are returned. |
|
622 |
||
623 |
>>> for submission in hw_submission_set.search(): |
|
624 |
... print submission.submission_key |
|
625 |
test_submission_id_1 |
|
626 |
sample-submission |
|
627 |
unique-id-1 |
|
628 |
unique-id-2 |
|
629 |
unique-id-4 |
|
630 |
unique-id-5 |
|
631 |
||
7465.7.2
by Abel Deuring
implemented reviewer's comments |
632 |
If the parameter `user` is specified, private submissions from this user |
7465.7.1
by Abel Deuring
search method for IHWSubmissionSet |
633 |
are returned too. |
634 |
||
635 |
>>> for submission in hw_submission_set.search(user=sample_person): |
|
636 |
... print submission.submission_key |
|
637 |
test_submission_id_1 |
|
638 |
sample-submission |
|
639 |
unique-id-1 |
|
640 |
unique-id-2 |
|
7465.7.2
by Abel Deuring
implemented reviewer's comments |
641 |
private-submission |
7465.7.1
by Abel Deuring
search method for IHWSubmissionSet |
642 |
unique-id-4 |
643 |
unique-id-5 |
|
644 |
||
645 |
Admins have access to all submissions. |
|
646 |
||
647 |
>>> for submission in hw_submission_set.search(user=foobar): |
|
648 |
... print submission.submission_key |
|
649 |
test_submission_id_1 |
|
650 |
sample-submission |
|
651 |
unique-id-1 |
|
652 |
unique-id-2 |
|
7465.7.2
by Abel Deuring
implemented reviewer's comments |
653 |
private-submission |
7465.7.1
by Abel Deuring
search method for IHWSubmissionSet |
654 |
unique-id-4 |
655 |
unique-id-5 |
|
656 |
||
7465.7.2
by Abel Deuring
implemented reviewer's comments |
657 |
If a distribution is specified, only those submissions that were made |
658 |
for that distribution are returned. |
|
7465.7.1
by Abel Deuring
search method for IHWSubmissionSet |
659 |
|
7675.110.3
by Curtis Hovey
Ran the migration script to move registry code to lp.registry. |
660 |
>>> from lp.registry.interfaces.distribution import ( |
7465.7.1
by Abel Deuring
search method for IHWSubmissionSet |
661 |
... IDistributionSet) |
662 |
>>> distribution_set = getUtility(IDistributionSet) |
|
663 |
>>> ubuntu = distribution_set.getByName('ubuntu') |
|
664 |
>>> for submission in hw_submission_set.search(distribution=ubuntu): |
|
665 |
... print submission.submission_key |
|
666 |
sample-submission |
|
667 |
||
668 |
>>> debian = distribution_set.getByName('debian') |
|
669 |
>>> print hw_submission_set.search(distribution=debian).count() |
|
670 |
0 |
|
671 |
||
7465.7.2
by Abel Deuring
implemented reviewer's comments |
672 |
If an architecture is specified, only those submissions that were made |
673 |
for that architecture are returned. |
|
7465.7.1
by Abel Deuring
search method for IHWSubmissionSet |
674 |
|
675 |
>>> for submission in hw_submission_set.search(architecture='i386'): |
|
676 |
... print submission.submission_key |
|
677 |
sample-submission |
|
678 |
||
679 |
>>> print hw_submission_set.search(architecture='amd64').count() |
|
680 |
0 |
|
681 |
||
7658.5.114
by Stuart Bishop
Remove some debug cruft and earlier fixes that are now unnecessary |
682 |
|
7465.7.2
by Abel Deuring
implemented reviewer's comments |
683 |
If a device is specified, only those submissions that include |
684 |
the device are returned. |
|
7465.7.1
by Abel Deuring
search method for IHWSubmissionSet |
685 |
|
10234.3.3
by Curtis Hovey
Migrated hardward database to lp. Updated test_doc to run the hwddb test. |
686 |
>>> from lp.hardwaredb.interfaces.hwdb import HWBus, IHWDeviceSet |
7465.7.1
by Abel Deuring
search method for IHWSubmissionSet |
687 |
>>> device_set = getUtility(IHWDeviceSet) |
688 |
>>> msi_mainboard = device_set.getByDeviceID( |
|
689 |
... HWBus.SYSTEM, 'MSI', 'MS-7369') |
|
690 |
>>> for submission in hw_submission_set.search(device=msi_mainboard): |
|
691 |
... print submission.submission_key |
|
692 |
sample-submission |
|
693 |
||
7465.7.2
by Abel Deuring
implemented reviewer's comments |
694 |
If a driver is specified, only those submissions for that driver |
695 |
are returned. |
|
7465.7.1
by Abel Deuring
search method for IHWSubmissionSet |
696 |
|
10234.3.3
by Curtis Hovey
Migrated hardward database to lp. Updated test_doc to run the hwddb test. |
697 |
>>> from lp.hardwaredb.interfaces.hwdb import IHWDriverSet |
7465.7.1
by Abel Deuring
search method for IHWSubmissionSet |
698 |
>>> driver_set = getUtility(IHWDriverSet) |
699 |
>>> ehci_driver = driver_set.getByPackageAndName( |
|
700 |
... 'linux-image-2.6.24-19-generic', 'ehci_hcd') |
|
701 |
>>> for submission in hw_submission_set.search(driver=ehci_driver): |
|
702 |
... print submission.submission_key |
|
703 |
sample-submission |
|
7734.1.1
by Tom Berger
allow searching submissions by distroseries + doctests |
704 |
|
705 |
If a distroseries is specified, only submissions for that distroseries |
|
706 |
are returned. |
|
707 |
||
8400.1.2
by Tim Penhey
Move the c.l.testing.factory to lp.testing. |
708 |
>>> from lp.testing.factory import LaunchpadObjectFactory |
7734.1.1
by Tom Berger
allow searching submissions by distroseries + doctests |
709 |
>>> factory = LaunchpadObjectFactory() |
710 |
||
711 |
>>> warty = ubuntu['warty'] |
|
712 |
>>> warty_arch_series = factory.makeDistroArchSeries(distroseries=warty) |
|
713 |
>>> submission = factory.makeHWSubmission(distroarchseries=warty_arch_series) |
|
714 |
>>> for submission in hw_submission_set.search(distroseries=warty): |
|
715 |
... print submission.distroarchseries.distroseries.name |
|
716 |
warty |
|
717 |
||
718 |
It is also possible to search for a distroseries and architecture. |
|
719 |
||
11692.6.2
by Curtis Hovey
Use deglober to fixing simple glob imports in doctests. |
720 |
>>> from lp.soyuz.interfaces.processor import IProcessorFamilySet |
7734.1.1
by Tom Berger
allow searching submissions by distroseries + doctests |
721 |
>>> amd64 = getUtility(IProcessorFamilySet).getByName('amd64') |
722 |
>>> warty_amd64 = factory.makeDistroArchSeries( |
|
723 |
... distroseries=warty, architecturetag='amd64', |
|
724 |
... processorfamily=amd64) |
|
725 |
>>> submission = factory.makeHWSubmission(distroarchseries=warty_amd64) |
|
726 |
>>> for submission in hw_submission_set.search(distroseries=warty, architecture='amd64'): |
|
727 |
... print '%s %s ' % ( |
|
728 |
... submission.distroarchseries.distroseries.name, |
|
729 |
... submission.distroarchseries.architecturetag) |
|
730 |
warty amd64 |
|
7746.1.1
by Tom Berger
make it possible to filter submissions by owner |
731 |
|
732 |
And we can also search for submissions from a particular user. |
|
733 |
||
11692.6.2
by Curtis Hovey
Use deglober to fixing simple glob imports in doctests. |
734 |
>>> from lp.registry.interfaces.person import IPersonSet |
7746.1.1
by Tom Berger
make it possible to filter submissions by owner |
735 |
>>> owner = getUtility(IPersonSet).getByName('name12') |
736 |
>>> set(submission.owner.name for submission |
|
737 |
... in hw_submission_set.search(owner=owner)) |
|
738 |
set([u'name12']) |
|
7881.4.1
by Tom Berger
make it possible to get the hardware submissions for a person |
739 |
|
740 |
Alternatively, we can get the same result by looking at |
|
741 |
IPerson.hardware_submissions. |
|
742 |
||
743 |
>>> set(submission.owner.name for submission |
|
744 |
... in owner.hardware_submissions) |
|
745 |
set([u'name12']) |
|
746 |