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

Subscribers

People subscribed via source and target branches