Logo Search packages:      
Sourcecode: ubuntuone-control-panel version File versions  Download package

def ubuntuone::controlpanel::backend::ControlBackend::volumes_info (   self )
Get the volumes info.

Definition at line 449 of file backend.py.

        """Get the volumes info."""
        self._volumes = {}

            account = yield self.account_info()
        except Exception:  # pylint: disable=W0703
            logger.exception('volumes_info: quota could not be retrieved:')
            free_bytes = self.FREE_BYTES_NOT_AVAILABLE
            free_bytes = int(account['quota_total']) - \

        root_dir = yield dbus_client.get_root_dir()
        shares_dir = yield dbus_client.get_shares_dir()
        shares_dir_link = yield dbus_client.get_shares_dir_link()
        folders = yield dbus_client.get_folders()
        shares = yield dbus_client.get_shares()

        root_volume = {u'volume_id': u'', u'path': root_dir,
                       u'subscribed': 'True', u'type': self.ROOT_TYPE}
        self._volumes[u''] = root_volume

        # group shares by the offering user
        shares_result = defaultdict(list)
        for share in shares:
            if not bool(share['accepted']):

            share[u'type'] = self.SHARE_TYPE

            vid = share['volume_id']
            if vid in self._volumes:
                logger.warning('volumes_info: share %r already in the volumes '
                               'list (%r).', vid, self._volumes[vid])
            self._volumes[vid] = share

            nicer_path = share[u'path'].replace(shares_dir, shares_dir_link)
            share[u'path'] = nicer_path

            username = share['other_visible_name']
            if not username:
                username = u'%s (%s)' % (share['other_username'],


        for folder in folders:
            folder[u'type'] = self.FOLDER_TYPE

            vid = folder['volume_id']
            if vid in self._volumes:
                logger.warning('volumes_info: udf %r already in the volumes '
                               'list (%r).', vid, self._volumes[vid])
            self._volumes[vid] = folder

        result = [(u'', unicode(free_bytes), [root_volume] + folders)]

        for other_username, shares in shares_result.iteritems():
            send_freebytes = any(s['access_level'] == 'Modify' for s in shares)
            if send_freebytes:
                free_bytes = shares[0][u'free_bytes']
                free_bytes = self.FREE_BYTES_NOT_AVAILABLE
            result.append((other_username, free_bytes, shares))


Generated by  Doxygen 1.6.0   Back to index