Merge lp:~brian.curtin/ubuntuone-client/851810-notify-on-volumes into lp:ubuntuone-client

Proposed by Brian Curtin
Status: Merged
Merged at revision: 1218
Proposed branch: lp:~brian.curtin/ubuntuone-client/851810-notify-on-volumes
Merge into: lp:ubuntuone-client
Diff against target: 179 lines (+44/-0)
10 files modified
tests/platform/test_external_interface.py (+2/-0)
tests/syncdaemon/test_interaction_interfaces.py (+14/-0)
tests/syncdaemon/test_vm.py (+4/-0)
ubuntuone/platform/linux/dbus_interface.py (+5/-0)
ubuntuone/platform/tools/windows.py (+1/-0)
ubuntuone/platform/windows/ipc.py (+5/-0)
ubuntuone/platform/windows/ipc_client.py (+5/-0)
ubuntuone/syncdaemon/event_queue.py (+1/-0)
ubuntuone/syncdaemon/interaction_interfaces.py (+5/-0)
ubuntuone/syncdaemon/volume_manager.py (+2/-0)
To merge this branch: bzr merge lp:~brian.curtin/ubuntuone-client/851810-notify-on-volumes
Reviewer Review Type Date Requested Status
Natalia Bidart (community) Needs Resubmitting
Review via email: mp+94280@code.launchpad.net

Commit message

- Emit a notification when volumes are ready after a server rescan, allowing clients to follow and update their information accordingly (LP: #851810).

Description of the change

After processing volumes during the server rescan, push an event to notify that volumes are ready for clients to consume.

To post a comment you must log in.
Revision history for this message
Brian Curtin (brian.curtin) wrote :

Forget this for now - there are still TODO comments that I forgot to address.

Revision history for this message
Brian Curtin (brian.curtin) wrote :

After going over it, I don't believe implementations of the TODO comments were necessary.

1197. By Natalia Bidart

- Use the Qt SSO UI when doing credentials management (LP: #930716).
- Use consistently the U1_DEBUG env var to have DEUBG output.

1198. By dobey

Update the messaging indicator integration to launch ubuntuone-installer
Avoid passing time() to the Indicator API which expects GTimeVal now
Update the tests for the changes

1199. By Natalia Bidart

- Call CredentialsManagementTool.login when prompt to connect (LP: #944230).

1200. By Natalia Bidart

- Made default for MARK logging to be every 15 minutes (LP: #906462).

1201. By Roberto Alsina

- Made indicate import optional (LP: #939509).

Revision history for this message
Natalia Bidart (nataliabidart) wrote :
Download full text (5.1 KiB)

Test are not running on linux because:

  File "/home/nessita/canonical/client/review_851810-notify-on-volumes/ubuntuone/platform/linux/dbus_interface.py", line 426, in Shares
    signature='a{ss}')
  File "/usr/lib/python2.7/dist-packages/dbus/decorators.py", line 333, in decorator
    raise ValueError('signal signature is longer than the number of arguments provided')
ValueError: signal signature is longer than the number of arguments provided
make: *** [test] Error 1

This is caused by the following:

73 + @dbus.service.signal(DBUS_IFACE_SHARES_NAME,
74 + signature='a{ss}')
75 + def VolumesReady(self):
76 + """Volumes are ready."""
77 +

VolumesReady should accept a param named 'volumes', like the signature specifies.

Also, in DBus you can't pass an array of objects, so you need to serialize the resulting volumes list. In IRL this means that with this branch we're getting this failure in the logs:

2012-03-07 12:49:39,359 - ubuntuone.SyncDaemon.EQ - ERROR - Error encountered while handling: VM_VOLUMES_READY in <ubuntuone.syncdaemon.interaction_interfaces.SyncdaemonEventListener object at 0xb501ed0>
Traceback (most recent call last):
  File "/home/nessita/canonical/client/review_851810-notify-on-volumes/ubuntuone/syncdaemon/event_queue.py", line 304, in _dispatch
    method(**kwargs)
  File "/home/nessita/canonical/client/review_851810-notify-on-volumes/ubuntuone/logger.py", line 269, in inner
    res = f(*args, **kwargs)
  File "/home/nessita/canonical/client/review_851810-notify-on-volumes/ubuntuone/syncdaemon/interaction_interfaces.py", line 1044, in handle_VM_VOLUMES_READY
    self.interface.shares.VolumesReady(volumes)
  File "/usr/lib/python2.7/dist-packages/dbus/decorators.py", line 314, in emit_signal
    message.append(signature=signature, *args)
TypeError: list indices must be integers, not RootVolume

So, in ubuntuone/syncdaemon/interaction_interfaces.py", line 1044, in handle_VM_VOLUMES_READY, you need to serialize the 'volumes' content. To do so, please use get_share_dict to serialize a the root and shares, and get_udf_dict for folders.

There is another thing to fix: the current volumes list has objects which classes are RooVolume, ShareVolume, and UDFVolume. These classes come from the protocol directly and are "low level", and should not be leaked to other modules. The volume_manager python module has a higher level abstraction for those, see the class Root, Shares and UDF (all 3 inheriting from Volume).

So, the volumes list send in the VM_VOLUMES_READY event should be a list of specializations of volume_manager.Volume. The fix does not ends there :-), as you can see in the

    549 def server_rescan(self):

method, after self._volumes_rescan_cb is done, another call is being to cleanup dead local volumes, so the event VM_VOLUMES_READY should be emitted once that cleanup is completed. Ergo, to solve both of these items (having high-level volume abstractions and a fully updated volumes list), I would suggest removing this line:

    639 events.append(("VM_VOLUMES_READY", dict(volumes=volumes)))

and adding a callback to the...

Read more...

review: Needs Fixing
Revision history for this message
Natalia Bidart (nataliabidart) wrote :

Just tested this change IRL and I'm getting:

  File "/home/nessita/canonical/client/review_851810-notify-on-volumes/ubuntuone/syncdaemon/volume_manager.py", line 562, in server_rescan
    volumes = self.shares + self.udfs
exceptions.TypeError: unsupported operand type(s) for +: 'VMTritcaskShelf' and 'VMTritcaskShelf'

we need to ask verterok how to properly "sum" to volumes list.

Revision history for this message
Natalia Bidart (nataliabidart) wrote :

Ok, just chatted with verterok and what we need is to emit the event with this as the volumes param:

volumes = list(self.get_volumes(all_volumes=True))

1202. By Alejandro J. Cura

- The infrastructure for a QtNetwork based process to tunnel syncdaemon traffic thru proxies. (LP: #929207)

1203. By Alejandro J. Cura

- A client for the proxy tunnel, to be used by syncdaemon (LP: #929207).

1204. By Alejandro J. Cura

- A proxy tunnel process to be started when proxies are enabled (LP: #929207).

1205. By dobey

Set the transient hint on the notifications to True

1206. By Alejandro J. Cura

- Tunnel storage protocol if proxy enabled in system settings (LP: #929208).

1207. By dobey

Fix the typo in the u1sdtool --list-shared help text and man page
Don't install the really old preferences man file we don't need

1208. By Alejandro J. Cura

- Use the txweb webclient from sso for webcalls, so they can be proxied too (LP: #929207, LP: #929212).

1209. By Alejandro J. Cura

QNetwork must use the proxy built; forward disconnections in the tunnel client.

1210. By dobey

Don't attach old useless log files, and clean up the report a little

1211. By Alejandro J. Cura

- Use proxy credentials from the keyring (LP: #929207)

1212. By Alejandro J. Cura

- Only allow connections that provide the right cookie thru the tunnel (LP: #929207).

1213. By Roberto Alsina

Fix tunnel spawning code so that it works on windows.

1214. By Brian Curtin

- Loosen the is_root check on Windows to allow Windows XP users, who commonly run with Administrator rights, to start U1 properly. (LP: #930398).

1215. By Brian Curtin

merge lp:~brian.curtin/ubuntuone-client/851810-notify-on-volumes

1216. By Brian Curtin

match the signature on linux

Revision history for this message
Natalia Bidart (nataliabidart) wrote :
review: Needs Resubmitting

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tests/platform/test_external_interface.py'
2--- tests/platform/test_external_interface.py 2012-02-03 14:29:52 +0000
3+++ tests/platform/test_external_interface.py 2012-03-22 18:12:20 +0000
4@@ -31,6 +31,7 @@
5
6 STR = 'something'
7 STR_STR_DICT = {'foo': 'bar'}
8+STR_LST_DICT = {'foo': ['bar', 'baz']}
9
10
11 class StatusTests(StatusTestCase):
12@@ -294,6 +295,7 @@
13 ('ShareSubscribeError', (STR_STR_DICT, STR)),
14 ('ShareUnSubscribed', (STR_STR_DICT,)),
15 ('ShareUnSubscribeError', (STR_STR_DICT, STR)),
16+ ('VolumesReady', (STR_LST_DICT))
17 ]
18
19 @defer.inlineCallbacks
20
21=== modified file 'tests/syncdaemon/test_interaction_interfaces.py'
22--- tests/syncdaemon/test_interaction_interfaces.py 2012-03-01 19:08:12 +0000
23+++ tests/syncdaemon/test_interaction_interfaces.py 2012-03-22 18:12:20 +0000
24@@ -1750,6 +1750,20 @@
25 self.assertEqual(error, error_msg)
26
27 @defer.inlineCallbacks
28+ def test_handle_VM_VOLUMES_READY(self):
29+ """Test the handle_VM_VOLUMES_READY method."""
30+ share = self._create_share(accepted=True)
31+ udf = self._create_udf()
32+ volumes = [share, udf, self.main.vm.root]
33+ d = defer.Deferred()
34+ self.patch(self.sd_obj.interface.shares, 'VolumesReady', d.callback)
35+ self.main.event_q.push('VM_VOLUMES_READY', volumes=volumes)
36+
37+ info = yield d
38+
39+ self.assertEqual(volumes, info)
40+
41+ @defer.inlineCallbacks
42 def test_handle_VM_VOLUME_DELETED_folder(self):
43 """Test the handle_VM_VOLUME_DELETED method for a folder."""
44 udf = self._create_udf()
45
46=== modified file 'tests/syncdaemon/test_vm.py'
47--- tests/syncdaemon/test_vm.py 2012-02-09 23:32:10 +0000
48+++ tests/syncdaemon/test_vm.py 2012-03-22 18:12:20 +0000
49@@ -3104,11 +3104,15 @@
50 vol_rescan_d.callback) # autosubscribe is False
51 server_rescan_d = defer.Deferred()
52 self._listen_for('SYS_SERVER_RESCAN_DONE', server_rescan_d.callback)
53+ volumes_ready_d = defer.Deferred()
54+ self._listen_for('VM_VOLUMES_READY', volumes_ready_d.callback)
55 yield self.vm.server_rescan()
56 yield server_rescan_d
57 events = yield vol_rescan_d
58+ vols = yield volumes_ready_d
59
60 self.assertEqual({'generation': 1, 'volume_id': ''}, events)
61+ self.assertEqual({'volumes' : response}, vols)
62
63 @defer.inlineCallbacks
64 def test_server_rescan_with_share_autosubscribe(self):
65
66=== modified file 'ubuntuone/platform/linux/dbus_interface.py'
67--- ubuntuone/platform/linux/dbus_interface.py 2012-02-18 16:13:04 +0000
68+++ ubuntuone/platform/linux/dbus_interface.py 2012-03-22 18:12:20 +0000
69@@ -422,6 +422,11 @@
70 def ShareDeleteError(self, share_dict, error):
71 """An error occurred while deleting a share."""
72
73+ @dbus.service.signal(DBUS_IFACE_SHARES_NAME,
74+ signature='a{ss}')
75+ def VolumesReady(self, volumes):
76+ """Volumes are ready."""
77+
78 @dbus.service.method(DBUS_IFACE_SHARES_NAME,
79 in_signature='ssss', out_signature='')
80 def create_share(self, path, username, name, access_level):
81
82=== modified file 'ubuntuone/platform/tools/windows.py'
83--- ubuntuone/platform/tools/windows.py 2011-11-30 14:53:56 +0000
84+++ ubuntuone/platform/tools/windows.py 2012-03-22 18:12:20 +0000
85@@ -88,6 +88,7 @@
86 'ShareUnSubscribed': ('shares', 'on_share_unsubscribed_cb'),
87 'ShareUnSubscribeError': ('shares', 'on_share_unsubscribe_error_cb'),
88 'StatusChanged': ('status', 'on_status_changed_cb'),
89+ 'VolumesReady': ('volumes', 'on_volumes_ready_cb'),
90 }
91
92 # All methods and instance variables that should not be handled by
93
94=== modified file 'ubuntuone/platform/windows/ipc.py'
95--- ubuntuone/platform/windows/ipc.py 2012-02-18 16:13:04 +0000
96+++ ubuntuone/platform/windows/ipc.py 2012-03-22 18:12:20 +0000
97@@ -507,6 +507,7 @@
98 'ShareSubscribeError': 'on_share_subscribe_error',
99 'ShareUnSubscribed': 'on_share_unsubscribed',
100 'ShareUnSubscribeError': 'on_share_unsubscribe_error',
101+ 'VolumesReady': 'on_volumes_ready',
102 }
103
104 def get_shares(self):
105@@ -616,6 +617,10 @@
106 def ShareUnSubscribeError(self, share_info, error):
107 """Notify an error while unsubscribing from a share."""
108
109+ @signal
110+ def VolumesReady(self, volumes):
111+ """Volumes are ready."""
112+
113
114 class Config(IPCExposedObject):
115 """The Syncdaemon config/settings interface."""
116
117=== modified file 'ubuntuone/platform/windows/ipc_client.py'
118--- ubuntuone/platform/windows/ipc_client.py 2012-02-03 14:29:52 +0000
119+++ ubuntuone/platform/windows/ipc_client.py 2012-03-22 18:12:20 +0000
120@@ -340,6 +340,7 @@
121 'on_share_subscribe_error',
122 'on_share_unsubscribed',
123 'on_share_unsubscribe_error',
124+ 'on_volumes_ready',
125 ]
126
127 @remote
128@@ -447,6 +448,10 @@
129 def on_share_unsubscribe_error(self, share_id, error):
130 """Emit the ShareUnSubscribeError signal."""
131
132+ @signal
133+ def on_volumes_ready(self, volumes):
134+ """Emit VolumesReady signal."""
135+
136
137 class ConfigClient(RemoteClient):
138 """The Syncdaemon config/settings ipc interface. """
139
140=== modified file 'ubuntuone/syncdaemon/event_queue.py'
141--- ubuntuone/syncdaemon/event_queue.py 2011-10-14 20:02:23 +0000
142+++ ubuntuone/syncdaemon/event_queue.py 2012-03-22 18:12:20 +0000
143@@ -160,6 +160,7 @@
144 'VM_VOLUME_DELETED': ('volume',),
145 'VM_VOLUME_DELETE_ERROR': ('volume_id', 'error'),
146 'VM_SHARE_CHANGED': ('share_id',),
147+ 'VM_VOLUMES_READY': ('volumes',),
148
149 }
150
151
152=== modified file 'ubuntuone/syncdaemon/interaction_interfaces.py'
153--- ubuntuone/syncdaemon/interaction_interfaces.py 2012-03-19 13:20:36 +0000
154+++ ubuntuone/syncdaemon/interaction_interfaces.py 2012-03-22 18:12:20 +0000
155@@ -1039,6 +1039,11 @@
156 self.interface.shares.ShareChanged(get_share_dict(share))
157
158 @log_call(logger.debug)
159+ def handle_VM_VOLUMES_READY(self, volumes):
160+ """Handle VM_VOLUMES_READY event, emit VolumesReady event."""
161+ self.interface.shares.VolumesReady(volumes)
162+
163+ @log_call(logger.debug)
164 def handle_AQ_CHANGE_PUBLIC_ACCESS_OK(self, share_id, node_id,
165 is_public, public_url):
166 """Handle the AQ_CHANGE_PUBLIC_ACCESS_OK event."""
167
168=== modified file 'ubuntuone/syncdaemon/volume_manager.py'
169--- ubuntuone/syncdaemon/volume_manager.py 2012-02-09 23:32:10 +0000
170+++ ubuntuone/syncdaemon/volume_manager.py 2012-03-22 18:12:20 +0000
171@@ -636,6 +636,8 @@
172 # update the free_bytes on the volume
173 self.update_free_space(volume_id, new_volume.free_bytes)
174
175+ events.append(("VM_VOLUMES_READY", dict(volumes=volumes)))
176+
177 # push the collected events
178 for event in events:
179 self.m.event_q.push(event[0], **event[1])

Subscribers

People subscribed via source and target branches