Merge lp:~thisfred/ubuntuone-client/reset-filenames into lp:ubuntuone-client

Proposed by Eric Casteleijn
Status: Rejected
Rejected by: Eric Casteleijn
Proposed branch: lp:~thisfred/ubuntuone-client/reset-filenames
Merge into: lp:ubuntuone-client
Diff against target: 703 lines (+186/-61)
4 files modified
tests/status/test_aggregator.py (+84/-14)
ubuntuone/eventlog/zg_listener.py (+2/-2)
ubuntuone/platform/linux/session.py (+1/-1)
ubuntuone/status/aggregator.py (+99/-44)
To merge this branch: bzr merge lp:~thisfred/ubuntuone-client/reset-filenames
Reviewer Review Type Date Requested Status
Facundo Batista (community) Abstain
Review via email: mp+67386@code.launchpad.net

Commit message

No longer forgets connection status after completed uploads/downloads.

Description of the change

No longer forgets connection status after completed uploads/downloads.

To post a comment you must log in.
1053. By Eric Casteleijn

forgot to save tests

Revision history for this message
Facundo Batista (facundo) wrote :

I still have the problem using this branch, see attached logs in the bug.

review: Needs Fixing
Revision history for this message
Eric Casteleijn (thisfred) wrote :

Facundo: It's a shame this bug does not solve the bug in question, but I'd still like to land it, as it improves the code and solves similar issues. If we land this I will not mark the bug as fixed, but as you can see from the commit message, it does not promise to.

Revision history for this message
Eric Casteleijn (thisfred) wrote :

s/bug does not solve/branch does not solve/

Revision history for this message
Facundo Batista (facundo) :
review: Abstain

Unmerged revisions

1053. By Eric Casteleijn

forgot to save tests

1052. By Eric Casteleijn

think I've fixed it

1051. By Eric Casteleijn

fixed reset not to set connected to False

1050. By Eric Casteleijn

fixed logging issues

1049. By Eric Casteleijn

added extensive debug logging

1048. By Eric Casteleijn

minor refactorings and cleanup

1047. By Eric Casteleijn

minor refactorings and cleanup

1046. By Eric Casteleijn

unchanged: attach bug

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'tests/status/test_aggregator.py'
--- tests/status/test_aggregator.py 2011-07-01 19:02:13 +0000
+++ tests/status/test_aggregator.py 2011-07-08 20:38:00 +0000
@@ -257,8 +257,8 @@
257 self.assertNotIn(notification,257 self.assertNotIn(notification,
258 self.toggleable.notification.notifications_shown)258 self.toggleable.notification.notifications_shown)
259259
260 def test_send_notification_passes_thru(self):260 def test_send_notification_passes_through(self):
261 """The send_notification method passes thru."""261 """The send_notification method passes through."""
262 args = (1, 2, 3, 4)262 args = (1, 2, 3, 4)
263 self.toggleable.send_notification(*args)263 self.toggleable.send_notification(*args)
264 self.assertShown(args)264 self.assertShown(args)
@@ -339,7 +339,7 @@
339 """The popup callback shows notifications."""339 """The popup callback shows notifications."""
340 self.bubble.connection_made()340 self.bubble.connection_made()
341 self.bubble.new_file_found()341 self.bubble.new_file_found()
342 self.bubble._popup()342 self.bubble.popup()
343 message = self.aggregator.build_discovery_message()343 message = self.aggregator.build_discovery_message()
344 notification = (aggregator.UBUNTUONE_TITLE, message, None, False)344 notification = (aggregator.UBUNTUONE_TITLE, message, None, False)
345 self.assertIn(notification, self.get_notifications_shown())345 self.assertIn(notification, self.get_notifications_shown())
@@ -355,7 +355,7 @@
355 def test_popup_shows_no_notification_before_connection_made(self):355 def test_popup_shows_no_notification_before_connection_made(self):
356 """The popup callback shows notifications."""356 """The popup callback shows notifications."""
357 self.bubble.new_file_found()357 self.bubble.new_file_found()
358 self.bubble._popup()358 self.bubble.popup()
359 message = self.aggregator.build_discovery_message()359 message = self.aggregator.build_discovery_message()
360 notification = (aggregator.UBUNTUONE_TITLE, message, None, False)360 notification = (aggregator.UBUNTUONE_TITLE, message, None, False)
361 self.assertNotIn(notification, self.get_notifications_shown())361 self.assertNotIn(notification, self.get_notifications_shown())
@@ -365,7 +365,7 @@
365 self.bubble.connection_made()365 self.bubble.connection_made()
366 self.bubble.connection_lost()366 self.bubble.connection_lost()
367 self.bubble.new_file_found()367 self.bubble.new_file_found()
368 self.bubble._popup()368 self.bubble.popup()
369 message = self.aggregator.build_discovery_message()369 message = self.aggregator.build_discovery_message()
370 notification = (aggregator.UBUNTUONE_TITLE, message, None, False)370 notification = (aggregator.UBUNTUONE_TITLE, message, None, False)
371 self.assertNotIn(notification, self.get_notifications_shown())371 self.assertNotIn(notification, self.get_notifications_shown())
@@ -374,7 +374,7 @@
374 """The notification is printed in the debug log."""374 """The notification is printed in the debug log."""
375 self.bubble.connection_made()375 self.bubble.connection_made()
376 self.bubble.new_file_found()376 self.bubble.new_file_found()
377 self.bubble._popup()377 self.bubble.popup()
378 msg = "notification shown: %s" % self.get_notifications_shown()[0][1]378 msg = "notification shown: %s" % self.get_notifications_shown()[0][1]
379 self.assertTrue(self.handler.check_debug(msg))379 self.assertTrue(self.handler.check_debug(msg))
380380
@@ -466,9 +466,9 @@
466 """The update callback updates notifications."""466 """The update callback updates notifications."""
467 self.bubble.connection_made()467 self.bubble.connection_made()
468 self.bubble.new_file_found()468 self.bubble.new_file_found()
469 self.bubble._popup()469 self.bubble.popup()
470 self.bubble.new_file_found()470 self.bubble.new_file_found()
471 self.bubble._update()471 self.bubble.update()
472 message = self.aggregator.build_discovery_message()472 message = self.aggregator.build_discovery_message()
473 notification = (aggregator.UBUNTUONE_TITLE, message, None, False)473 notification = (aggregator.UBUNTUONE_TITLE, message, None, False)
474 self.assertIn(notification, self.get_notifications_shown())474 self.assertIn(notification, self.get_notifications_shown())
@@ -477,9 +477,9 @@
477 """The notification is logged when _update is called."""477 """The notification is logged when _update is called."""
478 self.bubble.connection_made()478 self.bubble.connection_made()
479 self.bubble.new_file_found()479 self.bubble.new_file_found()
480 self.bubble._popup()480 self.bubble.popup()
481 self.bubble.new_file_found()481 self.bubble.new_file_found()
482 self.bubble._update()482 self.bubble.update()
483 msg = "notification updated: %s" % self.get_notifications_shown()[1][1]483 msg = "notification updated: %s" % self.get_notifications_shown()[1][1]
484 self.assertTrue(self.handler.check_debug(msg))484 self.assertTrue(self.handler.check_debug(msg))
485485
@@ -494,7 +494,6 @@
494 self.clock = PatchedClock()494 self.clock = PatchedClock()
495 self.aggregator = FakeStatusAggregator(clock=self.clock)495 self.aggregator = FakeStatusAggregator(clock=self.clock)
496 self.bubble = aggregator.FinalStatusBubble(self.aggregator)496 self.bubble = aggregator.FinalStatusBubble(self.aggregator)
497 self.addCleanup(self.bubble.cleanup)
498497
499 def test_notification_not_shown_initially(self):498 def test_notification_not_shown_initially(self):
500 """The notification is not shown initially."""499 """The notification is not shown initially."""
@@ -1181,6 +1180,9 @@
1181 def connection_lost(self):1180 def connection_lost(self):
1182 """Connection lost."""1181 """Connection lost."""
11831182
1183 def set_idle(self):
1184 """Reset this bubble to the initial state."""
1185
11841186
1185class FakeFinalBubble(object):1187class FakeFinalBubble(object):
1186 """A fake FinalStatusBubble."""1188 """A fake FinalStatusBubble."""
@@ -1229,15 +1231,17 @@
1229 self.assertEqual(0, self.aggregator.download_done)1231 self.assertEqual(0, self.aggregator.download_done)
1230 self.assertEqual(0, self.aggregator.upload_done)1232 self.assertEqual(0, self.aggregator.upload_done)
1231 self.assertEqual(0, len(self.aggregator.files_uploading))1233 self.assertEqual(0, len(self.aggregator.files_uploading))
1234 self.assertEqual('', self.aggregator.uploading_filename)
1232 self.assertEqual(0, len(self.aggregator.files_downloading))1235 self.assertEqual(0, len(self.aggregator.files_downloading))
1236 self.assertEqual('', self.aggregator.downloading_filename)
1237 self.assertIdentical(None, self.aggregator.queue_done_timer)
1233 self.assertEqual({}, self.aggregator.progress)1238 self.assertEqual({}, self.aggregator.progress)
1234 self.assertEqual({}, self.aggregator.to_do)1239 self.assertEqual({}, self.aggregator.to_do)
1235 self.assertIdentical(None, self.aggregator.queue_done_timer)
12361240
1237 def assertMiscCommandQueued(self, fc):1241 def assertMiscCommandQueued(self, fc):
1238 """Assert that some command was queued."""1242 """Assert that some command was queued."""
1239 self.assertEqual(len(self.aggregator.to_do), 1)1243 self.assertEqual(len(self.aggregator.to_do), 1)
1240 message = "queueing command (total: 1): %s" % fc.__class__.__name__1244 message = "command %s started (total: 0/1)" % fc.__class__.__name__
1241 self.assertEqual(fc.deflated_size, sum(self.aggregator.to_do.values()))1245 self.assertEqual(fc.deflated_size, sum(self.aggregator.to_do.values()))
1242 self.assertTrue(self.handler.check_debug(message))1246 self.assertTrue(self.handler.check_debug(message))
1243 self.assertTrue(self.aggregator.progress_bar.visible)1247 self.assertTrue(self.aggregator.progress_bar.visible)
@@ -1246,7 +1250,7 @@
1246 """Assert that some command was unqueued."""1250 """Assert that some command was unqueued."""
1247 self.assertEqual(1251 self.assertEqual(
1248 1, self.aggregator.download_done + self.aggregator.upload_done)1252 1, self.aggregator.download_done + self.aggregator.upload_done)
1249 message = "unqueueing command: %s" % fc.__class__.__name__1253 message = "command %s done (total: 1/1)" % fc.__class__.__name__
1250 self.assertTrue(self.handler.check_debug(message))1254 self.assertTrue(self.handler.check_debug(message))
12511255
1252 def test_counters_start_at_zero(self):1256 def test_counters_start_at_zero(self):
@@ -1565,3 +1569,69 @@
1565 self.assertEqual(0, len(notifications_shown))1569 self.assertEqual(0, len(notifications_shown))
1566 sf.queue_done()1570 sf.queue_done()
1567 self.assertEqual(0, len(notifications_shown))1571 self.assertEqual(0, len(notifications_shown))
1572
1573 def test_queue_done_resets_filename(self):
1574 """Bug LP: #807005"""
1575 self.patch(aggregator, "ToggleableNotification",
1576 FakeNotificationSingleton())
1577 self.patch(aggregator, "UbuntuOneLauncher", FakeLauncher)
1578 self.patch(aggregator.session, "Inhibitor", FakeInhibitor)
1579 clock = PatchedClock()
1580 upload = FakeCommand(path='upload.foo')
1581 sf = aggregator.StatusFrontend(clock=clock)
1582 sf.server_connection_made()
1583 sf.set_show_all_notifications(True)
1584 sf.upload_started(upload)
1585 notifications_shown = (
1586 sf.aggregator.file_discovery_bubble.
1587 notification.notifications_shown)
1588 # no notifications shown yet
1589 self.assertEqual(0, len(notifications_shown))
1590 clock.advance(aggregator.FileDiscoveryGatheringState.initial_timeout)
1591 # files found notification
1592 self.assertEqual(1, len(notifications_shown))
1593 sf.upload_finished(upload)
1594 sf.queue_done()
1595 clock.advance(sf.aggregator.finished_delay * 2)
1596 self.assertEqual(2, len(notifications_shown))
1597 final_text = notifications_shown[-1][1]
1598 upload2 = FakeCommand(path='upload.bar')
1599 sf.upload_started(upload2)
1600 # no notifications shown yet
1601 self.assertEqual(2, len(notifications_shown))
1602 clock.advance(aggregator.FileDiscoveryGatheringState.initial_timeout)
1603 # files found notification
1604 self.assertEqual(3, len(notifications_shown))
1605 sf.upload_finished(upload2)
1606 sf.queue_done()
1607 clock.advance(sf.aggregator.finished_delay * 2)
1608 self.assertEqual(4, len(notifications_shown))
1609 self.assertNotEqual(final_text, notifications_shown[-1][1])
1610
1611 def test_queue_done_resets_filename2(self):
1612 """Bug LP: #807005"""
1613 self.patch(aggregator, "ToggleableNotification",
1614 FakeNotificationSingleton())
1615 self.patch(aggregator, "UbuntuOneLauncher", FakeLauncher)
1616 self.patch(aggregator.session, "Inhibitor", FakeInhibitor)
1617 clock = PatchedClock()
1618 upload = FakeCommand(path='upload.foo')
1619 sf = aggregator.StatusFrontend(clock=clock)
1620 sf.server_connection_made()
1621 sf.set_show_all_notifications(True)
1622 sf.upload_started(upload)
1623 sf.upload_started(upload)
1624 sf.upload_started(upload)
1625 notifications_shown = (
1626 sf.aggregator.file_discovery_bubble.
1627 notification.notifications_shown)
1628 # no notifications shown yet
1629 self.assertEqual(0, len(notifications_shown))
1630 clock.advance(
1631 aggregator.FileDiscoveryGatheringState.initial_timeout)
1632 # files found notification
1633 self.assertEqual(1, len(notifications_shown))
1634 sf.upload_finished(upload)
1635 sf.queue_done()
1636 clock.advance(sf.aggregator.finished_delay * 2)
1637 self.assertEqual(2, len(notifications_shown))
15681638
=== modified file 'ubuntuone/eventlog/zg_listener.py'
--- ubuntuone/eventlog/zg_listener.py 2011-03-22 20:01:59 +0000
+++ ubuntuone/eventlog/zg_listener.py 2011-07-08 20:38:00 +0000
@@ -59,7 +59,7 @@
59 self.newly_created_local_files = set()59 self.newly_created_local_files = set()
6060
61 def handle_AQ_CREATE_SHARE_OK(self, share_id, marker):61 def handle_AQ_CREATE_SHARE_OK(self, share_id, marker):
62 """Log the 'directory shared thru the server' event."""62 """Log the 'directory shared through the server' event."""
63 share_id = str(share_id)63 share_id = str(share_id)
64 share = self.vm.shared.get(share_id)64 share = self.vm.shared.get(share_id)
65 if not share:65 if not share:
@@ -68,7 +68,7 @@
68 self.log_folder_shared(share, share_id)68 self.log_folder_shared(share, share_id)
6969
70 def handle_AQ_SHARE_INVITATION_SENT(self, marker):70 def handle_AQ_SHARE_INVITATION_SENT(self, marker):
71 """Log the 'directory shared thru http' event."""71 """Log the 'directory shared through http' event."""
72 share = self.vm.marker_share_map[marker]72 share = self.vm.marker_share_map[marker]
73 mdo = self.fsm.get_by_mdid(marker)73 mdo = self.fsm.get_by_mdid(marker)
74 self.log_folder_shared(share, mdo.share_id)74 self.log_folder_shared(share, mdo.share_id)
7575
=== modified file 'ubuntuone/platform/linux/session.py'
--- ubuntuone/platform/linux/session.py 2011-02-22 23:57:51 +0000
+++ ubuntuone/platform/linux/session.py 2011-07-08 20:38:00 +0000
@@ -15,7 +15,7 @@
15#15#
16# You should have received a copy of the GNU General Public License along16# You should have received a copy of the GNU General Public License along
17# with this program. If not, see <http://www.gnu.org/licenses/>.17# with this program. If not, see <http://www.gnu.org/licenses/>.
18"""Inhibit session logout when busy thru the Gnome Session DBus service."""18"""Inhibit session logout when busy through the Gnome Session DBus service."""
1919
20import dbus20import dbus
2121
2222
=== modified file 'ubuntuone/status/aggregator.py'
--- ubuntuone/status/aggregator.py 2011-07-07 13:10:02 +0000
+++ ubuntuone/status/aggregator.py 2011-07-08 20:38:00 +0000
@@ -51,6 +51,7 @@
51 """Set the launcher to urgent to alert the user."""51 """Set the launcher to urgent to alert the user."""
52 launcher = UbuntuOneLauncher()52 launcher = UbuntuOneLauncher()
53 launcher.set_urgent()53 launcher.set_urgent()
54 logger.debug("Launcher set to urgent.")
5455
5556
56def files_being_uploaded(filename, files_uploading):57def files_being_uploaded(filename, files_uploading):
@@ -130,9 +131,14 @@
130 self.notification = Notification()131 self.notification = Notification()
131132
132 def send_notification(self, *args):133 def send_notification(self, *args):
133 """Passthru the notification."""134 """Pass through the notification."""
134 if self.notification_switch.enabled:135 if self.notification_switch.enabled:
136 logger.debug(
137 "Displayed notification with arguments %r.", args)
135 return self.notification.send_notification(*args)138 return self.notification.send_notification(*args)
139 logger.debug(
140 "Asked to display notification with arguments %r, but "
141 "notifications switched off.", args)
136142
137143
138class NotificationSwitch(object):144class NotificationSwitch(object):
@@ -150,10 +156,12 @@
150 def enable_notifications(self):156 def enable_notifications(self):
151 """Turn the switch on."""157 """Turn the switch on."""
152 self.enabled = True158 self.enabled = True
159 logger.debug("Notifications enabled.")
153160
154 def disable_notifications(self):161 def disable_notifications(self):
155 """Turn the switch off."""162 """Turn the switch off."""
156 self.enabled = False163 self.enabled = False
164 logger.debug("Notifications disabled.")
157165
158166
159class StatusEvent(object):167class StatusEvent(object):
@@ -187,7 +195,7 @@
187 def many(self, events):195 def many(self, events):
188 """Show the number of files if many event of this type."""196 """Show the number of files if many event of this type."""
189 no_of_files = len(events)197 no_of_files = len(events)
190 gettext.dngettext(198 return gettext.dngettext(
191 GETTEXT_PACKAGE,199 GETTEXT_PACKAGE,
192 "%(event_count)d file was just made public.",200 "%(event_count)d file was just made public.",
193 "%(event_count)d files were just made public.",201 "%(event_count)d files were just made public.",
@@ -203,7 +211,7 @@
203 def many(self, events):211 def many(self, events):
204 """Show the number of files if many event of this type."""212 """Show the number of files if many event of this type."""
205 no_of_files = len(events)213 no_of_files = len(events)
206 gettext.dngettext(214 return gettext.dngettext(
207 GETTEXT_PACKAGE,215 GETTEXT_PACKAGE,
208 "%(event_count)d file is no longer published.",216 "%(event_count)d file is no longer published.",
209 "%(event_count)d files are no longer published.",217 "%(event_count)d files are no longer published.",
@@ -218,7 +226,7 @@
218 def many(self, events):226 def many(self, events):
219 """Show the number of files if many event of this type."""227 """Show the number of files if many event of this type."""
220 no_of_files = len(events)228 no_of_files = len(events)
221 gettext.dngettext(229 return gettext.dngettext(
222 GETTEXT_PACKAGE,230 GETTEXT_PACKAGE,
223 "Found %(event_count)d new cloud folder.",231 "Found %(event_count)d new cloud folder.",
224 "Found %(event_count)d new cloud folders.",232 "Found %(event_count)d new cloud folders.",
@@ -288,21 +296,30 @@
288 def cancel_if_active(self, call):296 def cancel_if_active(self, call):
289 """Cancel a call if it is active."""297 """Cancel a call if it is active."""
290 if call.active():298 if call.active():
299 logger.debug('callback %r cancelled.', call.func)
291 call.cancel()300 call.cancel()
292301
293 def cleanup(self):302 def cleanup(self):
294 """Cancel all active calls."""303 """Cancel all active calls."""
295 self.cancel_if_active(self.delay_call)304 self.cancel_if_active(self.delay_call)
305 logger.debug('%r cleaned up.', self)
296306
297 def callback(self, result=None):307 def callback(self, result=None):
298 """Make sure the timers are stopped when firing the callback."""308 """Make sure the timers are stopped when firing the callback."""
299 self.cleanup()309 self.cleanup()
300 defer.Deferred.callback(self, result)310 defer.Deferred.callback(self, result)
301311
312 def errback(self, failure=None):
313 """Log the failure."""
314 logger.error('Failure in %s %r: %r', self.__class__, self, failure)
315 defer.Deferred.errback(self, failure)
316
302 def reset(self):317 def reset(self):
303 """Reset the delay."""318 """Reset the delay."""
304 if not self.called:319 if not self.called:
305 self.delay_call.reset(self.delay)320 self.delay_call.reset(self.delay)
321 logger.debug(
322 '%s %r delay reset to %.2f.', self.__class__, self, self.delay)
306323
307 @property324 @property
308 def active(self):325 def active(self):
@@ -345,7 +362,7 @@
345362
346 def new_file_found(self):363 def new_file_found(self):
347 """New files found."""364 """New files found."""
348 self.bubble._start()365 self.bubble.start()
349366
350367
351class FileDiscoveryGatheringState(FileDiscoveryBaseState):368class FileDiscoveryGatheringState(FileDiscoveryBaseState):
@@ -365,7 +382,7 @@
365 def _timeout(self, result):382 def _timeout(self, result):
366 """Show the notification bubble."""383 """Show the notification bubble."""
367 self.cleanup()384 self.cleanup()
368 self.bubble._popup()385 self.bubble.popup()
369386
370 def new_file_found(self):387 def new_file_found(self):
371 """New files found."""388 """New files found."""
@@ -396,7 +413,7 @@
396413
397 def _update(self, result):414 def _update(self, result):
398 """The bubble should be updated."""415 """The bubble should be updated."""
399 self.bubble._update()416 self.bubble.update()
400417
401 def new_file_found(self):418 def new_file_found(self):
402 """New files found."""419 """New files found."""
@@ -424,7 +441,7 @@
424441
425 def _timeout(self, result):442 def _timeout(self, result):
426 """Move the notification to the idle state."""443 """Move the notification to the idle state."""
427 self.bubble._set_idle()444 self.bubble.set_idle()
428445
429 def cleanup(self):446 def cleanup(self):
430 """Clean up the timers."""447 """Clean up the timers."""
@@ -449,25 +466,29 @@
449 self.files_found = False466 self.files_found = False
450 self.clock = clock467 self.clock = clock
451 self.status_aggregator = status_aggregator468 self.status_aggregator = status_aggregator
452 self._set_idle()469 self.set_idle()
453 self.notification = None470 self.notification = None
454471
455 def _change_state(self, new_state_class):472 def _change_state(self, new_state_class):
456 """Change to a new state."""473 """Change to a new state."""
457 if self.state:474 if self.state:
458 self.state.cleanup()475 self.state.cleanup()
476 old_state = self.state.__class__
459 self.state = new_state_class(self)477 self.state = new_state_class(self)
478 logger.debug(
479 "FileDiscoveryBubble state changed from %s to %s",
480 old_state, new_state_class)
460481
461 def _set_idle(self):482 def set_idle(self):
462 """Reset this bubble to the initial state."""483 """Reset this bubble to the initial state."""
463 self._change_state(FileDiscoveryIdleState)484 self._change_state(FileDiscoveryIdleState)
464485
465 def _start(self):486 def start(self):
466 """The first file was found, so start gathering."""487 """The first file was found, so start gathering."""
467 self.notification = self.status_aggregator.get_notification()488 self.notification = self.status_aggregator.get_notification()
468 self._change_state(FileDiscoveryGatheringState)489 self._change_state(FileDiscoveryGatheringState)
469490
470 def _popup(self):491 def popup(self):
471 """Display the notification."""492 """Display the notification."""
472 if not self.connected:493 if not self.connected:
473 return494 return
@@ -477,7 +498,7 @@
477 logger.debug("notification shown: %s", text)498 logger.debug("notification shown: %s", text)
478 self._change_state(FileDiscoveryUpdateState)499 self._change_state(FileDiscoveryUpdateState)
479500
480 def _update(self):501 def update(self):
481 """Update the notification."""502 """Update the notification."""
482 if not self.connected:503 if not self.connected:
483 return504 return
@@ -498,7 +519,7 @@
498 """Connection made."""519 """Connection made."""
499 self.connected = True520 self.connected = True
500 if self.files_found:521 if self.files_found:
501 self._popup()522 self.popup()
502523
503 def connection_lost(self):524 def connection_lost(self):
504 """Connection lost."""525 """Connection lost."""
@@ -512,6 +533,7 @@
512533
513class ProgressBar(object):534class ProgressBar(object):
514 """Update a progressbar no more than 10 times a second."""535 """Update a progressbar no more than 10 times a second."""
536
515 pulsating = True537 pulsating = True
516 visible = False538 visible = False
517 progress = 0.0539 progress = 0.0
@@ -534,11 +556,11 @@
534 self.timer.cleanup()556 self.timer.cleanup()
535 self.timer = None557 self.timer = None
536558
537 def _timeout(self, result):559 def _timeout(self, _):
538 """The aggregating timer has expired, so update the UI."""560 """The aggregating timer has expired, so update the UI."""
539 self.timer = None561 self.timer = None
540 self.launcher.set_progress(self.progress)562 self.launcher.set_progress(self.progress)
541 logger.debug("progressbar updated: %f", self.progress)563 logger.debug("progressbar set to: %.2f", self.progress)
542564
543 def set_progress(self, progress):565 def set_progress(self, progress):
544 """Steps amount changed. Set up a timer if there isn't one ticking."""566 """Steps amount changed. Set up a timer if there isn't one ticking."""
@@ -579,9 +601,6 @@
579 """Initialize this instance."""601 """Initialize this instance."""
580 self.status_aggregator = status_aggregator602 self.status_aggregator = status_aggregator
581603
582 def cleanup(self):
583 """Clean up this instance."""
584
585 def show(self):604 def show(self):
586 """Show the final status notification."""605 """Show the final status notification."""
587 self.notification = self.status_aggregator.get_notification()606 self.notification = self.status_aggregator.get_notification()
@@ -601,17 +620,15 @@
601620
602 file_discovery_bubble = None621 file_discovery_bubble = None
603 final_status_bubble = None622 final_status_bubble = None
623 queue_done_timer = None
624 finished_delay = 10
604625
605 def __init__(self, clock=reactor):626 def __init__(self, clock=reactor):
606 """Initialize this instance."""627 """Initialize this instance."""
607 self.clock = clock628 self.clock = clock
608 self.notification_switch = NotificationSwitch()629 self.notification_switch = NotificationSwitch()
609 self.queue_done_timer = None
610 self.reset()
611 self.progress_bar = ProgressBar(clock=self.clock)630 self.progress_bar = ProgressBar(clock=self.clock)
612 self.finished_delay = 10631 self.reset()
613 self.progress = {}
614 self.to_do = {}
615632
616 def get_notification(self):633 def get_notification(self):
617 """Create a new toggleable notification object."""634 """Create a new toggleable notification object."""
@@ -629,17 +646,17 @@
629 if self.queue_done_timer is not None:646 if self.queue_done_timer is not None:
630 self.queue_done_timer.cleanup()647 self.queue_done_timer.cleanup()
631 self.queue_done_timer = None648 self.queue_done_timer = None
632
633 if self.file_discovery_bubble:649 if self.file_discovery_bubble:
634 self.file_discovery_bubble.cleanup()650 self.file_discovery_bubble.cleanup()
635 self.file_discovery_bubble = FileDiscoveryBubble(self,651 self.file_discovery_bubble.set_idle()
636 clock=self.clock)652 else:
637653 self.file_discovery_bubble = FileDiscoveryBubble(
638 if self.final_status_bubble:654 self, clock=self.clock)
639 self.final_status_bubble.cleanup()
640 self.final_status_bubble = FinalStatusBubble(self)655 self.final_status_bubble = FinalStatusBubble(self)
641 self.progress = {}656 self.progress = {}
642 self.to_do = {}657 self.to_do = {}
658 logger.debug("All status aggregation information reset.")
659
643 # pylint: enable=W0201660 # pylint: enable=W0201
644661
645 def get_discovery_message(self):662 def get_discovery_message(self):
@@ -674,9 +691,9 @@
674691
675 def _queue_done(self, _):692 def _queue_done(self, _):
676 """Show final bubble and reset counters."""693 """Show final bubble and reset counters."""
694 logger.debug("queue done callback fired")
677 self.queue_done_timer.cleanup()695 self.queue_done_timer.cleanup()
678 self.queue_done_timer = None696 self.queue_done_timer = None
679 logger.debug("queue done callback fired")
680 if self.upload_done + self.download_done > 0:697 if self.upload_done + self.download_done > 0:
681 self.final_status_bubble.show()698 self.final_status_bubble.show()
682 self.progress_bar.completed()699 self.progress_bar.completed()
@@ -685,15 +702,16 @@
685 def queue_done(self):702 def queue_done(self):
686 """Queue is finished."""703 """Queue is finished."""
687 if not self.to_do:704 if not self.to_do:
705 logger.debug("queue done but no events to process.")
688 return706 return
689 if self.queue_done_timer is None:707 if self.queue_done_timer is None:
690 logger.debug("queue done callback added")
691 self.queue_done_timer = Timer(708 self.queue_done_timer = Timer(
692 self.finished_delay, clock=self.clock)709 self.finished_delay, clock=self.clock)
693 self.queue_done_timer.addCallback(self._queue_done)710 self.queue_done_timer.addCallback(self._queue_done)
711 logger.debug("queue done callback added")
694 return712 return
713 self.queue_done_timer.reset()
695 logger.debug("queue done callback reset")714 logger.debug("queue done callback reset")
696 self.queue_done_timer.reset()
697715
698 def update_progressbar(self):716 def update_progressbar(self):
699 """Update the counters of the progressbar."""717 """Update the counters of the progressbar."""
@@ -701,6 +719,9 @@
701 progress = float(719 progress = float(
702 sum(self.progress.values())) / sum(self.to_do.values())720 sum(self.progress.values())) / sum(self.to_do.values())
703 self.progress_bar.set_progress(progress)721 self.progress_bar.set_progress(progress)
722 return
723 logger.debug(
724 "Update progress bar called while we have zero todo items.")
704725
705 def download_started(self, command):726 def download_started(self, command):
706 """A download just started."""727 """A download just started."""
@@ -711,15 +732,21 @@
711 if command.deflated_size is not None:732 if command.deflated_size is not None:
712 self.to_do[733 self.to_do[
713 (command.share_id, command.node_id)] = command.deflated_size734 (command.share_id, command.node_id)] = command.deflated_size
735 logger.debug(
736 'to_do[(%s, %s)] set to %i', command.share_id,
737 command.node_id, command.deflated_size)
714 # pylint: disable=W0201738 # pylint: disable=W0201
715 if not self.downloading_filename:739 if not self.downloading_filename:
716 self.downloading_filename = self.files_downloading[0].path.split(740 self.downloading_filename = self.files_downloading[0].path.split(
717 os.path.sep)[-1]741 os.path.sep)[-1]
742 logger.debug(
743 'downloading_filename set to %s' % self.downloading_filename)
718 # pylint: enable=W0201744 # pylint: enable=W0201
719 self.update_progressbar()745 self.update_progressbar()
720 logger.debug(746 logger.debug(
721 "queueing command (total: %d): %s",747 "command %s started (total: %d/%d)",
722 len(self.to_do), command.__class__.__name__)748 command.__class__.__name__, self.download_done + self.upload_done,
749 len(self.to_do))
723 self.file_discovery_bubble.new_file_found()750 self.file_discovery_bubble.new_file_found()
724751
725 def download_finished(self, command):752 def download_finished(self, command):
@@ -730,7 +757,10 @@
730 if command.deflated_size is not None:757 if command.deflated_size is not None:
731 self.progress[758 self.progress[
732 (command.share_id, command.node_id)] = command.deflated_size759 (command.share_id, command.node_id)] = command.deflated_size
733 logger.debug("unqueueing command: %s", command.__class__.__name__)760 logger.debug(
761 "command %s done (total: %d/%d)",
762 command.__class__.__name__, self.download_done + self.upload_done,
763 len(self.to_do))
734 self.update_progressbar()764 self.update_progressbar()
735765
736 def upload_started(self, command):766 def upload_started(self, command):
@@ -742,15 +772,21 @@
742 if command.deflated_size is not None:772 if command.deflated_size is not None:
743 self.to_do[773 self.to_do[
744 (command.share_id, command.node_id)] = command.deflated_size774 (command.share_id, command.node_id)] = command.deflated_size
775 logger.debug(
776 'to_do[(%s, %s)] set to %i', command.share_id,
777 command.node_id, command.deflated_size)
745 # pylint: disable=W0201778 # pylint: disable=W0201
746 if not self.uploading_filename:779 if not self.uploading_filename:
747 self.uploading_filename = self.files_uploading[0].path.split(780 self.uploading_filename = self.files_uploading[0].path.split(
748 os.path.sep)[-1]781 os.path.sep)[-1]
782 logger.debug(
783 'uploading_filename set to %s' % self.uploading_filename)
749 # pylint: enable=W0201784 # pylint: enable=W0201
750 self.update_progressbar()785 self.update_progressbar()
751 logger.debug(786 logger.debug(
752 "queueing command (total: %d): %s", len(self.to_do),787 "command %s started (total: %d/%d)",
753 command.__class__.__name__)788 command.__class__.__name__, self.download_done + self.upload_done,
789 len(self.to_do))
754 self.file_discovery_bubble.new_file_found()790 self.file_discovery_bubble.new_file_found()
755791
756 def upload_finished(self, command):792 def upload_finished(self, command):
@@ -761,7 +797,10 @@
761 if command.deflated_size is not None:797 if command.deflated_size is not None:
762 self.progress[798 self.progress[
763 (command.share_id, command.node_id)] = command.deflated_size799 (command.share_id, command.node_id)] = command.deflated_size
764 logger.debug("unqueueing command: %s", command.__class__.__name__)800 logger.debug(
801 "command %s done (total: %d/%d)",
802 command.__class__.__name__, self.download_done + self.upload_done,
803 len(self.to_do))
765 self.update_progressbar()804 self.update_progressbar()
766805
767 def progress_made(self, share_id, node_id, n_bytes_written, deflated_size):806 def progress_made(self, share_id, node_id, n_bytes_written, deflated_size):
@@ -794,48 +833,61 @@
794833
795 def file_published(self, public_url):834 def file_published(self, public_url):
796 """A file was published."""835 """A file was published."""
836 logger.debug('file published event received. url: %s', public_url)
797 status_event = FilePublishingStatus(new_public_url=public_url)837 status_event = FilePublishingStatus(new_public_url=public_url)
798 self.notification.send_notification(838 self.notification.send_notification(
799 UBUNTUONE_TITLE, status_event.one())839 UBUNTUONE_TITLE, status_event.one())
800840
801 def file_unpublished(self, public_url): # pylint: disable=W0613841 def file_unpublished(self, public_url): # pylint: disable=W0613
802 """A file was unpublished."""842 """A file was unpublished."""
843 logger.debug('file unpublished event received. url: %s', public_url)
803 self.notification.send_notification(844 self.notification.send_notification(
804 UBUNTUONE_TITLE, FileUnpublishingStatus().one())845 UBUNTUONE_TITLE, FileUnpublishingStatus().one())
805846
806 def download_started(self, command):847 def download_started(self, command):
807 """A file was queued for download."""848 """A file was queued for download."""
849 logger.debug('download started event received. command: %r', command)
808 self.aggregator.download_started(command)850 self.aggregator.download_started(command)
809851
810 def download_finished(self, command):852 def download_finished(self, command):
811 """A file download was unqueued."""853 """A file download was unqueued."""
854 logger.debug('download finished event received. command: %r', command)
812 self.aggregator.download_finished(command)855 self.aggregator.download_finished(command)
813856
814 def upload_started(self, command):857 def upload_started(self, command):
815 """A file was queued for upload."""858 """A file was queued for upload."""
859 logger.debug('upload started event received. command: %r', command)
816 self.aggregator.upload_started(command)860 self.aggregator.upload_started(command)
817861
818 def upload_finished(self, command):862 def upload_finished(self, command):
819 """A file upload was unqueued."""863 """A file upload was unqueued."""
864 logger.debug('upload finished event received. command: %r', command)
820 self.aggregator.upload_finished(command)865 self.aggregator.upload_finished(command)
821866
822 def progress_made(self, share_id, node_id, n_bytes_written, deflated_size):867 def progress_made(self, share_id, node_id, n_bytes_written, deflated_size):
823 """Progress made on up- or download."""868 """Progress made on up- or download."""
869 logger.debug(
870 'progress made event received. share_id %s, node_id %s, '
871 'n_bytes_written %i, deflated_size %i',
872 share_id, node_id, n_bytes_written, deflated_size)
824 self.aggregator.progress_made(873 self.aggregator.progress_made(
825 share_id, node_id, n_bytes_written, deflated_size)874 share_id, node_id, n_bytes_written, deflated_size)
826875
827 def queue_done(self):876 def queue_done(self):
828 """The queue is empty."""877 """The queue is empty."""
878 logger.debug('queue done event received.')
829 self.aggregator.queue_done()879 self.aggregator.queue_done()
830880
831 def new_share_available(self, share):881 def new_share_available(self, share):
832 """A new share is available for subscription."""882 """A new share is available for subscription."""
883 logger.debug('new share available event received. share: %r', share)
833 self.messaging.show_message(share.other_visible_name)884 self.messaging.show_message(share.other_visible_name)
834 self.notification.send_notification(885 self.notification.send_notification(
835 UBUNTUONE_TITLE, ShareAvailableStatus(share=share).one())886 UBUNTUONE_TITLE, ShareAvailableStatus(share=share).one())
836887
837 def new_udf_available(self, udf):888 def new_udf_available(self, udf):
838 """A new udf is available for subscription."""889 """A new udf is available for subscription."""
890 logger.debug('new udf available event received. udf: %r', udf)
839 if udf.subscribed:891 if udf.subscribed:
840 return892 return
841 self.notification.send_notification(893 self.notification.send_notification(
@@ -843,22 +895,24 @@
843895
844 def server_connection_lost(self):896 def server_connection_lost(self):
845 """The client lost the connection to the server."""897 """The client lost the connection to the server."""
846 logger.debug("server connection lost")898 logger.debug("server connection lost event received.")
847 self.aggregator.connection_lost()899 self.aggregator.connection_lost()
848900
849 def server_connection_made(self):901 def server_connection_made(self):
850 """The client made the connection to the server."""902 """The client made the connection to the server."""
851 logger.debug("server connection made")903 logger.debug("server connection made event received.")
852 self.aggregator.connection_made()904 self.aggregator.connection_made()
853905
854 def udf_quota_exceeded(self, volume_dict):906 def udf_quota_exceeded(self, volume_dict):
855 """Quota exceeded in UDF."""907 """Quota exceeded in UDF."""
856 logger.debug("UDF quota exceeded for volume %r." % volume_dict)908 logger.debug(
909 "UDF quota exceeded event received. volume: %r.", volume_dict)
857 alert_user()910 alert_user()
858911
859 def share_quota_exceeded(self, volume_dict):912 def share_quota_exceeded(self, volume_dict):
860 """Sharing user's quota exceeded in share."""913 """Sharing user's quota exceeded in share."""
861 logger.debug("Share quota exceeded for volume %r." % volume_dict)914 logger.debug(
915 "Share quota exceeded event received. volume: %r.", volume_dict)
862 if self.quota_timer is not None:916 if self.quota_timer is not None:
863 if self.quota_timer.active:917 if self.quota_timer.active:
864 return918 return
@@ -871,7 +925,8 @@
871925
872 def root_quota_exceeded(self, volume_dict):926 def root_quota_exceeded(self, volume_dict):
873 """Quota exceeded in root."""927 """Quota exceeded in root."""
874 logger.debug("Root quota exceeded for volume %r." % volume_dict)928 logger.debug(
929 "Root quota exceeded event received. volume: %r.", volume_dict)
875 alert_user()930 alert_user()
876931
877 def set_show_all_notifications(self, value):932 def set_show_all_notifications(self, value):

Subscribers

People subscribed via source and target branches