def _update(self): """Update the notification.""" if not self.connected: return text = self.status_aggregator.get_discovery_message() if text: logger.debug("notification updated: %s", text) self.notification.send_notification(UBUNTUONE_TITLE, text)
def _queue_done(self, _): """Show final bubble and reset counters.""" self.queue_done_timer.cleanup() self.queue_done_timer = None logger.debug("queue done callback fired") if self.upload_done + self.download_done > 0: self.final_status_bubble.show() self.progress_bar.completed() self.reset()
def _popup(self): """Display the notification.""" if not self.connected: return text = self.status_aggregator.get_discovery_message() if text: self.notification.send_notification(UBUNTUONE_TITLE, text) logger.debug("notification shown: %s", text) self._change_state(FileDiscoveryUpdateState)
def set_progress(self, progress): """Steps amount changed. Set up a timer if there isn't one ticking.""" self.progress = progress if not self.visible: self.visible = True self.launcher.show_progressbar() logger.debug("progressbar shown") if not self.timer: self.timer = Timer(self.updates_delay, clock=self.clock) self.timer.addCallback(self._timeout)
def upload_finished(self, command): """An upload just finished.""" if command in self.files_uploading: self.files_uploading.remove(command) self.upload_done += 1 if command.deflated_size is not None: self.progress[ (command.share_id, command.node_id)] = command.deflated_size logger.debug("unqueueing command: %s", command.__class__.__name__) self.update_progressbar()
def share_quota_exceeded(self, volume_dict): """Sharing user's quota exceeded in share.""" logger.debug("Share quota exceeded for volume %r." % volume_dict) if self.quota_timer is not None: if self.quota_timer.active: return else: self.quota_timer = Timer(ONE_DAY, clock=self.aggregator.clock) self.notification.send_notification( UBUNTUONE_TITLE, SHARE_QUOTA_EXCEEDED % ( volume_dict['path'], volume_dict['other_visible_name'])) alert_user()
def queue_done(self): """Queue is finished.""" if not self.to_do: return if self.queue_done_timer is None: logger.debug("queue done callback added") self.queue_done_timer = Timer( self.finished_delay, clock=self.clock) self.queue_done_timer.addCallback(self._queue_done) return logger.debug("queue done callback reset") self.queue_done_timer.reset()
def set_progress(self, progress): """Steps amount changed. Set up a timer if there isn't one ticking.""" self.progress = progress if not self.visible: self.visible = True self.launcher.show_progressbar() logger.debug("progressbar shown") if self.inhibitor_defer is None: self.inhibitor_defer = session.inhibit_logout_suspend( FILE_SYNC_IN_PROGRESS) if not self.timer: self.timer = Timer(self.updates_delay, clock=self.clock) self.timer.addCallback(self._timeout)
def download_finished(self, command): """A download just finished.""" if command in self.files_downloading: self.files_downloading.remove(command) self.download_done += 1 if command.deflated_size is not None: self.progress[ (command.share_id, command.node_id)] = command.deflated_size if command.path in self.recent_transfers: self.recent_transfers.remove(command.path) self.recent_transfers.append(command.path) logger.debug("unqueueing command: %s", command.__class__.__name__) self.update_progressbar()
def completed(self): """All has completed.""" self.cleanup() self.visible = False self.launcher.hide_progressbar() logger.debug("progressbar hidden") if self.inhibitor_defer is not None: def inhibitor_callback(inhibitor): """The inhibitor was found, so cancel it.""" self.inhibitor_defer = None return inhibitor.cancel() self.inhibitor_defer.addCallback(inhibitor_callback)
def upload_started(self, command): """An upload just started.""" if self.queue_done_timer is not None: self.queue_done_timer.cleanup() self.queue_done_timer = None self.files_uploading.append(command) if command.deflated_size is not None: self.to_do[ (command.share_id, command.node_id)] = command.deflated_size if not self.uploading_filename: self.uploading_filename = os.path.basename( self.files_uploading[0].path) self.update_progressbar() logger.debug( "queueing command (total: %d): %s", len(self.to_do), command.__class__.__name__) self.file_discovery_bubble.new_file_found()
def download_started(self, command): """A download just started.""" if self.queue_done_timer is not None: self.queue_done_timer.cleanup() self.queue_done_timer = None self.files_downloading.append(command) if command.deflated_size is not None: self.to_do[ (command.share_id, command.node_id)] = command.deflated_size # pylint: disable=W0201 if not self.downloading_filename: self.downloading_filename = self.files_downloading[0].path.split( os.path.sep)[-1] # pylint: enable=W0201 self.update_progressbar() logger.debug( "queueing command (total: %d): %s", len(self.to_do), command.__class__.__name__) self.file_discovery_bubble.new_file_found()
def root_quota_exceeded(self, volume_dict): """Quota exceeded in root.""" logger.debug("Root quota exceeded for volume %r." % volume_dict) alert_user()
def completed(self): """All has completed.""" self.cleanup() self.visible = False self.launcher.hide_progressbar() logger.debug("progressbar hidden")
def udf_quota_exceeded(self, volume_dict): """Quota exceeded in UDF.""" logger.debug("UDF quota exceeded for volume %r." % volume_dict) alert_user()
def server_connection_made(self): """The client made the connection to the server.""" logger.debug("server connection made") self.aggregator.connection_made()
def server_connection_lost(self): """The client lost the connection to the server.""" logger.debug("server connection lost") self.aggregator.connection_lost()
def _timeout(self, result): """The aggregating timer has expired, so update the UI.""" self.timer = None self.launcher.set_progress(self.progress) logger.debug("progressbar updated: %f", self.progress)