Merge ~sylvain-pineau/plainbox-provider-resource:resource_improv into plainbox-provider-resource:master

Proposed by Sylvain Pineau
Status: Merged
Approved by: Sylvain Pineau
Approved revision: 6a1cb507303f11fbb0fa63752fb4036cdfa42e7b
Merged at revision: deb30dde2d9451f21fb690b3647980d6d1394592
Proposed branch: ~sylvain-pineau/plainbox-provider-resource:resource_improv
Merge into: plainbox-provider-resource:master
Diff against target: 123 lines (+3/-89)
2 files modified
dev/null (+0/-72)
jobs/resource.pxu (+3/-17)
Reviewer Review Type Date Requested Status
Jonathan Cave (community) Approve
Review via email: mp+390137@code.launchpad.net

Description of the change

Speed and mem improvements for two major resources jobs, executable and package.

package only lists the deb package names
executable only lists the executable names, output is piped to `sort -u`

The package fallback execution on core just listing plainbox 0.1 is also removed since checkbox can properly handle empty resource objects.
Tested here: https://certification.canonical.com/hardware/201202-10584/submission/179550/

Finally staging/udev is gone

To post a comment you must log in.
Revision history for this message
Jonathan Cave (jocave) wrote :

If they aren't used then I'm fine with them being removed, +1

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/bin/udev2resource.py b/bin/udev2resource.py
2deleted file mode 100755
3index d4999ae..0000000
4--- a/bin/udev2resource.py
5+++ /dev/null
6@@ -1,72 +0,0 @@
7-#!/usr/bin/env python3
8-# This file is part of Checkbox.
9-#
10-# Copyright 2014 Canonical Ltd.
11-# Written by:
12-# Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
13-#
14-# Checkbox is free software: you can redistribute it and/or modify
15-# it under the terms of the GNU General Public License version 3,
16-# as published by the Free Software Foundation.
17-#
18-# Checkbox is distributed in the hope that it will be useful,
19-# but WITHOUT ANY WARRANTY; without even the implied warranty of
20-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21-# GNU General Public License for more details.
22-#
23-# You should have received a copy of the GNU General Public License
24-# along with Checkbox. If not, see <http://www.gnu.org/licenses/>.
25-"""
26-udev2resource.py -- udev to plainbox resource converter
27-=======================================================
28-
29-This script converts the output of 'udev info --export-db' into a RFC822-esque
30-PlainBox resource syntax. It handles the P:, N:, E:, S: and L: "directives"
31-"""
32-
33-import sys
34-import re
35-
36-
37-def udev2resource(in_stream, out_stream):
38- """
39- Convert the output of 'udev info --export-db' to RFC822 records.
40-
41- :param in_stream:
42- Input stream to process
43- :param out_stream:
44- Output stream to process
45-
46- The syntax is not documented anywhere that I could find but based on simple
47- experiments it looks like a sequence of lines starting with a one
48- letter-code followed by a colon and a value.
49-
50- The following fields are recognized:
51-
52- 'P' - device path relative to /sysfs
53- 'N' - device path relative to /dev
54- 'E' - a key-value attribute
55- 'S' - symlink path relative to /dev
56- 'L' - unknown field
57- """
58- symlink_count = 0
59- for line in in_stream:
60- line = line.rstrip()
61- if line == '':
62- symlink_count = 0
63- elif line.startswith("P: "):
64- line = line.replace("P: ", "path: ", 1)
65- elif line.startswith("N: "):
66- line = line.replace("N: ", "name: ", 1)
67- elif line.startswith("E: "):
68- line = re.sub("E: ([A-Za-z0-9_]+)=", "attr_\\1: ", line)
69- elif line.startswith("S: "):
70- line = re.sub("S: ", "symlink_{}: ".format(symlink_count), line)
71- symlink_count += 1
72- elif line.startswith("L: "):
73- line = line.replace("L: ", "l_something: ", 1)
74- print(line, file=out_stream)
75-
76-
77-if __name__ == '__main__':
78- udev2resource(sys.stdin, sys.stdout)
79diff --git a/jobs/resource.pxu b/jobs/resource.pxu
80index 0022978..115224e 100644
81--- a/jobs/resource.pxu
82+++ b/jobs/resource.pxu
83@@ -112,10 +112,8 @@ id: package
84 estimated_duration: 1.16
85 plugin: resource
86 command:
87- # shellcheck disable=SC2016
88- dpkg-query -W -f='name: ${Package}\nversion: ${Version}\n\n' || \
89- echo -e 'name: plainbox\nversion: 0.1\n\n' |\
90- awk 'BEGIN {RS = ""; FS = "\n"}{print $1; print $2; print "" }'
91+ # shellcheck disable=SC2016
92+ dpkg-query -W -f='name: ${Package}\n\n' || true
93 _description: Generates a list of packages
94 _summary: Collect information about installed software packages
95
96@@ -125,8 +123,7 @@ plugin: resource
97 _summary: Enumerate available system executables
98 _description: Generates a resource for all available executables
99 command:
100- xargs -n1 -d: <<< "$PATH" | xargs -I{} find -H {} -maxdepth 1 -xtype f -executable -printf "name: %f\nlocation: %h\n\n"
101- true
102+ xargs -n1 -d: <<< "$PATH" | xargs -I{} find -H {} -maxdepth 1 -xtype f -executable -printf "name: %f\n\n" | sort -u | awk '{print}' ORS='\n\n' || true
103
104 id: device
105 estimated_duration: 0.48
106@@ -142,17 +139,6 @@ command: udev_resource.py -f PARTITION || true
107 _description: Creates removable partitions info from udev
108 _summary: Collect removable partitions info from udev
109
110-id: staging/udev
111-estimated_duration: 1.1
112-plugin: resource
113-shell: /bin/sh
114-command: udevadm info --export-db | udev2resource.py
115-_summary: Collect unfiltered udev data
116-_description:
117- This job collects the udev database in mostly raw format. The only
118- transformations applied are basic changes to make the format compatible with
119- RFC822 syntax required by PlainBox.
120-
121 id: dmi_present
122 estimated_duration: 0.02
123 plugin: resource

Subscribers

People subscribed via source and target branches