def __init__(self, main, action_queue, fs_manager): """ Creates the instance.""" super(Status, self).__init__() self.syncdaemon_status = SyncdaemonStatus(main, action_queue, fs_manager)
class Status(Referenceable, SignalBroadcaster): """ Represent the status of the syncdaemon """ __metaclass__ = RemoteMeta # calls that will be accessible remotely remote_calls = [ 'current_status', 'current_downloads', 'waiting', 'waiting_metadata', 'waiting_content', 'current_uploads', ] def __init__(self, main, action_queue, fs_manager): """ Creates the instance.""" super(Status, self).__init__() self.syncdaemon_status = SyncdaemonStatus(main, action_queue, fs_manager) def current_status(self): """ return the current status of the system, one of: local_rescan, offline, trying_to_connect, server_rescan or online. """ logger.debug('called current_status') return self.syncdaemon_status.current_status() def current_downloads(self): """Return a list of files with a download in progress.""" logger.debug('called current_downloads') return self.syncdaemon_status.current_downloads() def waiting(self): """Return a list of the operations in action queue.""" logger.debug('called waiting') commands = self.syncdaemon_status.waiting() for op, op_id, data in commands: sanitize_dict(data) return commands def waiting_metadata(self): """Return a list of the operations in the meta-queue. As we don't have meta-queue anymore, this is faked. """ logger.debug('called waiting_metadata') return self.syncdaemon_status.waiting_metadata() def waiting_content(self): """Return a list of files that are waiting to be up- or downloaded. As we don't have content-queue anymore, this is faked. """ logger.debug('called waiting_content') return self.syncdaemon_status.waiting_content() def current_uploads(self): """ return a list of files with a upload in progress """ logger.debug('called current_uploads') return self.syncdaemon_status.current_uploads() def emit_content_queue_changed(self): """Emit ContentQueueChanged.""" self.emit_signal('on_content_queue_changed') def emit_invalid_name(self, dirname, filename): """Emit InvalidName.""" self.emit_signal('on_invalid_name', unicode(dirname), str(filename)) def emit_broken_node(self, volume_id, node_id, mdid, path): """Emit BrokenNode.""" if mdid is None: mdid = '' if path is None: path = '' self.emit_signal('on_broken_node', volume_id, node_id, mdid, path.decode('utf8')) def emit_status_changed(self, state): """Emit StatusChanged.""" self.emit_signal('on_status_changed', self.syncdaemon_status.current_status()) def emit_download_started(self, download): """Emit DownloadStarted.""" self.emit_signal('on_download_started', download) def emit_download_file_progress(self, download, **info): """Emit DownloadFileProgress.""" for k, v in info.copy().items(): info[str(k)] = str(v) self.emit_signal('on_download_file_progress', download, info) def emit_download_finished(self, download, **info): """Emit DownloadFinished.""" for k, v in info.copy().items(): info[str(k)] = str(v) self.emit_signal('on_download_finished', download, info) def emit_upload_started(self, upload): """Emit UploadStarted.""" self.emit_signal('on_upload_started', upload) def emit_upload_file_progress(self, upload, **info): """Emit UploadFileProgress.""" for k, v in info.copy().items(): info[str(k)] = str(v) self.emit_signal('on_upload_file_progress', upload, info) def emit_upload_finished(self, upload, **info): """Emit UploadFinished.""" for k, v in info.copy().items(): info[str(k)] = str(v) self.emit_signal('on_upload_finished', upload, info) def emit_account_changed(self, account_info): """Emit AccountChanged.""" info_dict = {'purchased_bytes': unicode(account_info.purchased_bytes)} self.emit_signal('on_account_changed', info_dict) def emit_metaqueue_changed(self): """Emit MetaQueueChanged.""" self.emit_signal('on_metaqueue_changed') def emit_requestqueue_added(self, op_name, op_id, data): """Emit RequestQueueAdded.""" sanitize_dict(data) self.emit_signal('on_request_queue_added', op_name, str(op_id), data) def emit_requestqueue_removed(self, op_name, op_id, data): """Emit RequestQueueRemoved.""" sanitize_dict(data) self.emit_signal('on_request_queue_removed', op_name, str(op_id), data)