Merge lp:~zyga/checkbox/fixes into lp:checkbox

Proposed by Zygmunt Krynicki
Status: Merged
Approved by: Maciej Kisielewski
Approved revision: 3413
Merged at revision: 3421
Proposed branch: lp:~zyga/checkbox/fixes
Merge into: lp:checkbox
Diff against target: 80 lines (+37/-5)
1 file modified
checkbox-touch/py/embedded_providers.py (+37/-5)
To merge this branch: bzr merge lp:~zyga/checkbox/fixes
Reviewer Review Type Date Requested Status
Maciej Kisielewski Approve
Review via email: mp+241761@code.launchpad.net

Description of the change

78c4913 checkbox-touch: fix embedded provider loader after API changes

To post a comment you must log in.
lp:~zyga/checkbox/fixes updated
3413. By Zygmunt Krynicki

checkbox-touch: fix embedded provider loader after API changes

This patch fixes the embedded provider plug-in to adhere to the extended
plug-in API.

Signed-off-by: Zygmunt Krynicki <email address hidden>

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

+1, Thanks!

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/embedded_providers.py'
2--- checkbox-touch/py/embedded_providers.py 2014-11-13 23:14:59 +0000
3+++ checkbox-touch/py/embedded_providers.py 2014-11-14 07:09:51 +0000
4@@ -22,16 +22,16 @@
5
6 This module contains custom providers used by Checkbox-touch
7 """
8+# NOTE: this is python 3.3 only
9 from importlib.machinery import SourceFileLoader
10-import logging
11 import os
12
13-from plainbox.abc import IProvider1, IProviderBackend1
14+from plainbox.impl.secure.config import Unset
15 from plainbox.impl.secure.plugins import FsPlugInCollection
16+from plainbox.impl.secure.plugins import now
17 from plainbox.impl.secure.providers.v1 import Provider1
18 from plainbox.impl.secure.providers.v1 import Provider1Definition
19 from plainbox.impl.secure.providers.v1 import Provider1PlugIn
20-from plainbox.impl.secure.config import Unset
21
22
23 class ManagePyProvider1PlugIn(Provider1PlugIn):
24@@ -39,15 +39,16 @@
25 Provider1PlugIn that is built from manage.py file.
26 """
27
28- def __init__(self, filename, file_contents, plugin_load_time, *, validate=None,
29+ def __init__(self, filename, file_contents, load_time, *, validate=None,
30 validation_kwargs=None, check=None, context=None):
31 """
32 Initialize plug-in and create provider from definition extracted
33 from manage.py pointed by `filename`
34 """
35-
36+ self._load_time = load_time
37 # override provider_manager.setup() to capture setup's parameters
38 setup_kwargs = []
39+ start_time = now()
40
41 def fake_setup(**kwargs):
42 setup_kwargs.append(kwargs)
43@@ -74,6 +75,37 @@
44 self._provider = Provider1.from_definition(
45 definition, secure=False, validate=validate,
46 validation_kwargs=validation_kwargs, check=check, context=context)
47+ self._wrap_time = now() - start_time
48+
49+ @property
50+ def plugin_name(self):
51+ """
52+ plugin name, the namespace of the provider
53+ """
54+ return self._provider.name
55+
56+ @property
57+ def plugin_object(self):
58+ """
59+ plugin object, the actual Provider1 instance
60+ """
61+ return self._provider
62+
63+ @property
64+ def plugin_load_time(self) -> float:
65+ """
66+ time, in fractional seconds, that was needed to load the provider
67+ definition file from the file system
68+ """
69+ return self._load_time
70+
71+ @property
72+ def plugin_wrap_time(self) -> float:
73+ """
74+ time, in fractional seconds, that was needed to load the provider from
75+ the definition text
76+ """
77+ return self._wrap_time
78
79
80 class EmbeddedProvider1PlugInCollection(FsPlugInCollection):

Subscribers

People subscribed via source and target branches