Merge lp:~kissiel/checkbox/embedded-providers into lp:checkbox

Proposed by Maciej Kisielewski
Status: Merged
Approved by: Sylvain Pineau
Approved revision: 3395
Merged at revision: 3400
Proposed branch: lp:~kissiel/checkbox/embedded-providers
Merge into: lp:checkbox
Diff against target: 125 lines (+101/-2)
2 files modified
checkbox-touch/py/checkbox_touch.py (+9/-2)
checkbox-touch/py/embedded_providers.py (+92/-0)
To merge this branch: bzr merge lp:~kissiel/checkbox/embedded-providers
Reviewer Review Type Date Requested Status
Sylvain Pineau (community) Approve
Zygmunt Krynicki (community) Needs Fixing
Review via email: mp+240832@code.launchpad.net

Description of the change

This MR adds option to load providers supplied with checkbox-touch app.

d7fc3cf checkbox-touch: add loading providers from '$APP_DIR/providers'
f5f2ec2 plainbox:providers:special: add loading of embedded providers

To post a comment you must log in.
Revision history for this message
Zygmunt Krynicki (zyga) wrote :

Hi (sigh, lost comments)

Please convert this to a PlugIn and use FsPlugInCollection instead. We have lots of goodies there and I'd like to make sure all things like that are handled via the plugin system.

The FileSystemPlugInCollection can be used as-is, just pass the correct filters to find manage.py and disable recursion. You will want to write a PlugIn subclass that knows how to load the thing from disk though.

Otherwise ok

review: Needs Fixing
Revision history for this message
Sylvain Pineau (sylvain-pineau) wrote :

+1 for the new plugin mechanism. thanks

review: Approve
Revision history for this message
Daniel Manrique (roadmr) wrote :
Download full text (11.8 KiB)

The attempt to merge lp:~kissiel/checkbox/embedded-providers into lp:checkbox failed. Below is the output from the failed tests.

[precise] starting container
[precise] (timing) 0.06user 0.01system 0:05.20elapsed 1%CPU (0avgtext+0avgdata 7860maxresident)k
[precise] (timing) 0inputs+32outputs (0major+6064minor)pagefaults 0swaps
[precise] provisioning container
[precise] (timing) 39.39user 10.58system 1:31.39elapsed 54%CPU (0avgtext+0avgdata 51368maxresident)k
[precise] (timing) 0inputs+16424outputs (0major+4463039minor)pagefaults 0swaps
[precise-testing] Starting tests...
Found a test script: ./checkbox-gui/requirements/container-tests-checkbox-gui-build
[precise-testing] container-tests-checkbox-gui-build: PASS
[precise-testing] (timing) 30.23user 2.06system 0:32.91elapsed 98%CPU (0avgtext+0avgdata 116392maxresident)k
[precise-testing] (timing) 0inputs+4224outputs (0major+478228minor)pagefaults 0swaps
Found a test script: ./checkbox-ng/requirements/container-tests-checkbox-ng-unit
[precise-testing] container-tests-checkbox-ng-unit: FAIL
[precise-testing] stdout: http://paste.ubuntu.com/8948332/
[precise-testing] stderr: http://paste.ubuntu.com/8948333/
[precise-testing] (timing) Command exited with non-zero status 1
[precise-testing] (timing) 0.44user 0.13system 0:00.60elapsed 95%CPU (0avgtext+0avgdata 35356maxresident)k
[precise-testing] (timing) 0inputs+2456outputs (0major+19110minor)pagefaults 0swaps
Found a test script: ./checkbox-support/requirements/container-tests-checkbox-support
[precise-testing] container-tests-checkbox-support: PASS
[precise-testing] (timing) 16.21user 0.15system 0:16.65elapsed 98%CPU (0avgtext+0avgdata 83084maxresident)k
[precise-testing] (timing) 0inputs+1096outputs (0major+31256minor)pagefaults 0swaps
Found a test script: ./checkbox-touch/requirements/container-tests-touch-unit-tests
[precise-testing] container-tests-touch-unit-tests: PASS
[precise-testing] (timing) 0.00user 0.00system 0:00.02elapsed 44%CPU (0avgtext+0avgdata 2016maxresident)k
[precise-testing] (timing) 0inputs+8outputs (0major+2344minor)pagefaults 0swaps
Found a test script: ./plainbox/plainbox/impl/providers/categories/requirements/container-tests-provider-categories
[precise-testing] container-tests-provider-categories: FAIL
[precise-testing] stdout:
[precise-testing] stderr: http://paste.ubuntu.com/8948335/
[precise-testing] (timing) Command exited with non-zero status 1
[precise-testing] (timing) 0.13user 0.03system 0:00.18elapsed 92%CPU (0avgtext+0avgdata 12584maxresident)k
[precise-testing] (timing) 0inputs+176outputs (0major+5645minor)pagefaults 0swaps
Found a test script: ./plainbox/requirements/001-container-tests-plainbox-egg-info
[precise-testing] 001-container-tests-plainbox-egg-info: PASS
[precise-testing] (timing) 0.15user 0.04system 0:00.21elapsed 92%CPU (0avgtext+0avgdata 10492maxresident)k
[precise-testing] (timing) 0inputs+88outputs (0major+4979minor)pagefaults 0swaps
Found a test script: ./plainbox/requirements/container-tests-plainbox
[precise-testing] container-tests-plainbox: FAIL
[precise-testing] stdout: http://paste.ubuntu...

3394. By Maciej Kisielewski

checkbox-touch: add checkbox-touch custom providers

This patch adds manage.py providers for checkbox-touch

3395. By Maciej Kisielewski

checkbox-touch: add loading providers from '$APP_DIR/providers'

This patch makes checkbox-touch load providers that were supplied in
$APP_DIR/providers.

Revision history for this message
Maciej Kisielewski (kissiel) wrote :

Moved embedded providers to be checkbox-touch only.

Revision history for this message
Sylvain Pineau (sylvain-pineau) wrote :

Now we have two python files in checkbox-touch...

But +1 for solving the dependency on python 3.3+ this way

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'checkbox-touch/py/checkbox_touch.py'
2--- checkbox-touch/py/checkbox_touch.py 2014-11-05 10:56:15 +0000
3+++ checkbox-touch/py/checkbox_touch.py 2014-11-12 03:15:44 +0000
4@@ -48,6 +48,7 @@
5 from plainbox.impl.providers.special import get_categories
6 from plainbox.impl.providers.special import get_stubbox
7 from plainbox.impl.providers.v1 import all_providers
8+from embedded_providers import EmbeddedProvider1PlugInCollection
9 from plainbox.impl.runner import JobRunner
10 from plainbox.impl.secure.origin import Origin
11 from plainbox.impl.secure.qualifiers import FieldQualifier
12@@ -684,8 +685,14 @@
13 'com.canonical.certification.checkbox-touch'))
14
15 def _get_default_providers(self):
16- all_providers.load()
17- return [get_stubbox(), get_categories()]
18+ providers_collection = all_providers.get_all_plugin_objects()
19+ # when running on ubuntu-touch device, APP_DIR env var is present
20+ # and points to touch application top directory
21+ path = os.path.join(os.path.expandvars('$APP_DIR'), 'providers')
22+ if os.path.exists(path):
23+ embedded_providers = EmbeddedProvider1PlugInCollection(path)
24+ providers_collection += embedded_providers.get_all_plugin_objects()
25+ return providers_collection
26
27
28 def bootstrap():
29
30=== added file 'checkbox-touch/py/embedded_providers.py'
31--- checkbox-touch/py/embedded_providers.py 1970-01-01 00:00:00 +0000
32+++ checkbox-touch/py/embedded_providers.py 2014-11-12 03:15:44 +0000
33@@ -0,0 +1,92 @@
34+# This file is part of Checkbox.
35+#
36+# Copyright 2014 Canonical Ltd.
37+# Written by:
38+# Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
39+# Maciej Kisielewski <maciej.kisielewski@canonical.com>
40+#
41+# Checkbox is free software: you can redistribute it and/or modify
42+# it under the terms of the GNU General Public License version 3,
43+# as published by the Free Software Foundation.
44+#
45+# Checkbox is distributed in the hope that it will be useful,
46+# but WITHOUT ANY WARRANTY; without even the implied warranty of
47+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
48+# GNU General Public License for more details.
49+#
50+# You should have received a copy of the GNU General Public License
51+# along with Checkbox. If not, see <http://www.gnu.org/licenses/>.
52+"""
53+:mod:`embedded_providers` -- Checkbox-touch-only providers
54+===============================================================
55+
56+This module contains custom providers used by Checkbox-touch
57+"""
58+from importlib.machinery import SourceFileLoader
59+import logging
60+import os
61+
62+from plainbox.abc import IProvider1, IProviderBackend1
63+from plainbox.impl.secure.plugins import FsPlugInCollection
64+from plainbox.impl.secure.providers.v1 import Provider1
65+from plainbox.impl.secure.providers.v1 import Provider1Definition
66+from plainbox.impl.secure.providers.v1 import Provider1PlugIn
67+from plainbox.impl.secure.config import Unset
68+
69+
70+class ManagePyProvider1PlugIn(Provider1PlugIn):
71+ """
72+ Provider1PlugIn that is built from manage.py file.
73+ """
74+
75+ def __init__(self, filename, file_contents, *, validate=None,
76+ validation_kwargs=None, check=None, context=None):
77+ """
78+ Initialize plug-in and create provider from definition extracted
79+ from manage.py pointed by `filename`
80+ """
81+
82+ # override provider_manager.setup() to capture setup's parameters
83+ setup_kwargs = []
84+
85+ def fake_setup(**kwargs):
86+ setup_kwargs.append(kwargs)
87+
88+ from plainbox import provider_manager
89+ provider_manager.setup = fake_setup
90+
91+ loader = SourceFileLoader('manage', filename)
92+ loader.load_module()
93+ location = os.path.dirname(os.path.abspath(filename))
94+ if len(setup_kwargs) < 1:
95+ # did not load any provider from given manage.py
96+ # creating empty definition
97+ definition = Provider1Definition()
98+ else:
99+ setup_kwargs = setup_kwargs.pop()
100+ definition = Provider1Definition()
101+ definition.location = location
102+ definition.name = setup_kwargs.get('name', None)
103+ definition.version = setup_kwargs.get('version', None)
104+ definition.description = setup_kwargs.get('description', None)
105+ definition.gettext_domain = setup_kwargs.get(
106+ 'gettext_domain', Unset)
107+ self._provider = Provider1.from_definition(
108+ definition, secure=False, validate=validate,
109+ validation_kwargs=validation_kwargs, check=check, context=context)
110+
111+
112+class EmbeddedProvider1PlugInCollection(FsPlugInCollection):
113+ """
114+ A collection of v1 provider plugins loaded from 'manage.py' files.
115+
116+ """
117+ def __init__(self, path, **kwargs):
118+ """
119+ Initiates collection with all providers loaded from manage.py files
120+ found in `path` and subdirectories.
121+ """
122+ # get all manage.py files to load providers from
123+ super().__init__(
124+ [path], 'manage.py', recursive=True, load=True,
125+ wrapper=ManagePyProvider1PlugIn, **kwargs)

Subscribers

People subscribed via source and target branches