Merge lp:~didrocks/ubuntu-system-image/small-modifs into lp:~barry/ubuntu-system-image/lp1212781

Proposed by Didier Roche-Tolomelli
Status: Merged
Merge reported by: Barry Warsaw
Merged at revision: not available
Proposed branch: lp:~didrocks/ubuntu-system-image/small-modifs
Merge into: lp:~barry/ubuntu-system-image/lp1212781
Diff against target: 329 lines (+112/-66)
3 files modified
systemimage/bindings.py (+1/-1)
systemimage/dbus.py (+22/-4)
systemimage/testing/dbus.py (+89/-61)
To merge this branch: bzr merge lp:~didrocks/ubuntu-system-image/small-modifs
Reviewer Review Type Date Requested Status
Barry Warsaw Approve
Review via email: mp+181580@code.launchpad.net

Description of the change

Misc mock issues fixes

To post a comment you must log in.
159. By Didier Roche-Tolomelli

no GetSetting/SetSetting needed

160. By Didier Roche-Tolomelli

comment is deprecated

161. By Didier Roche-Tolomelli

support version as a string instead of an int

162. By Didier Roche-Tolomelli

emit a SettingChanged signal if a setting key changed

Revision history for this message
Barry Warsaw (barry) wrote :

Thanks for the fixes and changes!

LP: #1215586 tracks the support for the array-of-dictionaries data type. I'll leave these commented out in my branch for now, so please resolve that issue when the u/i can handle this and I'll re-enable it in the client.

I fixed all the tests.

I had to restore the Reset method; it's used by the test suite due to peculiarities in the way the dbus service is launched through the testing infrastructure.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'systemimage/bindings.py'
2--- systemimage/bindings.py 2013-08-01 22:52:44 +0000
3+++ systemimage/bindings.py 2013-08-22 16:02:46 +0000
4@@ -95,7 +95,7 @@
5
6 @property
7 def update_version(self):
8- return int(self.iface.GetUpdateVersion())
9+ return str(self.iface.GetUpdateVersion())
10
11 @property
12 def update_descriptions(self):
13
14=== modified file 'systemimage/dbus.py'
15--- systemimage/dbus.py 2013-08-22 02:33:05 +0000
16+++ systemimage/dbus.py 2013-08-22 16:02:46 +0000
17@@ -61,7 +61,7 @@
18 self._update.version,
19 self._update.size,
20 self._update.last_update_date,
21- self._update.descriptions,
22+ #self._update.descriptions,
23 "")
24 self._checking = False
25 # Stop GLib from calling this method again.
26@@ -122,7 +122,14 @@
27 GLib.timeout_add(50, self._download)
28
29 @method('com.canonical.SystemImage')
30- def Cancel(self):
31+ def PauseDownload(self, out_signature='s'):
32+ """Pause a downloading update.
33+
34+ TODO: complete"""
35+ return ""
36+
37+ @method('com.canonical.SystemImage')
38+ def CancelUpdate(self, out_signature='s'):
39 """Cancel a download and/or reboot.
40
41 At any time between the `GetUpdate()` call and the `Reboot()` call, an
42@@ -134,6 +141,8 @@
43 """
44 self._api.cancel()
45 self.Canceled()
46+ # TODO: if can't cancel the current download, return the reason in this string
47+ return ""
48
49 @method('com.canonical.SystemImage')
50 def Exit(self):
51@@ -148,11 +157,12 @@
52 self._api.reboot()
53 return ''
54
55- @signal('com.canonical.SystemImage', signature='bbiisaa{ss}s')
56+ #@signal('com.canonical.SystemImage', signature='bbiisaa{ss}s')
57+ @signal('com.canonical.SystemImage', signature='bbsiss')
58 def UpdateAvailableStatus(self,
59 is_available, downloading,
60 available_version, update_size,
61- last_update_date, descriptions,
62+ last_update_date, #descriptions,
63 error_reason):
64 """Signal sent in response to a CheckForUpdate()."""
65
66@@ -172,6 +182,7 @@
67 def UpdatePaused(self, percentage):
68 """The download got paused."""
69
70+ # TODO: remove
71 @signal('com.canonical.SystemImage')
72 def Canceled(self):
73 """A download has been canceled.
74@@ -202,9 +213,16 @@
75 return
76 if as_int not in (0, 1, 2):
77 return
78+ if value == self.GetSetting(key):
79+ return
80 Settings().set(key, value)
81+ self.SettingChanged(key, value)
82
83 @method('com.canonical.SystemImage', in_signature='s', out_signature='s')
84 def GetSetting(self, key):
85 """Get a setting."""
86 return Settings().get(key)
87+
88+ @signal('com.canonical.SystemImage', signature='ss')
89+ def SettingChanged(self, key, new_value):
90+ """A settings key has change"""
91
92=== modified file 'systemimage/testing/dbus.py'
93--- systemimage/testing/dbus.py 2013-08-22 02:54:38 +0000
94+++ systemimage/testing/dbus.py 2013-08-22 16:02:46 +0000
95@@ -88,10 +88,6 @@
96 super().__init__(bus, object_path, loop)
97 self._reset()
98
99- @method('com.canonical.SystemImage')
100- def Reset(self):
101- self._reset()
102-
103 def _reset(self):
104 self._percentage = 0
105 self._eta = 50.0
106@@ -109,21 +105,25 @@
107
108 def _send_status(self):
109 self.UpdateAvailableStatus(
110- True, self._auto_download, 42, 1337 * 1024 * 1024,
111+ True, self._auto_download, '42', 1337 * 1024 * 1024,
112 '1983-09-13T12:13:14',
113- [
114- {'description': 'Ubuntu Edge support',
115- 'description-en_GB': 'change the background colour',
116- 'description-fr': "Support d'Ubuntu Edge",
117- },
118- {'description':
119- 'Flipped container with 200% boot speed improvement',
120- }],
121+ #[
122+ #{'description': 'Ubuntu Edge support',
123+ # 'description-en_GB': 'change the background colour',
124+ # 'description-fr': "Support d'Ubuntu Edge",
125+ #},
126+ #{'description':
127+ # 'Flipped container with 200% boot speed improvement',
128+ #"}],
129 '')
130- if self._auto_download:
131+ if self._auto_download and not self._downloading and not self._rebootable:
132 self._downloading = True
133 self.UpdateProgress(0, 50.0)
134 GLib.timeout_add(500, self._send_more_status)
135+ if self._paused:
136+ self.UpdatePaused(self._percentage)
137+ if self._rebootable:
138+ self.UpdateDownloaded()
139 return False
140
141 def _send_more_status(self):
142@@ -138,6 +138,7 @@
143 if self._percentage == 100:
144 # We're done.
145 self._downloading = False
146+ self._rebootable = True
147 self.UpdateDownloaded()
148 return False
149 self.UpdateProgress(self._percentage, self._eta)
150@@ -161,7 +162,7 @@
151 self.UpdateProgress(0, 50.0)
152 GLib.timeout_add(500, self._send_more_status)
153
154- @method('com.canonical.SystemImage', signature='s')
155+ @method('com.canonical.SystemImage', out_signature='s')
156 def CancelUpdate(self):
157 if self._downloading:
158 self._canceled = True
159@@ -183,32 +184,33 @@
160 class _UpdateFailed(Service):
161 def __init__(self, bus, object_path, loop):
162 super().__init__(bus, object_path, loop)
163- self._reset()
164-
165- @method('com.canonical.SystemImage')
166- def Reset(self):
167- self._reset()
168-
169- def _reset(self):
170 self._failure_count = 1
171
172 @method('com.canonical.SystemImage')
173 def CheckForUpdate(self):
174- msg = 'You need some network for downloading'
175+ msg = ''
176+ if self._failure_count > 0:
177+ msg = 'You need some network for downloading'
178 self.UpdateAvailableStatus(
179- True, False, 42, 1337 * 1024 * 1024,
180+ True, False, '42', 1337 * 1024 * 1024,
181 '1983-09-13T12:13:14',
182- [
183- {'description': 'Ubuntu Edge support',
184- 'description-en_GB': 'change the background colour',
185- 'description-fr': "Support d'Ubuntu Edge",
186- },
187- {'description':
188- 'Flipped container with 200% boot speed improvement',
189- }],
190+ #[
191+ #{'description': 'Ubuntu Edge support',
192+ # 'description-en_GB': 'change the background colour',
193+ # 'description-fr': "Support d'Ubuntu Edge",
194+ #},
195+ #{'description':
196+ # 'Flipped container with 200% boot speed improvement',
197+ #}],
198 msg)
199- self._failure_count += 1
200- self.UpdateFailed(self._failure_count, msg)
201+ if self._failure_count > 0:
202+ self._failure_count += 1
203+ self.UpdateFailed(self._failure_count, msg)
204+
205+ @method('com.canonical.SystemImage', out_signature='s')
206+ def CancelUpdate(self):
207+ self._failure_count = 0
208+ return ''
209
210
211 class _FailApply(Service):
212@@ -219,16 +221,16 @@
213 @method('com.canonical.SystemImage')
214 def CheckForUpdate(self):
215 self.UpdateAvailableStatus(
216- True, False, 42, 1337 * 1024 * 1024,
217+ True, False, '42', 1337 * 1024 * 1024,
218 '1983-09-13T12:13:14',
219- [
220- {'description': 'Ubuntu Edge support',
221- 'description-en_GB': 'change the background colour',
222- 'description-fr': "Support d'Ubuntu Edge",
223- },
224- {'description':
225- 'Flipped container with 200% boot speed improvement',
226- }],
227+ #[
228+ #{'description': 'Ubuntu Edge support',
229+ # 'description-en_GB': 'change the background colour',
230+ # 'description-fr': "Support d'Ubuntu Edge",
231+ #},
232+ #{'description':
233+ # 'Flipped container with 200% boot speed improvement',
234+ #}],
235 '')
236 self.UpdateDownloaded()
237
238@@ -246,16 +248,16 @@
239 @method('com.canonical.SystemImage')
240 def CheckForUpdate(self):
241 self.UpdateAvailableStatus(
242- True, False, 42, 1337 * 1024 * 1024,
243+ True, False, '42', 1337 * 1024 * 1024,
244 '1983-09-13T12:13:14',
245- [
246- {'description': 'Ubuntu Edge support',
247- 'description-en_GB': 'change the background colour',
248- 'description-fr': "Support d'Ubuntu Edge",
249- },
250- {'description':
251- 'Flipped container with 200% boot speed improvement',
252- }],
253+ #[
254+ #{'description': 'Ubuntu Edge support',
255+ # 'description-en_GB': 'change the background colour',
256+ # 'description-fr': "Support d'Ubuntu Edge",
257+ #},
258+ #{'description':
259+ # 'Flipped container with 200% boot speed improvement',
260+ #}],
261 '')
262 self.UpdatePaused(42)
263
264@@ -272,16 +274,16 @@
265 @method('com.canonical.SystemImage')
266 def CheckForUpdate(self):
267 self.UpdateAvailableStatus(
268- True, True, 42, 1337 * 1024 * 1024,
269+ True, True, '42', 1337 * 1024 * 1024,
270 '1983-09-13T12:13:14',
271- [
272- {'description': 'Ubuntu Edge support',
273- 'description-en_GB': 'change the background colour',
274- 'description-fr': "Support d'Ubuntu Edge",
275- },
276- {'description':
277- 'Flipped container with 200% boot speed improvement',
278- }],
279+ #[
280+ #{'description': 'Ubuntu Edge support',
281+ # 'description-en_GB': 'change the background colour',
282+ # 'description-fr': "Support d'Ubuntu Edge",
283+ #},
284+ #{'description':
285+ # 'Flipped container with 200% boot speed improvement',
286+ #}],
287 '')
288 self.UpdateProgress(10, 0)
289
290@@ -289,6 +291,30 @@
291 def PauseDownload(self):
292 return 'no no, not now'
293
294+class _NoUpdate(Service):
295+ @method('com.canonical.SystemImage')
296+ def CheckForUpdate(self):
297+ GLib.timeout_add_seconds(3, self._send_status)
298+
299+ def _send_status(self):
300+ self.UpdateAvailableStatus(
301+ False, False, '', 0,
302+ '1983-09-13T12:13:14',
303+ #[
304+ #{'description': 'Ubuntu Edge support',
305+ # 'description-en_GB': 'change the background colour',
306+ # 'description-fr': "Support d'Ubuntu Edge",
307+ #},
308+ #{'description':
309+ # 'Flipped container with 200% boot speed improvement',
310+ #}],
311+ '')
312+
313+
314+def get_service(testing_mode, system_bus, object_path, loop):
315+ """Return the appropriate service class for the testing mode."""
316+ if testing_mode == 'live':
317+ ServiceClass = _LiveTestableService
318
319 def get_service(testing_mode, system_bus, object_path, loop):
320 """Return the appropriate service class for the testing mode."""
321@@ -306,6 +332,8 @@
322 ServiceClass = _FailResume
323 elif testing_mode == 'fail-pause':
324 ServiceClass = _FailPause
325+ elif testing_mode == 'no-update':
326+ ServiceClass = _NoUpdate
327 else:
328 raise RuntimeError('Invalid testing mode: {}'.format(testing_mode))
329 return ServiceClass(system_bus, object_path, loop)

Subscribers

People subscribed via source and target branches