Merge lp:~zyga/checkbox/sa-api-changes into lp:checkbox

Proposed by Zygmunt Krynicki
Status: Merged
Approved by: Maciej Kisielewski
Approved revision: 4073
Merged at revision: 4073
Proposed branch: lp:~zyga/checkbox/sa-api-changes
Merge into: lp:checkbox
Diff against target: 127 lines (+69/-3)
3 files modified
plainbox/plainbox/impl/ingredients.py (+42/-1)
plainbox/plainbox/impl/session/assistant.py (+22/-1)
plainbox/plainbox/impl/session/test_assistant.py (+5/-1)
To merge this branch: bzr merge lp:~zyga/checkbox/sa-api-changes
Reviewer Review Type Date Requested Status
Maciej Kisielewski Approve
Sylvain Pineau (community) Approve
Review via email: mp+273502@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Sylvain Pineau (sylvain-pineau) wrote :

I already reviewed this branch without approving it, done now :)

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

Attempt to merge into lp:checkbox failed due to conflicts:

text conflict in plainbox/plainbox/impl/session/assistant.py

lp:~zyga/checkbox/sa-api-changes updated
4050. By Maciej Kisielewski

"automatic merge of lp:~kissiel/checkbox/fix-1368001-auto-skipped-rerun/ by tarmac [r=sylvain-pineau][bug=1368001,1505198][author=kissiel]"

4051. By Launchpad Translations on behalf of checkbox-dev

Launchpad automatic translations update.

4052. By Launchpad Translations on behalf of checkbox-dev

Launchpad automatic translations update.

4053. By Maciej Kisielewski

"automatic merge of lp:~kissiel/checkbox/translations-converged/ by tarmac [r=sylvain-pineau][bug=][author=kissiel]"

4054. By Launchpad Translations on behalf of checkbox-dev

Launchpad automatic translations update.

4055. By Launchpad Translations on behalf of checkbox-dev

Launchpad automatic translations update.

4056. By Maciej Kisielewski

"automatic merge of lp:~kissiel/checkbox/autopilot-reordering/ by tarmac [r=sylvain-pineau][bug=][author=kissiel]"

4057. By Sylvain Pineau

"automatic merge of lp:~sylvain-pineau/checkbox/snap_packages_in_submission_parser/ by tarmac [r=kissiel][bug=][author=sylvain-pineau]"

4058. By Po-Hsu Lin

"automatic merge of lp:~cypressyew/checkbox/use-touchscreen-manifest/ by tarmac [r=sylvain-pineau][bug=1508297][author=cypressyew]"

4059. By Pierre Equoy

"automatic merge of lp:~pierre-equoy/checkbox/fix-1459948-new-screen-rotation-script-using-dbus/ by tarmac [r=sylvain-pineau][bug=1459948][author=pierre-equoy]"

4060. By Maciej Kisielewski

"automatic merge of lp:~kissiel/checkbox/fix-1506632-crash-when-no-provider/ by tarmac [r=sylvain-pineau][bug=1506632][author=kissiel]"

4061. By Maciej Kisielewski

"automatic merge of lp:~kissiel/checkbox/fix-session-ending/ by tarmac [r=sylvain-pineau][bug=][author=kissiel]"

4062. By Maciej Kisielewski

"automatic merge of lp:~kissiel/checkbox/fix-1493467-uncategorized-skipped/ by tarmac [r=sylvain-pineau][bug=1493467][author=kissiel]"

4063. By Maciej Kisielewski

"automatic merge of lp:~kissiel/checkbox/fix-1506621-crash-next-session/ by tarmac [r=sylvain-pineau][bug=1506621][author=kissiel]"

4064. By Maciej Kisielewski

"automatic merge of lp:~kissiel/checkbox/fix-1501511-standard-close-icon/ by tarmac [r=sylvain-pineau,nik90][bug=1501511][author=kissiel]"

4065. By Po-Hsu Lin

"automatic merge of lp:~cypressyew/checkbox/rotation-from-normal/ by tarmac [r=sylvain-pineau][bug=1503167][author=cypressyew]"

4066. By Maciej Kisielewski

"automatic merge of lp:~kissiel/checkbox/minor-converged-fixes/ by tarmac [r=sylvain-pineau][bug=][author=kissiel]"

4067. By Launchpad Translations on behalf of checkbox-dev

Launchpad automatic translations update.

4068. By Po-Hsu Lin

"automatic merge of lp:~cypressyew/checkbox/reduce-webcam-led-time/ by tarmac [r=zyga][bug=][author=cypressyew]"

4069. By Maciej Kisielewski

"automatic merge of lp:~kissiel/checkbox/minor-converged-fixes/ by tarmac [r=zyga][bug=][author=kissiel]"

4070. By Pierre Equoy

"automatic merge of lp:~pierre-equoy/checkbox/fix-1471663-erroneous-wireless-results-when-eth-plugged/ by tarmac [r=sylvain-pineau][bug=1471663][author=pierre-equoy]"

4071. By Zygmunt Krynicki

plainbox: expand SessionAssistant initializer API

This patch modifies the session assistant initializer to allow up to
four arguments. The three new arguments are:

app_version: so that we can use this implicitly in some places,
 e.g. don't resumes sessions created by future versions, etc.
api_version: so that we can change usage expectations over time
 but let applications stay compatible by using a fixed API version.
 This can be changed to a __new__ call that returns a versioned
 SA class instead of doing if-then-else magic in all the places.
api_flags: so that we can allow applications to opt-into optional
 features and so that we can adjust expectations accordingly. This
 will also allow us to easily compare applications for feature
 parity.

For now all new arguments have sane defaults. Once all applications are
patched the defaults will go away.

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

4072. By Zygmunt Krynicki

plainbox:ingredients: add get_sa_api_{version,flags} to CanonicalCommand

This patch allows CanonicalCommand consumers to define the expected
SessionAssistant API and feature flags with simple class-level
attributes. Two new getter methods are used to read them and provide
sensible defaults.

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

4073. By Zygmunt Krynicki

plainbox:ingredients: initialize SA with app meta-data

This patch makes CanonicalCommand initialize the internal
SessionAssistant object with application version and API version and
feature flags, as declared by the command.

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 'plainbox/plainbox/impl/ingredients.py'
2--- plainbox/plainbox/impl/ingredients.py 2015-09-01 13:48:29 +0000
3+++ plainbox/plainbox/impl/ingredients.py 2015-10-28 11:12:50 +0000
4@@ -137,7 +137,12 @@
5
6 def late_init(self, context):
7 """Add a SessionAssistant as ``sa`` to the guacamole context."""
8- context.sa = SessionAssistant(context.cmd_toplevel.get_app_id())
9+ context.sa = SessionAssistant(
10+ context.cmd_toplevel.get_app_id(),
11+ context.cmd_toplevel.get_cmd_version(),
12+ context.cmd_toplevel.get_sa_api_version(),
13+ context.cmd_toplevel.get_sa_api_flags(),
14+ )
15
16
17 class CanonicalCrashIngredient(Ingredient):
18@@ -198,6 +203,42 @@
19
20 bug_report_url = "https://bugs.launchpad.net/checkbox/+filebug"
21
22+ def get_sa_api_version(self):
23+ """
24+ Get the SessionAssistant API this command needs to use.
25+
26+ :returns:
27+ ``self.sa_api_version`` if defined
28+ :returns:
29+ "0.99", otherwise
30+
31+ This method is used internally by CanonicalCommand to initialize
32+ SessionAssistant. Applications can declare the API version they use by
33+ defining the ``sa_api_version`` attribute at class level.
34+ """
35+ try:
36+ return self.sa_api_version
37+ except AttributeError:
38+ return '0.99'
39+
40+ def get_sa_api_flags(self):
41+ """
42+ Get the SessionAssistant API flags this command needs to use.
43+
44+ :returns:
45+ ``self.sa_api_flags`` if defined
46+ :returns:
47+ ``[]``, otherwise
48+
49+ This method is used internally by CanonicalCommand to initialize
50+ SessionAssistant. Applications can declare the API flags they use by
51+ defining the ``sa_api_flags`` attribute at class level.
52+ """
53+ try:
54+ return self.sa_api_flags
55+ except AttributeError:
56+ return []
57+
58 def main(self, argv=None, exit=True):
59 """
60 Shortcut for running a command.
61
62=== modified file 'plainbox/plainbox/impl/session/assistant.py'
63--- plainbox/plainbox/impl/session/assistant.py 2015-10-26 13:11:03 +0000
64+++ plainbox/plainbox/impl/session/assistant.py 2015-10-28 11:12:50 +0000
65@@ -94,7 +94,8 @@
66
67 # TODO: create a flowchart of possible states
68
69- def __init__(self, app_id):
70+ def __init__(self, app_id, app_version=None, api_version='0.99',
71+ api_flags=()):
72 """
73 Initialize a new session assistant.
74
75@@ -102,12 +103,32 @@
76 Identifier of the testing application. The identifier should be
77 unique and constant throughout the support cycle of the
78 application.
79+ :param app_version:
80+ Version of the testing application.
81+ :param api_version:
82+ Expected API of SessionAssistant. Currently only "0.99" API is
83+ defined.
84+ :param api_flags:
85+ Flags that describe optional API features that this application
86+ wishes to support. Flags may change the usage expectation of
87+ session assistant. Currently no flags are supported.
88+ :raises ValueError:
89+ When api_version is not recognized.
90+ :raises ValueError:
91+ When api_flags contains an unrecognized flag.
92
93 The application identifier is useful to implement session resume
94 functionality where the application can easily filter out sessions from
95 other programs.
96 """
97+ if api_version != '0.99':
98+ raise ValueError("Unrecognized API version")
99+ for flag in api_flags:
100+ raise ValueError("Unrecognized API flag: {!r}".format(flag))
101 self._app_id = app_id
102+ self._app_version = app_version
103+ self._api_version = api_version
104+ self._api_flags = api_flags
105 self._repo = SessionStorageRepository()
106 self._config = PlainBoxConfig().get()
107 self._execution_ctrl_list = None # None is "default"
108
109=== modified file 'plainbox/plainbox/impl/session/test_assistant.py'
110--- plainbox/plainbox/impl/session/test_assistant.py 2015-08-03 14:10:44 +0000
111+++ plainbox/plainbox/impl/session/test_assistant.py 2015-10-28 11:12:50 +0000
112@@ -35,10 +35,14 @@
113 """Tests for the SessionAssitant class."""
114
115 APP_ID = 'app-id'
116+ APP_VERSION = '1.0'
117+ API_VERSION = '0.99'
118+ API_FLAGS = []
119
120 def setUp(self):
121 """Common set-up code."""
122- self.sa = SessionAssistant(self.APP_ID)
123+ self.sa = SessionAssistant(
124+ self.APP_ID, self.APP_VERSION, self.API_VERSION, self.API_FLAGS)
125 # NOTE: setup a custom repository so that all tests are done in
126 # isolation from the user account. While we're doing that, let's check
127 # that this this function is allowed just after setting up the session.

Subscribers

People subscribed via source and target branches