Merge lp:~adeuring/launchpad/bug-438169-parse-sysfs-attr into lp:launchpad/db-devel
- bug-438169-parse-sysfs-attr
- Merge into db-devel
Proposed by
Abel Deuring
Status: | Merged |
---|---|
Approved by: | Graham Binns |
Approved revision: | no longer in the source branch. |
Merged at revision: | not available |
Proposed branch: | lp:~adeuring/launchpad/bug-438169-parse-sysfs-attr |
Merge into: | lp:launchpad/db-devel |
Diff against target: |
569 lines 8 files modified
lib/canonical/launchpad/database/__init__.py (+0/-2) lib/canonical/launchpad/doc/hwdb-device-tables.txt (+1/-1) lib/canonical/launchpad/scripts/hwdbsubmissions.py (+77/-0) lib/canonical/launchpad/scripts/tests/hardwaretest-udev.xml (+13/-4) lib/canonical/launchpad/scripts/tests/test_hwdb_submission_parser.py (+164/-0) lib/canonical/launchpad/zcml/hwdb.zcml (+23/-23) lib/canonical/launchpad/zcml/launchpadstatistic.zcml (+3/-3) lib/lp/code/model/tests/test_branchjob.py (+19/-0) |
To merge this branch: | bzr merge lp:~adeuring/launchpad/bug-438169-parse-sysfs-attr |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Graham Binns (community) | Approve | ||
Review via email: mp+12581@code.launchpad.net |
Commit message
Description of the change
To post a comment you must log in.
Revision history for this message
Abel Deuring (adeuring) wrote : | # |
Revision history for this message
Graham Binns (gmb) wrote : | # |
I'm happy for this to land with the following changes:
- Use dedent() in the tests to prevent ugly alignment issues.
- Clean up the leading braces of the dicts in the assertEqual() call as discussed on IRC.
review:
Approve
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'lib/canonical/launchpad/database/__init__.py' | |||
2 | --- lib/canonical/launchpad/database/__init__.py 2009-08-27 07:05:16 +0000 | |||
3 | +++ lib/canonical/launchpad/database/__init__.py 2009-09-29 11:33:15 +0000 | |||
4 | @@ -58,7 +58,6 @@ | |||
5 | 58 | from canonical.launchpad.database.personnotification import * | 58 | from canonical.launchpad.database.personnotification import * |
6 | 59 | from canonical.launchpad.database.packaging import * | 59 | from canonical.launchpad.database.packaging import * |
7 | 60 | from canonical.launchpad.database.librarian import * | 60 | from canonical.launchpad.database.librarian import * |
8 | 61 | from canonical.launchpad.database.launchpadstatistic import * | ||
9 | 62 | from canonical.launchpad.database.binaryandsourcepackagename import * | 61 | from canonical.launchpad.database.binaryandsourcepackagename import * |
10 | 63 | from canonical.launchpad.database.message import * | 62 | from canonical.launchpad.database.message import * |
11 | 64 | from canonical.launchpad.database.structuralsubscription import * | 63 | from canonical.launchpad.database.structuralsubscription import * |
12 | @@ -66,4 +65,3 @@ | |||
13 | 66 | from canonical.launchpad.database.temporaryblobstorage import * | 65 | from canonical.launchpad.database.temporaryblobstorage import * |
14 | 67 | from canonical.launchpad.database.emailaddress import * | 66 | from canonical.launchpad.database.emailaddress import * |
15 | 68 | from canonical.launchpad.database.oauth import * | 67 | from canonical.launchpad.database.oauth import * |
16 | 69 | from canonical.launchpad.database.hwdb import * | ||
17 | 70 | 68 | ||
18 | === modified file 'lib/canonical/launchpad/doc/hwdb-device-tables.txt' | |||
19 | --- lib/canonical/launchpad/doc/hwdb-device-tables.txt 2009-08-14 13:03:36 +0000 | |||
20 | +++ lib/canonical/launchpad/doc/hwdb-device-tables.txt 2009-09-29 11:33:15 +0000 | |||
21 | @@ -1486,7 +1486,7 @@ | |||
22 | 1486 | names. Note that the package name value None (used in older submissions) | 1486 | names. Note that the package name value None (used in older submissions) |
23 | 1487 | is not included. | 1487 | is not included. |
24 | 1488 | 1488 | ||
26 | 1489 | >>> from canonical.launchpad.database import HWDriver | 1489 | >>> from canonical.launchpad.database.hwdb import HWDriver |
27 | 1490 | >>> store.add(HWDriver(name='foo', package_name=None)) | 1490 | >>> store.add(HWDriver(name='foo', package_name=None)) |
28 | 1491 | <HWDriver at... | 1491 | <HWDriver at... |
29 | 1492 | >>> for package_name in driver_set.all_package_names(): | 1492 | >>> for package_name in driver_set.all_package_names(): |
30 | 1493 | 1493 | ||
31 | === modified file 'lib/canonical/launchpad/scripts/hwdbsubmissions.py' | |||
32 | --- lib/canonical/launchpad/scripts/hwdbsubmissions.py 2009-09-28 11:33:57 +0000 | |||
33 | +++ lib/canonical/launchpad/scripts/hwdbsubmissions.py 2009-09-29 11:33:15 +0000 | |||
34 | @@ -556,6 +556,82 @@ | |||
35 | 556 | dmi_data[record[0]] = record[1] | 556 | dmi_data[record[0]] = record[1] |
36 | 557 | return dmi_data | 557 | return dmi_data |
37 | 558 | 558 | ||
38 | 559 | def _parseSysfsAttributes(self, sysfs_node): | ||
39 | 560 | """Parse the <sysfs-attributes> node. | ||
40 | 561 | |||
41 | 562 | :return: A dictionary {path: attrs, ...} where path is the | ||
42 | 563 | path is the path of a sysfs directory, and where attrs | ||
43 | 564 | is a dictionary containing attribute names and values. | ||
44 | 565 | |||
45 | 566 | A sample of the input data: | ||
46 | 567 | |||
47 | 568 | P: /devices/LNXSYSTM:00/LNXPWRBN:00/input/input0 | ||
48 | 569 | A: modalias=input:b0019v0000p0001e0000-e0,1,k74,ramlsfw | ||
49 | 570 | A: uniq= | ||
50 | 571 | A: phys=LNXPWRBN/button/input0 | ||
51 | 572 | A: name=Power Button | ||
52 | 573 | |||
53 | 574 | P: /devices/LNXSYSTM:00/device:00/PNP0A08:00/device:03/input/input8 | ||
54 | 575 | A: modalias=input:b0019v0000p0006e0000-e0,1,kE0,E1,E3,F0,F1 | ||
55 | 576 | A: uniq= | ||
56 | 577 | A: phys=/video/input0 | ||
57 | 578 | A: name=Video Bus | ||
58 | 579 | |||
59 | 580 | Data for different devices is separated by empty lines. The data | ||
60 | 581 | for each device starts with a line 'P: /devices/LNXSYSTM...', | ||
61 | 582 | specifying the sysfs path of a device, followed by zero or more | ||
62 | 583 | lines of the form 'A: key=value' | ||
63 | 584 | """ | ||
64 | 585 | sysfs_lines = sysfs_node.text.split('\n') | ||
65 | 586 | sysfs_data = {} | ||
66 | 587 | attributes = None | ||
67 | 588 | |||
68 | 589 | for line_number, line in enumerate(sysfs_lines): | ||
69 | 590 | if len(line) == 0: | ||
70 | 591 | attributes = None | ||
71 | 592 | continue | ||
72 | 593 | record = line.split(': ', 1) | ||
73 | 594 | if len(record) != 2: | ||
74 | 595 | self._logError( | ||
75 | 596 | 'Line %i in <sysfs-attributes>: No valid key:value data: ' | ||
76 | 597 | '%r' % (line_number, line), | ||
77 | 598 | self.submission_key) | ||
78 | 599 | return None | ||
79 | 600 | |||
80 | 601 | key, value = record | ||
81 | 602 | if key == 'P': | ||
82 | 603 | if attributes is not None: | ||
83 | 604 | self._logError( | ||
84 | 605 | "Line %i in <sysfs-attributes>: duplicate 'P' line " | ||
85 | 606 | "found: %r" % (line_number, line), | ||
86 | 607 | self.submission_key) | ||
87 | 608 | return None | ||
88 | 609 | attributes = {} | ||
89 | 610 | sysfs_data[value] = attributes | ||
90 | 611 | elif key == 'A': | ||
91 | 612 | if attributes is None: | ||
92 | 613 | self._logError( | ||
93 | 614 | "Line %i in <sysfs-attributes>: Block for a device " | ||
94 | 615 | "does not start with 'P:': %r" % (line_number, line), | ||
95 | 616 | self.submission_key) | ||
96 | 617 | return None | ||
97 | 618 | attribute_data = value.split('=', 1) | ||
98 | 619 | if len(attribute_data) != 2: | ||
99 | 620 | self._logError( | ||
100 | 621 | 'Line %i in <sysfs-attributes>: Attribute line does ' | ||
101 | 622 | 'not contain key=value data: %r' | ||
102 | 623 | % (line_number, line), | ||
103 | 624 | self.submission_key) | ||
104 | 625 | return None | ||
105 | 626 | attributes[attribute_data[0]] = attribute_data[1] | ||
106 | 627 | else: | ||
107 | 628 | self._logError( | ||
108 | 629 | 'Line %i in <sysfs-attributes>: Unexpected key: %r' | ||
109 | 630 | % (line_number, line), | ||
110 | 631 | self.submission_key) | ||
111 | 632 | return None | ||
112 | 633 | return sysfs_data | ||
113 | 634 | |||
114 | 559 | def _setHardwareSectionParsers(self): | 635 | def _setHardwareSectionParsers(self): |
115 | 560 | self._parse_hardware_section = { | 636 | self._parse_hardware_section = { |
116 | 561 | 'hal': self._parseHAL, | 637 | 'hal': self._parseHAL, |
117 | @@ -563,6 +639,7 @@ | |||
118 | 563 | 'aliases': self._parseAliases, | 639 | 'aliases': self._parseAliases, |
119 | 564 | 'udev': self._parseUdev, | 640 | 'udev': self._parseUdev, |
120 | 565 | 'dmi': self._parseDmi, | 641 | 'dmi': self._parseDmi, |
121 | 642 | 'sysfs-attributes': self._parseSysfsAttributes, | ||
122 | 566 | } | 643 | } |
123 | 567 | 644 | ||
124 | 568 | def _parseHardware(self, hardware_node): | 645 | def _parseHardware(self, hardware_node): |
125 | 569 | 646 | ||
126 | === modified file 'lib/canonical/launchpad/scripts/tests/hardwaretest-udev.xml' | |||
127 | --- lib/canonical/launchpad/scripts/tests/hardwaretest-udev.xml 2009-09-14 09:16:45 +0000 | |||
128 | +++ lib/canonical/launchpad/scripts/tests/hardwaretest-udev.xml 2009-09-29 11:33:15 +0000 | |||
129 | @@ -184,10 +184,19 @@ | |||
130 | 184 | is stored in the same format as the DMI data: | 184 | is stored in the same format as the DMI data: |
131 | 185 | /path/to/file:filecontent | 185 | /path/to/file:filecontent |
132 | 186 | --> | 186 | --> |
137 | 187 | <sysfs-attributes>/sys/devices/pci0000:00/0000:00:1f.1/host3/target3:0:0/3:0:0:0/vendor:HL-DT-ST | 187 | <sysfs-attributes> |
138 | 188 | /sys/devices/pci0000:00/0000:00:1f.1/host3/target3:0:0/3:0:0:0/model:DVDRAM GSA-4083N | 188 | P: /devices/LNXSYSTM:00/LNXPWRBN:00/input/input0 |
139 | 189 | /sys/devices/pci0000:00/0000:00:1f.1/host3/target3:0:0/3:0:0:0/type:5 | 189 | A: modalias=input:b0019v0000p0001e0000-e0,1,k74,ramlsfw |
140 | 190 | </sysfs-attributes> | 190 | A: uniq= |
141 | 191 | A: phys=LNXPWRBN/button/input0 | ||
142 | 192 | A: name=Power Button | ||
143 | 193 | |||
144 | 194 | P: /devices/LNXSYSTM:00/device:00/PNP0A08:00/device:03/input/input8 | ||
145 | 195 | A: modalias=input:b0019v0000p0006e0000-e0,1,kE0,E1,E3,F0,F1,F2,F3,F4,F5,ramlsfw | ||
146 | 196 | A: uniq= | ||
147 | 197 | A: phys=/video/input0 | ||
148 | 198 | A: name=Video Bus | ||
149 | 199 | </sysfs-attributes> | ||
150 | 191 | 200 | ||
151 | 192 | <!-- processors: Data about processors installed in a system. | 201 | <!-- processors: Data about processors installed in a system. |
152 | 193 | The data is retrieved from /proc/cpuinfo. | 202 | The data is retrieved from /proc/cpuinfo. |
153 | 194 | 203 | ||
154 | === modified file 'lib/canonical/launchpad/scripts/tests/test_hwdb_submission_parser.py' | |||
155 | --- lib/canonical/launchpad/scripts/tests/test_hwdb_submission_parser.py 2009-09-28 12:35:40 +0000 | |||
156 | +++ lib/canonical/launchpad/scripts/tests/test_hwdb_submission_parser.py 2009-09-29 11:33:15 +0000 | |||
157 | @@ -11,6 +11,7 @@ | |||
158 | 11 | from datetime import datetime | 11 | from datetime import datetime |
159 | 12 | import logging | 12 | import logging |
160 | 13 | import os | 13 | import os |
161 | 14 | from textwrap import dedent | ||
162 | 14 | from unittest import TestCase, TestLoader | 15 | from unittest import TestCase, TestLoader |
163 | 15 | 16 | ||
164 | 16 | import pytz | 17 | import pytz |
165 | @@ -649,6 +650,169 @@ | |||
166 | 649 | parser.submission_key, | 650 | parser.submission_key, |
167 | 650 | "Line 1 in <dmi>: No valid key:value data: 'invalid line'") | 651 | "Line 1 in <dmi>: No valid key:value data: 'invalid line'") |
168 | 651 | 652 | ||
169 | 653 | def testSysfsAttributes(self): | ||
170 | 654 | """Test of SubmissionParser._parseSysfsAttributes(). | ||
171 | 655 | |||
172 | 656 | The content of the <sys-attributes> node is converted into | ||
173 | 657 | a dictionary. | ||
174 | 658 | """ | ||
175 | 659 | parser = SubmissionParser(self.log) | ||
176 | 660 | node = etree.fromstring(dedent(""" | ||
177 | 661 | <sysfs-attributes> | ||
178 | 662 | P: /devices/LNXSYSTM:00/LNXPWRBN:00/input/input0 | ||
179 | 663 | A: modalias=input:b0019v0000p0001e0000-e0,1,k74 | ||
180 | 664 | A: uniq= | ||
181 | 665 | A: phys=LNXPWRBN/button/input0 | ||
182 | 666 | A: name=Power Button | ||
183 | 667 | |||
184 | 668 | P: /devices/LNXSYSTM:00/device:00/PNP0A08:00/device:03 | ||
185 | 669 | A: uniq= | ||
186 | 670 | A: phys=/video/input0 | ||
187 | 671 | A: name=Video Bus | ||
188 | 672 | </sysfs-attributes> | ||
189 | 673 | """)) | ||
190 | 674 | result = parser._parseSysfsAttributes(node) | ||
191 | 675 | self.assertEqual( | ||
192 | 676 | { | ||
193 | 677 | '/devices/LNXSYSTM:00/LNXPWRBN:00/input/input0': { | ||
194 | 678 | 'modalias': 'input:b0019v0000p0001e0000-e0,1,k74', | ||
195 | 679 | 'uniq': '', | ||
196 | 680 | 'phys': 'LNXPWRBN/button/input0', | ||
197 | 681 | 'name': 'Power Button', | ||
198 | 682 | }, | ||
199 | 683 | '/devices/LNXSYSTM:00/device:00/PNP0A08:00/device:03': { | ||
200 | 684 | 'uniq': '', | ||
201 | 685 | 'phys': '/video/input0', | ||
202 | 686 | 'name': 'Video Bus', | ||
203 | 687 | }, | ||
204 | 688 | |||
205 | 689 | }, | ||
206 | 690 | result, | ||
207 | 691 | 'Invalid parsing result of <sysfs-attributes> node.') | ||
208 | 692 | |||
209 | 693 | def testSysfsAttributesLineWithoutKeyValueData(self): | ||
210 | 694 | """Test of SubmissionParser._parseSysfsAttributes(). | ||
211 | 695 | |||
212 | 696 | Lines not in key: value format are rejected. | ||
213 | 697 | """ | ||
214 | 698 | parser = SubmissionParser(self.log) | ||
215 | 699 | parser.submission_key = ( | ||
216 | 700 | 'Detect <sysfs-attributes> lines not in key:value format') | ||
217 | 701 | node = etree.fromstring(dedent(""" | ||
218 | 702 | <sysfs-attributes> | ||
219 | 703 | P: /devices/LNXSYSTM:00/LNXPWRBN:00/input/input0 | ||
220 | 704 | A: modalias=input:b0019v0000p0001e0000-e0,1,k74 | ||
221 | 705 | invalid line | ||
222 | 706 | </sysfs-attributes> | ||
223 | 707 | """)) | ||
224 | 708 | result = parser._parseSysfsAttributes(node) | ||
225 | 709 | self.assertEqual( | ||
226 | 710 | None, result, | ||
227 | 711 | 'Invalid parsing result of a <sysfs-attributes> node containing ' | ||
228 | 712 | 'a line not in key:value format.') | ||
229 | 713 | self.assertErrorMessage( | ||
230 | 714 | parser.submission_key, | ||
231 | 715 | "Line 3 in <sysfs-attributes>: No valid key:value data: " | ||
232 | 716 | "'invalid line'") | ||
233 | 717 | |||
234 | 718 | def testSysfsAttributesDuplicatePLine(self): | ||
235 | 719 | """Test of SubmissionParser._parseSysfsAttributes(). | ||
236 | 720 | |||
237 | 721 | A line starting with "P:" must be the first line of a device block. | ||
238 | 722 | """ | ||
239 | 723 | parser = SubmissionParser(self.log) | ||
240 | 724 | parser.submission_key = ( | ||
241 | 725 | 'Detect <sysfs-attributes> node with duplicate P: line') | ||
242 | 726 | node = etree.fromstring(dedent(""" | ||
243 | 727 | <sysfs-attributes> | ||
244 | 728 | P: /devices/LNXSYSTM:00/LNXPWRBN:00/input/input0 | ||
245 | 729 | A: modalias=input:b0019v0000p0001e0000-e0,1,k74 | ||
246 | 730 | P: /devices/LNXSYSTM:00/LNXPWRBN:00/input/input0 | ||
247 | 731 | </sysfs-attributes> | ||
248 | 732 | """)) | ||
249 | 733 | result = parser._parseSysfsAttributes(node) | ||
250 | 734 | self.assertEqual( | ||
251 | 735 | None, result, | ||
252 | 736 | 'Invalid parsing result of a <sysfs-attributes> node containing ' | ||
253 | 737 | 'a duplicate P: line.') | ||
254 | 738 | self.assertErrorMessage( | ||
255 | 739 | parser.submission_key, | ||
256 | 740 | "Line 3 in <sysfs-attributes>: duplicate 'P' line found: " | ||
257 | 741 | "'P: /devices/LNXSYSTM:00/LNXPWRBN:00/input/input0'") | ||
258 | 742 | |||
259 | 743 | def testSysfsAttributesNoPLineAtDeviceStart(self): | ||
260 | 744 | """Test of SubmissionParser._parseSysfsAttributes(). | ||
261 | 745 | |||
262 | 746 | The data for a device must start with a "P:" line. | ||
263 | 747 | """ | ||
264 | 748 | parser = SubmissionParser(self.log) | ||
265 | 749 | parser.submission_key = ( | ||
266 | 750 | 'Detect <sysfs-attributes> node without leading P: line') | ||
267 | 751 | node = etree.fromstring(dedent(""" | ||
268 | 752 | <sysfs-attributes> | ||
269 | 753 | A: modalias=input:b0019v0000p0001e0000-e0,1,k74 | ||
270 | 754 | </sysfs-attributes> | ||
271 | 755 | """)) | ||
272 | 756 | result = parser._parseSysfsAttributes(node) | ||
273 | 757 | self.assertEqual( | ||
274 | 758 | None, result, | ||
275 | 759 | 'Invalid parsing result of a <sysfs-attributes> node where a ' | ||
276 | 760 | 'device block does not start with a "P": line.') | ||
277 | 761 | self.assertErrorMessage( | ||
278 | 762 | parser.submission_key, | ||
279 | 763 | "Line 1 in <sysfs-attributes>: Block for a device does not " | ||
280 | 764 | "start with 'P:': " | ||
281 | 765 | "'A: modalias=input:b0019v0000p0001e0000-e0,1,k74'") | ||
282 | 766 | |||
283 | 767 | def testSysfsAttributesNoAttributeKeyValue(self): | ||
284 | 768 | """Test of SubmissionParser._parseSysfsAttributes(). | ||
285 | 769 | |||
286 | 770 | A line starting with "A:" must be in key=value format. | ||
287 | 771 | """ | ||
288 | 772 | parser = SubmissionParser(self.log) | ||
289 | 773 | parser.submission_key = ( | ||
290 | 774 | 'Detect <sysfs-attributes> node with A: line not in key=value ' | ||
291 | 775 | 'format') | ||
292 | 776 | node = etree.fromstring(dedent(""" | ||
293 | 777 | <sysfs-attributes> | ||
294 | 778 | P: /devices/LNXSYSTM:00/LNXPWRBN:00/input/input0 | ||
295 | 779 | A: equal sign is missing | ||
296 | 780 | </sysfs-attributes> | ||
297 | 781 | """)) | ||
298 | 782 | result = parser._parseSysfsAttributes(node) | ||
299 | 783 | self.assertEqual( | ||
300 | 784 | None, result, | ||
301 | 785 | 'Invalid parsing result of a <sysfs-attributes> node with A: ' | ||
302 | 786 | 'line not in key=value format.') | ||
303 | 787 | self.assertErrorMessage( | ||
304 | 788 | parser.submission_key, | ||
305 | 789 | "Line 2 in <sysfs-attributes>: Attribute line does not contain " | ||
306 | 790 | "key=value data: 'A: equal sign is missing'") | ||
307 | 791 | |||
308 | 792 | def testSysfsAttributesInvalidMainKey(self): | ||
309 | 793 | """Test of SubmissionParser._parseSysfsAttributes(). | ||
310 | 794 | |||
311 | 795 | All lines must start with "P:" or "A:". | ||
312 | 796 | """ | ||
313 | 797 | parser = SubmissionParser(self.log) | ||
314 | 798 | parser.submission_key = ( | ||
315 | 799 | 'Detect <sysfs-attributes> node with invalid main key.') | ||
316 | 800 | node = etree.fromstring(dedent(""" | ||
317 | 801 | <sysfs-attributes> | ||
318 | 802 | P: /devices/LNXSYSTM:00/LNXPWRBN:00/input/input0 | ||
319 | 803 | X: an invalid line | ||
320 | 804 | </sysfs-attributes> | ||
321 | 805 | """)) | ||
322 | 806 | result = parser._parseSysfsAttributes(node) | ||
323 | 807 | self.assertEqual( | ||
324 | 808 | None, result, | ||
325 | 809 | 'Invalid parsing result of a <sysfs-attributes> node containg ' | ||
326 | 810 | 'a line that does not start with "A:" or "P:".') | ||
327 | 811 | self.assertErrorMessage( | ||
328 | 812 | parser.submission_key, | ||
329 | 813 | "Line 2 in <sysfs-attributes>: Unexpected key: " | ||
330 | 814 | "'X: an invalid line'") | ||
331 | 815 | |||
332 | 652 | def testHardware(self): | 816 | def testHardware(self): |
333 | 653 | """The <hardware> tag is converted into a dictionary.""" | 817 | """The <hardware> tag is converted into a dictionary.""" |
334 | 654 | test = self | 818 | test = self |
335 | 655 | 819 | ||
336 | === modified file 'lib/canonical/launchpad/zcml/hwdb.zcml' | |||
337 | --- lib/canonical/launchpad/zcml/hwdb.zcml 2009-08-14 13:03:36 +0000 | |||
338 | +++ lib/canonical/launchpad/zcml/hwdb.zcml 2009-09-29 11:33:15 +0000 | |||
339 | @@ -44,7 +44,7 @@ | |||
340 | 44 | template="../templates/hwdb-submit-hardware-data.pt" | 44 | template="../templates/hwdb-submit-hardware-data.pt" |
341 | 45 | /> | 45 | /> |
342 | 46 | 46 | ||
344 | 47 | <class class="canonical.launchpad.database.HWSubmission"> | 47 | <class class="canonical.launchpad.database.hwdb.HWSubmission"> |
345 | 48 | <require | 48 | <require |
346 | 49 | permission="launchpad.View" | 49 | permission="launchpad.View" |
347 | 50 | interface="canonical.launchpad.interfaces.IHWSubmission" | 50 | interface="canonical.launchpad.interfaces.IHWSubmission" |
348 | @@ -78,18 +78,18 @@ | |||
349 | 78 | /> | 78 | /> |
350 | 79 | 79 | ||
351 | 80 | <securedutility | 80 | <securedutility |
353 | 81 | class="canonical.launchpad.database.HWSubmissionSet" | 81 | class="canonical.launchpad.database.hwdb.HWSubmissionSet" |
354 | 82 | provides="canonical.launchpad.interfaces.IHWSubmissionSet"> | 82 | provides="canonical.launchpad.interfaces.IHWSubmissionSet"> |
355 | 83 | <allow interface="canonical.launchpad.interfaces.IHWSubmissionSet" /> | 83 | <allow interface="canonical.launchpad.interfaces.IHWSubmissionSet" /> |
356 | 84 | </securedutility> | 84 | </securedutility> |
357 | 85 | 85 | ||
359 | 86 | <class class="canonical.launchpad.database.HWSystemFingerprint"> | 86 | <class class="canonical.launchpad.database.hwdb.HWSystemFingerprint"> |
360 | 87 | <allow | 87 | <allow |
361 | 88 | interface="canonical.launchpad.interfaces.IHWSystemFingerprint" /> | 88 | interface="canonical.launchpad.interfaces.IHWSystemFingerprint" /> |
362 | 89 | </class> | 89 | </class> |
363 | 90 | 90 | ||
364 | 91 | <securedutility | 91 | <securedutility |
366 | 92 | class="canonical.launchpad.database.HWSystemFingerprintSet" | 92 | class="canonical.launchpad.database.hwdb.HWSystemFingerprintSet" |
367 | 93 | provides="canonical.launchpad.interfaces.IHWSystemFingerprintSet"> | 93 | provides="canonical.launchpad.interfaces.IHWSystemFingerprintSet"> |
368 | 94 | <allow | 94 | <allow |
369 | 95 | interface="canonical.launchpad.interfaces.IHWSystemFingerprintSet" /> | 95 | interface="canonical.launchpad.interfaces.IHWSystemFingerprintSet" /> |
370 | @@ -109,18 +109,18 @@ | |||
371 | 109 | <allow attributes="__call__" /> | 109 | <allow attributes="__call__" /> |
372 | 110 | </class> | 110 | </class> |
373 | 111 | 111 | ||
375 | 112 | <class class="canonical.launchpad.database.HWVendorName"> | 112 | <class class="canonical.launchpad.database.hwdb.HWVendorName"> |
376 | 113 | <allow interface="canonical.launchpad.interfaces.IHWVendorName" /> | 113 | <allow interface="canonical.launchpad.interfaces.IHWVendorName" /> |
377 | 114 | <allow attributes="id" /> | 114 | <allow attributes="id" /> |
378 | 115 | </class> | 115 | </class> |
379 | 116 | 116 | ||
380 | 117 | <securedutility | 117 | <securedutility |
382 | 118 | class="canonical.launchpad.database.HWVendorNameSet" | 118 | class="canonical.launchpad.database.hwdb.HWVendorNameSet" |
383 | 119 | provides="canonical.launchpad.interfaces.IHWVendorNameSet"> | 119 | provides="canonical.launchpad.interfaces.IHWVendorNameSet"> |
384 | 120 | <allow interface="canonical.launchpad.interfaces.IHWVendorNameSet" /> | 120 | <allow interface="canonical.launchpad.interfaces.IHWVendorNameSet" /> |
385 | 121 | </securedutility> | 121 | </securedutility> |
386 | 122 | 122 | ||
388 | 123 | <class class="canonical.launchpad.database.HWVendorID"> | 123 | <class class="canonical.launchpad.database.hwdb.HWVendorID"> |
389 | 124 | <require | 124 | <require |
390 | 125 | permission="launchpad.View" | 125 | permission="launchpad.View" |
391 | 126 | interface="canonical.launchpad.interfaces.IHWVendorID" /> | 126 | interface="canonical.launchpad.interfaces.IHWVendorID" /> |
392 | @@ -133,12 +133,12 @@ | |||
393 | 133 | /> | 133 | /> |
394 | 134 | 134 | ||
395 | 135 | <securedutility | 135 | <securedutility |
397 | 136 | class="canonical.launchpad.database.HWVendorIDSet" | 136 | class="canonical.launchpad.database.hwdb.HWVendorIDSet" |
398 | 137 | provides="canonical.launchpad.interfaces.IHWVendorIDSet"> | 137 | provides="canonical.launchpad.interfaces.IHWVendorIDSet"> |
399 | 138 | <allow interface="canonical.launchpad.interfaces.IHWVendorIDSet" /> | 138 | <allow interface="canonical.launchpad.interfaces.IHWVendorIDSet" /> |
400 | 139 | </securedutility> | 139 | </securedutility> |
401 | 140 | 140 | ||
403 | 141 | <class class="canonical.launchpad.database.HWDevice"> | 141 | <class class="canonical.launchpad.database.hwdb.HWDevice"> |
404 | 142 | <require | 142 | <require |
405 | 143 | permission="launchpad.View" | 143 | permission="launchpad.View" |
406 | 144 | interface="canonical.launchpad.interfaces.IHWDevice" /> | 144 | interface="canonical.launchpad.interfaces.IHWDevice" /> |
407 | @@ -151,24 +151,24 @@ | |||
408 | 151 | /> | 151 | /> |
409 | 152 | 152 | ||
410 | 153 | <securedutility | 153 | <securedutility |
412 | 154 | class="canonical.launchpad.database.HWDeviceSet" | 154 | class="canonical.launchpad.database.hwdb.HWDeviceSet" |
413 | 155 | provides="canonical.launchpad.interfaces.IHWDeviceSet"> | 155 | provides="canonical.launchpad.interfaces.IHWDeviceSet"> |
414 | 156 | <allow interface="canonical.launchpad.interfaces.IHWDeviceSet" /> | 156 | <allow interface="canonical.launchpad.interfaces.IHWDeviceSet" /> |
415 | 157 | </securedutility> | 157 | </securedutility> |
416 | 158 | 158 | ||
418 | 159 | <class class="canonical.launchpad.database.HWDeviceNameVariant"> | 159 | <class class="canonical.launchpad.database.hwdb.HWDeviceNameVariant"> |
419 | 160 | <allow interface= | 160 | <allow interface= |
420 | 161 | "canonical.launchpad.interfaces.IHWDeviceNameVariant" /> | 161 | "canonical.launchpad.interfaces.IHWDeviceNameVariant" /> |
421 | 162 | </class> | 162 | </class> |
422 | 163 | 163 | ||
423 | 164 | <securedutility | 164 | <securedutility |
425 | 165 | class="canonical.launchpad.database.HWDeviceNameVariantSet" | 165 | class="canonical.launchpad.database.hwdb.HWDeviceNameVariantSet" |
426 | 166 | provides="canonical.launchpad.interfaces.IHWDeviceNameVariantSet"> | 166 | provides="canonical.launchpad.interfaces.IHWDeviceNameVariantSet"> |
427 | 167 | <allow interface= | 167 | <allow interface= |
428 | 168 | "canonical.launchpad.interfaces.IHWDeviceNameVariantSet" /> | 168 | "canonical.launchpad.interfaces.IHWDeviceNameVariantSet" /> |
429 | 169 | </securedutility> | 169 | </securedutility> |
430 | 170 | 170 | ||
432 | 171 | <class class="canonical.launchpad.database.HWDriver"> | 171 | <class class="canonical.launchpad.database.hwdb.HWDriver"> |
433 | 172 | <require | 172 | <require |
434 | 173 | permission="launchpad.View" | 173 | permission="launchpad.View" |
435 | 174 | interface="canonical.launchpad.interfaces.IHWDriver" /> | 174 | interface="canonical.launchpad.interfaces.IHWDriver" /> |
436 | @@ -181,13 +181,13 @@ | |||
437 | 181 | /> | 181 | /> |
438 | 182 | 182 | ||
439 | 183 | <securedutility | 183 | <securedutility |
441 | 184 | class="canonical.launchpad.database.HWDriverSet" | 184 | class="canonical.launchpad.database.hwdb.HWDriverSet" |
442 | 185 | provides="canonical.launchpad.interfaces.IHWDriverSet"> | 185 | provides="canonical.launchpad.interfaces.IHWDriverSet"> |
443 | 186 | <allow | 186 | <allow |
444 | 187 | interface="canonical.launchpad.interfaces.IHWDriverSet" /> | 187 | interface="canonical.launchpad.interfaces.IHWDriverSet" /> |
445 | 188 | </securedutility> | 188 | </securedutility> |
446 | 189 | 189 | ||
448 | 190 | <class class="canonical.launchpad.database.HWDriverName"> | 190 | <class class="canonical.launchpad.database.hwdb.HWDriverName"> |
449 | 191 | <require | 191 | <require |
450 | 192 | permission="launchpad.View" | 192 | permission="launchpad.View" |
451 | 193 | interface="canonical.launchpad.interfaces.IHWDriverName" /> | 193 | interface="canonical.launchpad.interfaces.IHWDriverName" /> |
452 | @@ -199,7 +199,7 @@ | |||
453 | 199 | parent_utility="canonical.launchpad.interfaces.IHWDBApplication" | 199 | parent_utility="canonical.launchpad.interfaces.IHWDBApplication" |
454 | 200 | /> | 200 | /> |
455 | 201 | 201 | ||
457 | 202 | <class class="canonical.launchpad.database.HWDriverPackageName"> | 202 | <class class="canonical.launchpad.database.hwdb.HWDriverPackageName"> |
458 | 203 | <require | 203 | <require |
459 | 204 | permission="launchpad.View" | 204 | permission="launchpad.View" |
460 | 205 | interface="canonical.launchpad.interfaces.IHWDriverPackageName" /> | 205 | interface="canonical.launchpad.interfaces.IHWDriverPackageName" /> |
461 | @@ -211,20 +211,20 @@ | |||
462 | 211 | parent_utility="canonical.launchpad.interfaces.IHWDBApplication" | 211 | parent_utility="canonical.launchpad.interfaces.IHWDBApplication" |
463 | 212 | /> | 212 | /> |
464 | 213 | 213 | ||
466 | 214 | <class class="canonical.launchpad.database.HWDeviceDriverLink"> | 214 | <class class="canonical.launchpad.database.hwdb.HWDeviceDriverLink"> |
467 | 215 | <allow | 215 | <allow |
468 | 216 | interface="canonical.launchpad.interfaces.IHWDeviceDriverLink" /> | 216 | interface="canonical.launchpad.interfaces.IHWDeviceDriverLink" /> |
469 | 217 | <allow attributes="id" /> | 217 | <allow attributes="id" /> |
470 | 218 | </class> | 218 | </class> |
471 | 219 | 219 | ||
472 | 220 | <securedutility | 220 | <securedutility |
474 | 221 | class="canonical.launchpad.database.HWDeviceDriverLinkSet" | 221 | class="canonical.launchpad.database.hwdb.HWDeviceDriverLinkSet" |
475 | 222 | provides="canonical.launchpad.interfaces.IHWDeviceDriverLinkSet"> | 222 | provides="canonical.launchpad.interfaces.IHWDeviceDriverLinkSet"> |
476 | 223 | <allow | 223 | <allow |
477 | 224 | interface="canonical.launchpad.interfaces.IHWDeviceDriverLinkSet" /> | 224 | interface="canonical.launchpad.interfaces.IHWDeviceDriverLinkSet" /> |
478 | 225 | </securedutility> | 225 | </securedutility> |
479 | 226 | 226 | ||
481 | 227 | <class class="canonical.launchpad.database.HWDeviceClass"> | 227 | <class class="canonical.launchpad.database.hwdb.HWDeviceClass"> |
482 | 228 | <require permission="launchpad.View" | 228 | <require permission="launchpad.View" |
483 | 229 | interface="canonical.launchpad.interfaces.IHWDeviceClass" /> | 229 | interface="canonical.launchpad.interfaces.IHWDeviceClass" /> |
484 | 230 | </class> | 230 | </class> |
485 | @@ -242,7 +242,7 @@ | |||
486 | 242 | interface="canonical.launchpad.interfaces.IHWDeviceClassSet" /> | 242 | interface="canonical.launchpad.interfaces.IHWDeviceClassSet" /> |
487 | 243 | </securedutility> | 243 | </securedutility> |
488 | 244 | 244 | ||
490 | 245 | <class class="canonical.launchpad.database.HWSubmissionDevice"> | 245 | <class class="canonical.launchpad.database.hwdb.HWSubmissionDevice"> |
491 | 246 | <require | 246 | <require |
492 | 247 | permission="launchpad.View" | 247 | permission="launchpad.View" |
493 | 248 | interface="canonical.launchpad.interfaces.IHWSubmissionDevice" /> | 248 | interface="canonical.launchpad.interfaces.IHWSubmissionDevice" /> |
494 | @@ -255,20 +255,20 @@ | |||
495 | 255 | /> | 255 | /> |
496 | 256 | 256 | ||
497 | 257 | <securedutility | 257 | <securedutility |
499 | 258 | class="canonical.launchpad.database.HWSubmissionDeviceSet" | 258 | class="canonical.launchpad.database.hwdb.HWSubmissionDeviceSet" |
500 | 259 | provides="canonical.launchpad.interfaces.IHWSubmissionDeviceSet"> | 259 | provides="canonical.launchpad.interfaces.IHWSubmissionDeviceSet"> |
501 | 260 | <allow | 260 | <allow |
502 | 261 | interface="canonical.launchpad.interfaces.IHWSubmissionDeviceSet" /> | 261 | interface="canonical.launchpad.interfaces.IHWSubmissionDeviceSet" /> |
503 | 262 | </securedutility> | 262 | </securedutility> |
504 | 263 | 263 | ||
506 | 264 | <class class="canonical.launchpad.database.HWSubmissionBug"> | 264 | <class class="canonical.launchpad.database.hwdb.HWSubmissionBug"> |
507 | 265 | <allow | 265 | <allow |
508 | 266 | interface="canonical.launchpad.interfaces.IHWSubmissionBug" /> | 266 | interface="canonical.launchpad.interfaces.IHWSubmissionBug" /> |
509 | 267 | <allow attributes="id" /> | 267 | <allow attributes="id" /> |
510 | 268 | </class> | 268 | </class> |
511 | 269 | 269 | ||
512 | 270 | <securedutility | 270 | <securedutility |
514 | 271 | class="canonical.launchpad.database.HWSubmissionBugSet" | 271 | class="canonical.launchpad.database.hwdb.HWSubmissionBugSet" |
515 | 272 | provides="canonical.launchpad.interfaces.IHWSubmissionBugSet"> | 272 | provides="canonical.launchpad.interfaces.IHWSubmissionBugSet"> |
516 | 273 | <allow | 273 | <allow |
517 | 274 | interface="canonical.launchpad.interfaces.IHWSubmissionBugSet" /> | 274 | interface="canonical.launchpad.interfaces.IHWSubmissionBugSet" /> |
518 | 275 | 275 | ||
519 | === modified file 'lib/canonical/launchpad/zcml/launchpadstatistic.zcml' | |||
520 | --- lib/canonical/launchpad/zcml/launchpadstatistic.zcml 2009-09-18 13:24:29 +0000 | |||
521 | +++ lib/canonical/launchpad/zcml/launchpadstatistic.zcml 2009-09-29 11:33:15 +0000 | |||
522 | @@ -9,14 +9,14 @@ | |||
523 | 9 | i18n_domain="launchpad"> | 9 | i18n_domain="launchpad"> |
524 | 10 | 10 | ||
525 | 11 | <!-- LaunchpadStatistic --> | 11 | <!-- LaunchpadStatistic --> |
528 | 12 | <class class="canonical.launchpad.database.LaunchpadStatistic"> | 12 | <class class="canonical.launchpad.database.launchpadstatistic.LaunchpadStatistic"> |
529 | 13 | <allow interface="canonical.launchpad.interfaces.ILaunchpadStatistic" /> | 13 | <allow interface="canonical.launchpad.interfaces.launchpadstatistic.ILaunchpadStatistic" /> |
530 | 14 | </class> | 14 | </class> |
531 | 15 | 15 | ||
532 | 16 | 16 | ||
533 | 17 | <!-- LaunchpadStatisticSet --> | 17 | <!-- LaunchpadStatisticSet --> |
534 | 18 | <securedutility | 18 | <securedutility |
536 | 19 | class="canonical.launchpad.database.LaunchpadStatisticSet" | 19 | class="canonical.launchpad.database.launchpadstatistic.LaunchpadStatisticSet" |
537 | 20 | provides="canonical.launchpad.interfaces.ILaunchpadStatisticSet"> | 20 | provides="canonical.launchpad.interfaces.ILaunchpadStatisticSet"> |
538 | 21 | <allow interface="canonical.launchpad.interfaces.ILaunchpadStatisticSet" /> | 21 | <allow interface="canonical.launchpad.interfaces.ILaunchpadStatisticSet" /> |
539 | 22 | </securedutility> | 22 | </securedutility> |
540 | 23 | 23 | ||
541 | === modified file 'lib/lp/code/model/tests/test_branchjob.py' | |||
542 | --- lib/lp/code/model/tests/test_branchjob.py 2009-08-13 07:00:48 +0000 | |||
543 | +++ lib/lp/code/model/tests/test_branchjob.py 2009-09-29 11:33:15 +0000 | |||
544 | @@ -957,6 +957,25 @@ | |||
545 | 957 | entry = entries[0] | 957 | entry = entries[0] |
546 | 958 | self.assertEqual(pot_path, entry.path) | 958 | self.assertEqual(pot_path, entry.path) |
547 | 959 | 959 | ||
548 | 960 | def test_init_translation_file_lists_skip_dirs(self): | ||
549 | 961 | # The method _init_translation_file_lists extracts all translation | ||
550 | 962 | # files from the branch but does not add changed directories to the | ||
551 | 963 | # template_files_changed and translation_files_changed lists . | ||
552 | 964 | pot_path = u"subdir/foo.pot" | ||
553 | 965 | pot_content = self.factory.getUniqueString() | ||
554 | 966 | po_path = u"subdir/foo.po" | ||
555 | 967 | po_content = self.factory.getUniqueString() | ||
556 | 968 | self._makeBranchWithTreeAndFiles(((pot_path, pot_content), | ||
557 | 969 | (po_path, po_content))) | ||
558 | 970 | self._makeProductSeries(TranslationsBranchImportMode.NO_IMPORT) | ||
559 | 971 | job = RosettaUploadJob.create(self.branch, NULL_REVISION, True) | ||
560 | 972 | job._init_translation_file_lists() | ||
561 | 973 | |||
562 | 974 | self.assertEqual([(pot_path, pot_content)], | ||
563 | 975 | job.template_files_changed) | ||
564 | 976 | self.assertEqual([(po_path, po_content)], | ||
565 | 977 | job.translation_files_changed) | ||
566 | 978 | |||
567 | 960 | def test_upload_xpi_template(self): | 979 | def test_upload_xpi_template(self): |
568 | 961 | # XPI templates are indentified by a special name. They are imported | 980 | # XPI templates are indentified by a special name. They are imported |
569 | 962 | # like POT files. | 981 | # like POT files. |
This branch adds a method _parseSysfsAttr ibutes to the class SubmisisonParser.
The HWDB client in Karmic will no longer submit data from HAL; instead the data will come from udev, the content from some sysfs files etc. The new method parses the content from the new XML node <sysfs-attributes>.
Additonially I changed the content of the sample submission file l/c/l/scripts/ tests/hardwaret est-udev. xml to reflect the real content sent by the HWDB client.
test: ./bin/test -t test_hwdb_ submission_ parser
= Launchpad lint =
Checking for conflicts. and issues in doctests and templates.
Running jslint, xmllint, pyflakes, and pylint.
Using normal rules.
Linting changed files: /launchpad/ scripts/ hwdbsubmissions .py /launchpad/ scripts/ tests/hardwaret est-udev. xml /launchpad/ scripts/ tests/test_ hwdb_submission _parser. py
lib/canonical
lib/canonical
lib/canonical
== Pyflakes notices ==
lib/canonical/ launchpad/ scripts/ hwdbsubmissions .py
22: redefinition of unused 'etree' from line 20
lib/canonical/ launchpad/ scripts/ tests/test_ hwdb_submission _parser. py
10: redefinition of unused 'etree' from line 8
== Pylint notices ==
lib/canonical/ launchpad/ scripts/ hwdbsubmissions .py cElementTree' (No module named etree)
20: [F0401] Unable to import 'xml.etree.
lib/canonical/ launchpad/ scripts/ tests/test_ hwdb_submission _parser. py cElementTree' (No module named etree)
8: [F0401] Unable to import 'xml.etree.
These messages are not related to the new methods.