Merge lp:~mandel/ubuntuone-windows-installer/improve_u1sync_communication into lp:ubuntuone-windows-installer/beta
- improve_u1sync_communication
- Merge into beta
Proposed by
Manuel de la Peña
Status: | Merged |
---|---|
Approved by: | John Lenton |
Approved revision: | 165 |
Merged at revision: | 127 |
Proposed branch: | lp:~mandel/ubuntuone-windows-installer/improve_u1sync_communication |
Merge into: | lp:ubuntuone-windows-installer/beta |
Prerequisite: | lp:~mandel/ubuntuone-windows-installer/remove_recently_modifed_state_spaces |
Diff against target: |
391 lines (+136/-29) 9 files modified
src/Canonical.UbuntuOne.Client.Views/NotifyIcon.xaml.cs (+26/-1) src/Canonical.UbuntuOne.Client/Canonical.UbuntuOne.Client.csproj (+1/-0) src/Canonical.UbuntuOne.Client/Notification/Enums.cs (+40/-0) src/Canonical.UbuntuOne.Client/Notification/INotificationIconPresenter.cs (+19/-17) src/Canonical.UbuntuOne.Client/Notification/INotificationIconView.cs (+9/-0) src/Canonical.UbuntuOne.ProcessDispatcher/JsonMessageProcessor.cs (+7/-1) src/u1sync/main.py (+9/-1) src/u1sync/sync.py (+21/-5) src/u1sync/utils.py (+4/-4) |
To merge this branch: | bzr merge lp:~mandel/ubuntuone-windows-installer/improve_u1sync_communication |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
John Lenton (community) | Approve | ||
Review via email:
|
Commit message
Description of the change
Improve the u1sync communication.
To post a comment you must log in.
Revision history for this message
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
John Lenton (chipaca) : | # |
review:
Approve
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'src/Canonical.UbuntuOne.Client.Views/NotifyIcon.xaml.cs' | |||
2 | --- src/Canonical.UbuntuOne.Client.Views/NotifyIcon.xaml.cs 2010-11-02 22:21:27 +0000 | |||
3 | +++ src/Canonical.UbuntuOne.Client.Views/NotifyIcon.xaml.cs 2010-11-02 22:21:27 +0000 | |||
4 | @@ -86,7 +86,32 @@ | |||
5 | 86 | /// <param name="text">The text of the notification.</param> | 86 | /// <param name="text">The text of the notification.</param> |
6 | 87 | public void ShowNotification(int timeout, string title, string text) | 87 | public void ShowNotification(int timeout, string title, string text) |
7 | 88 | { | 88 | { |
9 | 89 | NotifyIcon.ShowBalloonTip(timeout, title, text, NotifyBalloonIcon.Info); | 89 | ShowNotification(timeout, title, text, NotificationType.INFO); |
10 | 90 | } | ||
11 | 91 | |||
12 | 92 | /// <summary> | ||
13 | 93 | /// Shows a notification to the user. | ||
14 | 94 | /// </summary> | ||
15 | 95 | /// <param name="timeout">The amount of time the notification will be shown.</param> | ||
16 | 96 | /// <param name="title">The title of the notification.</param> | ||
17 | 97 | /// <param name="text">The text of the actual notification.</param> | ||
18 | 98 | /// <param name="type">The type of notification sent.</param> | ||
19 | 99 | public void ShowNotification(int timeout, string title, string text, NotificationType type) | ||
20 | 100 | { | ||
21 | 101 | var icon = NotifyBalloonIcon.None; | ||
22 | 102 | switch (type) | ||
23 | 103 | { | ||
24 | 104 | case NotificationType.ERROR: | ||
25 | 105 | icon = NotifyBalloonIcon.Error; | ||
26 | 106 | break; | ||
27 | 107 | case NotificationType.WARNING: | ||
28 | 108 | icon = NotifyBalloonIcon.Warning; | ||
29 | 109 | break; | ||
30 | 110 | default: | ||
31 | 111 | icon = NotifyBalloonIcon.Info; | ||
32 | 112 | break; | ||
33 | 113 | } | ||
34 | 114 | NotifyIcon.ShowBalloonTip(timeout, title, text, icon); | ||
35 | 90 | } | 115 | } |
36 | 91 | 116 | ||
37 | 92 | /// <summary> | 117 | /// <summary> |
38 | 93 | 118 | ||
39 | === modified file 'src/Canonical.UbuntuOne.Client/Canonical.UbuntuOne.Client.csproj' | |||
40 | --- src/Canonical.UbuntuOne.Client/Canonical.UbuntuOne.Client.csproj 2010-10-19 12:34:50 +0000 | |||
41 | +++ src/Canonical.UbuntuOne.Client/Canonical.UbuntuOne.Client.csproj 2010-11-02 22:21:27 +0000 | |||
42 | @@ -74,6 +74,7 @@ | |||
43 | 74 | <Compile Include="..\Version.cs"> | 74 | <Compile Include="..\Version.cs"> |
44 | 75 | <Link>Properties\Version.cs</Link> | 75 | <Link>Properties\Version.cs</Link> |
45 | 76 | </Compile> | 76 | </Compile> |
46 | 77 | <Compile Include="Notification\Enums.cs" /> | ||
47 | 77 | <Compile Include="Notification\INotificationIconView.cs" /> | 78 | <Compile Include="Notification\INotificationIconView.cs" /> |
48 | 78 | <Compile Include="Notification\IStateMapper.cs" /> | 79 | <Compile Include="Notification\IStateMapper.cs" /> |
49 | 79 | <Compile Include="Notification\ISyncDaemonClientNotifier.cs" /> | 80 | <Compile Include="Notification\ISyncDaemonClientNotifier.cs" /> |
50 | 80 | 81 | ||
51 | === added file 'src/Canonical.UbuntuOne.Client/Notification/Enums.cs' | |||
52 | --- src/Canonical.UbuntuOne.Client/Notification/Enums.cs 1970-01-01 00:00:00 +0000 | |||
53 | +++ src/Canonical.UbuntuOne.Client/Notification/Enums.cs 2010-11-02 22:21:27 +0000 | |||
54 | @@ -0,0 +1,40 @@ | |||
55 | 1 | /* | ||
56 | 2 | * Copyright 2010 Canonical Ltd. | ||
57 | 3 | * | ||
58 | 4 | * This file is part of UbuntuOne on Windows. | ||
59 | 5 | * | ||
60 | 6 | * UbuntuOne on Windows is free software: you can redistribute it and/or modify | ||
61 | 7 | * it under the terms of the GNU Lesser General Public License version | ||
62 | 8 | * as published by the Free Software Foundation. | ||
63 | 9 | * | ||
64 | 10 | * Ubuntu One on Windows is distributed in the hope that it will be useful, | ||
65 | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
66 | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
67 | 13 | * GNU Lesser General Public License for more details. | ||
68 | 14 | * | ||
69 | 15 | * You should have received a copy of the GNU Lesser General Public License | ||
70 | 16 | * along with UbuntuOne for Windows. If not, see <http://www.gnu.org/licenses/>. | ||
71 | 17 | * | ||
72 | 18 | * Authors: Manuel de la Peña <manuel.delapena@canonical.com> | ||
73 | 19 | */ | ||
74 | 20 | namespace Canonical.UbuntuOne.Client.Notification | ||
75 | 21 | { | ||
76 | 22 | /// <summary> | ||
77 | 23 | /// Enum that contains the different types of notifications. | ||
78 | 24 | /// </summary> | ||
79 | 25 | public enum NotificationType | ||
80 | 26 | { | ||
81 | 27 | ///<summary> | ||
82 | 28 | /// Enum that states that the notification provides information. | ||
83 | 29 | ///</summary> | ||
84 | 30 | INFO, | ||
85 | 31 | /// <summary> | ||
86 | 32 | /// Enum that states that the notification provides an error. | ||
87 | 33 | /// </summary> | ||
88 | 34 | ERROR, | ||
89 | 35 | /// <summary> | ||
90 | 36 | /// Enum that states that the notification provides a warning. | ||
91 | 37 | /// </summary> | ||
92 | 38 | WARNING | ||
93 | 39 | } | ||
94 | 40 | } | ||
95 | 0 | 41 | ||
96 | === modified file 'src/Canonical.UbuntuOne.Client/Notification/INotificationIconPresenter.cs' | |||
97 | --- src/Canonical.UbuntuOne.Client/Notification/INotificationIconPresenter.cs 2010-08-30 17:30:31 +0000 | |||
98 | +++ src/Canonical.UbuntuOne.Client/Notification/INotificationIconPresenter.cs 2010-11-02 22:21:27 +0000 | |||
99 | @@ -1,20 +1,22 @@ | |||
117 | 1 | // Copyright 2010 Canonical Ltd. | 1 | /* |
118 | 2 | // | 2 | * Copyright 2010 Canonical Ltd. |
119 | 3 | // This file is part of UbuntuOne on Windows. | 3 | * |
120 | 4 | // | 4 | * This file is part of UbuntuOne on Windows. |
121 | 5 | // UbuntuOne on Windows is free software: you can redistribute it and/or modify | 5 | * |
122 | 6 | // it under the terms of the GNU Lesser General Public License version | 6 | * UbuntuOne on Windows is free software: you can redistribute it and/or modify |
123 | 7 | // as published by the Free Software Foundation. | 7 | * it under the terms of the GNU Lesser General Public License version |
124 | 8 | // | 8 | * as published by the Free Software Foundation. |
125 | 9 | // Ubuntu One on Windows is distributed in the hope that it will be useful, | 9 | * |
126 | 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * Ubuntu One on Windows is distributed in the hope that it will be useful, |
127 | 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
128 | 12 | // GNU Lesser General Public License for more details. | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
129 | 13 | // | 13 | * GNU Lesser General Public License for more details. |
130 | 14 | // You should have received a copy of the GNU Lesser General Public License | 14 | * |
131 | 15 | // along with UbuntuOne for Windows. If not, see <http://www.gnu.org/licenses/>. | 15 | * You should have received a copy of the GNU Lesser General Public License |
132 | 16 | // | 16 | * along with UbuntuOne for Windows. If not, see <http://www.gnu.org/licenses/>. |
133 | 17 | // Authors: Manuel de la Peña <manuel.delapena@canonical.com> | 17 | * |
134 | 18 | * Authors: Manuel de la Peña <manuel.delapena@canonical.com> | ||
135 | 19 | */ | ||
136 | 18 | namespace Canonical.UbuntuOne.Client.Notification | 20 | namespace Canonical.UbuntuOne.Client.Notification |
137 | 19 | { | 21 | { |
138 | 20 | /// <summary> | 22 | /// <summary> |
139 | 21 | 23 | ||
140 | === modified file 'src/Canonical.UbuntuOne.Client/Notification/INotificationIconView.cs' | |||
141 | --- src/Canonical.UbuntuOne.Client/Notification/INotificationIconView.cs 2010-10-20 23:09:36 +0000 | |||
142 | +++ src/Canonical.UbuntuOne.Client/Notification/INotificationIconView.cs 2010-11-02 22:21:27 +0000 | |||
143 | @@ -41,6 +41,15 @@ | |||
144 | 41 | void ShowNotification(int timeout, string title, string text); | 41 | void ShowNotification(int timeout, string title, string text); |
145 | 42 | 42 | ||
146 | 43 | /// <summary> | 43 | /// <summary> |
147 | 44 | /// Shows a notification to the user. | ||
148 | 45 | /// </summary> | ||
149 | 46 | /// <param name="timeout">The amount of time the notification will be shown.</param> | ||
150 | 47 | /// <param name="title">The title of the notification.</param> | ||
151 | 48 | /// <param name="text">The text of the actual notification.</param> | ||
152 | 49 | /// <param name="type">The type of notification sent.</param> | ||
153 | 50 | void ShowNotification(int timeout, string title, string text, NotificationType type); | ||
154 | 51 | |||
155 | 52 | /// <summary> | ||
156 | 44 | /// Gets and sets the list of recently modified files. | 53 | /// Gets and sets the list of recently modified files. |
157 | 45 | /// </summary> | 54 | /// </summary> |
158 | 46 | IList<string> RecentlyModifiedFiles { get; set; } | 55 | IList<string> RecentlyModifiedFiles { get; set; } |
159 | 47 | 56 | ||
160 | === modified file 'src/Canonical.UbuntuOne.ProcessDispatcher/JsonMessageProcessor.cs' | |||
161 | --- src/Canonical.UbuntuOne.ProcessDispatcher/JsonMessageProcessor.cs 2010-10-19 12:34:50 +0000 | |||
162 | +++ src/Canonical.UbuntuOne.ProcessDispatcher/JsonMessageProcessor.cs 2010-11-02 22:21:27 +0000 | |||
163 | @@ -47,7 +47,13 @@ | |||
164 | 47 | var messageObject = (JObject) message; | 47 | var messageObject = (JObject) message; |
165 | 48 | if(string.Compare((string)messageObject["type"], "notify", StringComparison.CurrentCultureIgnoreCase) == 0) | 48 | if(string.Compare((string)messageObject["type"], "notify", StringComparison.CurrentCultureIgnoreCase) == 0) |
166 | 49 | { | 49 | { |
168 | 50 | NotificationIconView.ShowNotification(10, (string)messageObject["title"], (string)messageObject["message"]); | 50 | NotificationIconView.ShowNotification(5, (string)messageObject["title"], (string)messageObject["message"], |
169 | 51 | NotificationType.INFO); | ||
170 | 52 | } | ||
171 | 53 | if(string.Compare((string)messageObject["type"], "error", StringComparison.CurrentCultureIgnoreCase) == 0) | ||
172 | 54 | { | ||
173 | 55 | NotificationIconView.ShowNotification(5, "Error", (string) messageObject["message"], | ||
174 | 56 | NotificationType.ERROR); | ||
175 | 51 | } | 57 | } |
176 | 52 | } | 58 | } |
177 | 53 | } | 59 | } |
178 | 54 | 60 | ||
179 | === modified file 'src/u1sync/main.py' | |||
180 | --- src/u1sync/main.py 2010-10-19 10:35:43 +0000 | |||
181 | +++ src/u1sync/main.py 2010-11-02 22:21:27 +0000 | |||
182 | @@ -43,7 +43,7 @@ | |||
183 | 43 | from u1sync.merge import ( | 43 | from u1sync.merge import ( |
184 | 44 | SyncMerge, ClobberServerMerge, ClobberLocalMerge, merge_trees) | 44 | SyncMerge, ClobberServerMerge, ClobberLocalMerge, merge_trees) |
185 | 45 | from u1sync.sync import download_tree, upload_tree | 45 | from u1sync.sync import download_tree, upload_tree |
187 | 46 | from u1sync.utils import safe_mkdir, send_bus_error, send_notification | 46 | from u1sync.utils import safe_mkdir, send_error, send_notification |
188 | 47 | from u1sync import metadata | 47 | from u1sync import metadata |
189 | 48 | from u1sync.constants import METADATA_DIR_NAME | 48 | from u1sync.constants import METADATA_DIR_NAME |
190 | 49 | from u1sync.ubuntuone_optparse import UbuntuOneOptionsParser | 49 | from u1sync.ubuntuone_optparse import UbuntuOneOptionsParser |
191 | @@ -335,21 +335,29 @@ | |||
192 | 335 | try: | 335 | try: |
193 | 336 | do_main(argv, UbuntuOneOptionsParser()) | 336 | do_main(argv, UbuntuOneOptionsParser()) |
194 | 337 | except AuthenticationError, e: | 337 | except AuthenticationError, e: |
195 | 338 | send_error("Authentication failed: %s" % e, e) | ||
196 | 338 | print "Authentication failed: %s" % e | 339 | print "Authentication failed: %s" % e |
197 | 339 | except ConnectionError, e: | 340 | except ConnectionError, e: |
198 | 341 | send_error("Connection failed: %s" % e, e) | ||
199 | 340 | print "Connection failed: %s" % e | 342 | print "Connection failed: %s" % e |
200 | 341 | except DirectoryNotInitializedError, e: | 343 | except DirectoryNotInitializedError, e: |
201 | 344 | send_error("Directory not initialized", e) | ||
202 | 342 | print "Directory not initialized; " \ | 345 | print "Directory not initialized; " \ |
203 | 343 | "use --init [DIRECTORY] to initialize it." | 346 | "use --init [DIRECTORY] to initialize it." |
204 | 344 | except DirectoryAlreadyInitializedError, e: | 347 | except DirectoryAlreadyInitializedError, e: |
205 | 348 | send_error("Directory already initialized.", e) | ||
206 | 345 | print "Directory already initialized." | 349 | print "Directory already initialized." |
207 | 346 | except NoSuchShareError, e: | 350 | except NoSuchShareError, e: |
208 | 351 | send_error("No matching share found.", e) | ||
209 | 347 | print "No matching share found." | 352 | print "No matching share found." |
210 | 348 | except ReadOnlyShareError, e: | 353 | except ReadOnlyShareError, e: |
211 | 354 | send_error("The selected action isn't possible on a read-only share.", e) | ||
212 | 349 | print "The selected action isn't possible on a read-only share." | 355 | print "The selected action isn't possible on a read-only share." |
213 | 350 | except (ForcedShutdown, KeyboardInterrupt), e: | 356 | except (ForcedShutdown, KeyboardInterrupt), e: |
214 | 357 | send_error("Interrupted!", e) | ||
215 | 351 | print "Interrupted!" | 358 | print "Interrupted!" |
216 | 352 | except TreesDiffer, e: | 359 | except TreesDiffer, e: |
217 | 360 | send_error("Trees differ.", e) | ||
218 | 353 | if not e.quiet: | 361 | if not e.quiet: |
219 | 354 | print "Trees differ." | 362 | print "Trees differ." |
220 | 355 | else: | 363 | else: |
221 | 356 | 364 | ||
222 | === modified file 'src/u1sync/sync.py' | |||
223 | --- src/u1sync/sync.py 2010-10-20 08:42:42 +0000 | |||
224 | +++ src/u1sync/sync.py 2010-11-02 22:21:27 +0000 | |||
225 | @@ -35,7 +35,7 @@ | |||
226 | 35 | DIRECTORY, SYMLINK) | 35 | DIRECTORY, SYMLINK) |
227 | 36 | from u1sync.genericmerge import ( | 36 | from u1sync.genericmerge import ( |
228 | 37 | MergeNode, generic_merge) | 37 | MergeNode, generic_merge) |
230 | 38 | from u1sync.utils import safe_mkdir, send_notification | 38 | from u1sync.utils import safe_mkdir, send_notification, send_error |
231 | 39 | from u1sync.client import UnsupportedOperationError | 39 | from u1sync.client import UnsupportedOperationError |
232 | 40 | 40 | ||
233 | 41 | def get_conflict_path(path, conflict_info): | 41 | def get_conflict_path(path, conflict_info): |
234 | @@ -88,10 +88,6 @@ | |||
235 | 88 | else: | 88 | else: |
236 | 89 | if not quiet: | 89 | if not quiet: |
237 | 90 | print "%s %s" % (sync_mode.symbol, display_path) | 90 | print "%s %s" % (sync_mode.symbol, display_path) |
238 | 91 | if(sync_mode.symbol == DOWNLOAD_SYMBOL): | ||
239 | 92 | send_notification("Downloading", "Downloading file '%s'" % display_path, "info") | ||
240 | 93 | elif(sync_mode.symbol == UPLOAD_SYMBOL): | ||
241 | 94 | send_notification("Uploading", "Uploading file '%s'" % display_path, "info") | ||
242 | 95 | try: | 91 | try: |
243 | 96 | create_dir = sync_mode.create_directory | 92 | create_dir = sync_mode.create_directory |
244 | 97 | node_uuid = create_dir(parent_uuid=parent_uuid, | 93 | node_uuid = create_dir(parent_uuid=parent_uuid, |
245 | @@ -241,6 +237,7 @@ | |||
246 | 241 | safe_mkdir(path) | 237 | safe_mkdir(path) |
247 | 242 | send_notification("New dir", "Creating dir %s" % path, "info") | 238 | send_notification("New dir", "Creating dir %s" % path, "info") |
248 | 243 | except OSError, e: | 239 | except OSError, e: |
249 | 240 | send_error("Error creating local directory %s" % path, e) | ||
250 | 244 | raise NodeCreateError("Error creating local directory %s: %s" % \ | 241 | raise NodeCreateError("Error creating local directory %s: %s" % \ |
251 | 245 | (path, e)) | 242 | (path, e)) |
252 | 246 | return None | 243 | return None |
253 | @@ -253,6 +250,7 @@ | |||
254 | 253 | path = get_conflict_path(path, conflict_info) | 250 | path = get_conflict_path(path, conflict_info) |
255 | 254 | content_hash = conflict_info[1] | 251 | content_hash = conflict_info[1] |
256 | 255 | try: | 252 | try: |
257 | 253 | send_notification("Downloading", "Downloading '%s'" % path, "info") | ||
258 | 256 | if node_type == SYMLINK: | 254 | if node_type == SYMLINK: |
259 | 257 | self.client.download_string(share_uuid= | 255 | self.client.download_string(share_uuid= |
260 | 258 | self.share_uuid, | 256 | self.share_uuid, |
261 | @@ -265,24 +263,30 @@ | |||
262 | 265 | filename=path) | 263 | filename=path) |
263 | 266 | except (request.StorageRequestError, UnsupportedOperationError), e: | 264 | except (request.StorageRequestError, UnsupportedOperationError), e: |
264 | 267 | if os.path.exists(path): | 265 | if os.path.exists(path): |
265 | 266 | send_error("Error downloading content for %s" % path, e) | ||
266 | 268 | raise NodeUpdateError("Error downloading content for %s: %s" %\ | 267 | raise NodeUpdateError("Error downloading content for %s: %s" %\ |
267 | 269 | (path, e)) | 268 | (path, e)) |
268 | 270 | else: | 269 | else: |
269 | 270 | send_error("Error locally creating %s" % path, e) | ||
270 | 271 | raise NodeCreateError("Error locally creating %s: %s" % \ | 271 | raise NodeCreateError("Error locally creating %s: %s" % \ |
271 | 272 | (path, e)) | 272 | (path, e)) |
272 | 273 | 273 | ||
273 | 274 | def delete_directory(self, node_uuid, path): | 274 | def delete_directory(self, node_uuid, path): |
274 | 275 | """Deletes a directory.""" | 275 | """Deletes a directory.""" |
275 | 276 | send_notification("Removing", "Removing directory '%s'" % path, "info") | ||
276 | 276 | try: | 277 | try: |
277 | 277 | os.rmdir(path) | 278 | os.rmdir(path) |
278 | 278 | except OSError, e: | 279 | except OSError, e: |
279 | 280 | send_error("Error locally deleting %s" % path, e) | ||
280 | 279 | raise NodeDeleteError("Error locally deleting %s: %s" % (path, e)) | 281 | raise NodeDeleteError("Error locally deleting %s: %s" % (path, e)) |
281 | 280 | 282 | ||
282 | 281 | def delete_file(self, node_uuid, path): | 283 | def delete_file(self, node_uuid, path): |
283 | 282 | """Deletes a file.""" | 284 | """Deletes a file.""" |
284 | 285 | send_notification("Removing", "Removing file '%s'" % path, "info") | ||
285 | 283 | try: | 286 | try: |
286 | 284 | os.unlink(path) | 287 | os.unlink(path) |
287 | 285 | except OSError, e: | 288 | except OSError, e: |
288 | 289 | send_error("Error locally deleting %s" % path, e) | ||
289 | 286 | raise NodeDeleteError("Error locally deleting %s: %s" % (path, e)) | 290 | raise NodeDeleteError("Error locally deleting %s: %s" % (path, e)) |
290 | 287 | 291 | ||
291 | 288 | 292 | ||
292 | @@ -298,10 +302,12 @@ | |||
293 | 298 | """Creates a directory on the server.""" | 302 | """Creates a directory on the server.""" |
294 | 299 | name = name_from_path(path) | 303 | name = name_from_path(path) |
295 | 300 | try: | 304 | try: |
296 | 305 | send_notification("Creating", "Creating directory '%s'" % path, "info") | ||
297 | 301 | return self.client.create_directory(share_uuid=self.share_uuid, | 306 | return self.client.create_directory(share_uuid=self.share_uuid, |
298 | 302 | parent_uuid=parent_uuid, | 307 | parent_uuid=parent_uuid, |
299 | 303 | name=name) | 308 | name=name) |
300 | 304 | except (request.StorageRequestError, UnsupportedOperationError), e: | 309 | except (request.StorageRequestError, UnsupportedOperationError), e: |
301 | 310 | send_error("Error remotely creating %s" % path, e) | ||
302 | 305 | raise NodeCreateError("Error remotely creating %s: %s" % \ | 311 | raise NodeCreateError("Error remotely creating %s: %s" % \ |
303 | 306 | (path, e)) | 312 | (path, e)) |
304 | 307 | 313 | ||
305 | @@ -319,6 +325,7 @@ | |||
306 | 319 | name=conflict_name, | 325 | name=conflict_name, |
307 | 320 | node_uuid=node_uuid) | 326 | node_uuid=node_uuid) |
308 | 321 | except (request.StorageRequestError, UnsupportedOperationError), e: | 327 | except (request.StorageRequestError, UnsupportedOperationError), e: |
309 | 328 | send_error("Error remotely renaming %s to %s" % (path, conflict_path), e) | ||
310 | 322 | raise NodeUpdateError("Error remotely renaming %s to %s: %s" %\ | 329 | raise NodeUpdateError("Error remotely renaming %s to %s: %s" %\ |
311 | 323 | (path, conflict_path, e)) | 330 | (path, conflict_path, e)) |
312 | 324 | node_uuid = None | 331 | node_uuid = None |
313 | @@ -328,6 +335,7 @@ | |||
314 | 328 | try: | 335 | try: |
315 | 329 | target = os.readlink(path) | 336 | target = os.readlink(path) |
316 | 330 | except OSError, e: | 337 | except OSError, e: |
317 | 338 | send_error("Error retrieving link target %s" % path, e) | ||
318 | 331 | raise NodeCreateError("Error retrieving link target " \ | 339 | raise NodeCreateError("Error retrieving link target " \ |
319 | 332 | "for %s: %s" % (path, e)) | 340 | "for %s: %s" % (path, e)) |
320 | 333 | else: | 341 | else: |
321 | @@ -336,6 +344,7 @@ | |||
322 | 336 | name = name_from_path(path) | 344 | name = name_from_path(path) |
323 | 337 | if node_uuid is None: | 345 | if node_uuid is None: |
324 | 338 | try: | 346 | try: |
325 | 347 | send_notification("Creating", "Remotely creating '%s'" % path, "info") | ||
326 | 339 | if node_type == SYMLINK: | 348 | if node_type == SYMLINK: |
327 | 340 | node_uuid = self.client.create_symlink(share_uuid= | 349 | node_uuid = self.client.create_symlink(share_uuid= |
328 | 341 | self.share_uuid, | 350 | self.share_uuid, |
329 | @@ -351,11 +360,13 @@ | |||
330 | 351 | parent_uuid, | 360 | parent_uuid, |
331 | 352 | name=name) | 361 | name=name) |
332 | 353 | except (request.StorageRequestError, UnsupportedOperationError), e: | 362 | except (request.StorageRequestError, UnsupportedOperationError), e: |
333 | 363 | send_error("Error remotely creating for %s" % path, e) | ||
334 | 354 | raise NodeCreateError("Error remotely creating %s: %s" % \ | 364 | raise NodeCreateError("Error remotely creating %s: %s" % \ |
335 | 355 | (path, e)) | 365 | (path, e)) |
336 | 356 | 366 | ||
337 | 357 | if old_content_hash != content_hash: | 367 | if old_content_hash != content_hash: |
338 | 358 | try: | 368 | try: |
339 | 369 | send_notification("Updating", "Uploading '%s'" % path, "info") | ||
340 | 359 | if node_type == SYMLINK: | 370 | if node_type == SYMLINK: |
341 | 360 | self.client.upload_string(share_uuid=self.share_uuid, | 371 | self.client.upload_string(share_uuid=self.share_uuid, |
342 | 361 | node_uuid=node_uuid, | 372 | node_uuid=node_uuid, |
343 | @@ -370,6 +381,7 @@ | |||
344 | 370 | old_content_hash=old_content_hash, | 381 | old_content_hash=old_content_hash, |
345 | 371 | filename=path) | 382 | filename=path) |
346 | 372 | except (request.StorageRequestError, UnsupportedOperationError), e: | 383 | except (request.StorageRequestError, UnsupportedOperationError), e: |
347 | 384 | send_error("Error uploading content for %s" % path, e) | ||
348 | 373 | raise NodeUpdateError("Error uploading content for %s: %s" % \ | 385 | raise NodeUpdateError("Error uploading content for %s: %s" % \ |
349 | 374 | (path, e)) | 386 | (path, e)) |
350 | 375 | 387 | ||
351 | @@ -377,12 +389,16 @@ | |||
352 | 377 | """Deletes a directory.""" | 389 | """Deletes a directory.""" |
353 | 378 | try: | 390 | try: |
354 | 379 | self.client.unlink(share_uuid=self.share_uuid, node_uuid=node_uuid) | 391 | self.client.unlink(share_uuid=self.share_uuid, node_uuid=node_uuid) |
355 | 392 | send_notification("Deleting", "Remotely deleting directory '%s'" % path, "info") | ||
356 | 380 | except (request.StorageRequestError, UnsupportedOperationError), e: | 393 | except (request.StorageRequestError, UnsupportedOperationError), e: |
357 | 394 | send_error("Error remotely deleting %s" % path, e) | ||
358 | 381 | raise NodeDeleteError("Error remotely deleting %s: %s" % (path, e)) | 395 | raise NodeDeleteError("Error remotely deleting %s: %s" % (path, e)) |
359 | 382 | 396 | ||
360 | 383 | def delete_file(self, node_uuid, path): | 397 | def delete_file(self, node_uuid, path): |
361 | 384 | """Deletes a file.""" | 398 | """Deletes a file.""" |
362 | 385 | try: | 399 | try: |
363 | 386 | self.client.unlink(share_uuid=self.share_uuid, node_uuid=node_uuid) | 400 | self.client.unlink(share_uuid=self.share_uuid, node_uuid=node_uuid) |
364 | 401 | send_notification("Deleting", "Remotely deleting file '%s'" % path, "info") | ||
365 | 387 | except (request.StorageRequestError, UnsupportedOperationError), e: | 402 | except (request.StorageRequestError, UnsupportedOperationError), e: |
366 | 403 | send_error("Error remotely deleting %s" % path, e) | ||
367 | 388 | raise NodeDeleteError("Error remotely deleting %s: %s" % (path, e)) | 404 | raise NodeDeleteError("Error remotely deleting %s: %s" % (path, e)) |
368 | 389 | 405 | ||
369 | === modified file 'src/u1sync/utils.py' | |||
370 | --- src/u1sync/utils.py 2010-10-19 10:35:43 +0000 | |||
371 | +++ src/u1sync/utils.py 2010-11-02 22:21:27 +0000 | |||
372 | @@ -81,14 +81,14 @@ | |||
373 | 81 | except Exception, e: | 81 | except Exception, e: |
374 | 82 | print "Error: C# client is not listening!! %s" % e.message | 82 | print "Error: C# client is not listening!! %s" % e.message |
375 | 83 | 83 | ||
377 | 84 | def send_bus_error(error_message, exception): | 84 | def send_error(error_message, exception): |
378 | 85 | message = create_error_message(error_message, exception) | 85 | message = create_error_message(error_message, exception) |
379 | 86 | send_bus_message(message) | 86 | send_bus_message(message) |
380 | 87 | 87 | ||
381 | 88 | def send_notification(title, message, type): | 88 | def send_notification(title, message, type): |
382 | 89 | message = {'type':'notify', | 89 | message = {'type':'notify', |
386 | 90 | 'title':title, | 90 | 'title':title, |
387 | 91 | 'message':message, | 91 | 'message':message, |
388 | 92 | 'notification_type':type} | 92 | 'notification_type':type} |
389 | 93 | send_bus_message(message) | 93 | send_bus_message(message) |
390 | 94 | 94 | ||
391 | 95 | \ No newline at end of file | 95 | \ No newline at end of file |