当前位置: 首页>>代码示例>>Python>>正文


Python Dropbox.users_get_space_usage方法代码示例

本文整理汇总了Python中dropbox.Dropbox.users_get_space_usage方法的典型用法代码示例。如果您正苦于以下问题:Python Dropbox.users_get_space_usage方法的具体用法?Python Dropbox.users_get_space_usage怎么用?Python Dropbox.users_get_space_usage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在dropbox.Dropbox的用法示例。


在下文中一共展示了Dropbox.users_get_space_usage方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: display

# 需要导入模块: from dropbox import Dropbox [as 别名]
# 或者: from dropbox.Dropbox import users_get_space_usage [as 别名]
def display():
    if 'access_token' not in session:
        abort(400)

    access_token = session['access_token']
    if 'job' in session:
        job = get_job_from_key(session['job'], conn)
        # Only rely on a previous result if the same user is logged in (same access_token)
        if job is not None and access_token == job.meta.get('access_token', None):
            return render_template('display.html', username=session['username'], quota=session['quota'], used=session['used'])

    try:
        client = Dropbox(access_token)
    except Exception:
        abort(401)

    account = client.users_get_current_account()
    session['username'] = account.name.display_name

    space_usage = client.users_get_space_usage()
    allocated, used = get_space_usage_info(space_usage)
    total_bytes = used
    session['used'] = human_readable(used)
    session['quota'] = human_readable(allocated)

    job = q.enqueue(walk_entire_dropbox, access_token, total_bytes)
    job.meta['access_token'] = access_token
    job.save()
    update_progress(job, 0, "/")
    session['job'] = job.key

    return render_template('display.html', username=session['username'], quota=session['quota'], used=session['used'])
开发者ID:kevincon,项目名称:utilityknife,代码行数:34,代码来源:app.py

示例2: __init__

# 需要导入模块: from dropbox import Dropbox [as 别名]
# 或者: from dropbox.Dropbox import users_get_space_usage [as 别名]
class DropboxConnector:
    def __init__(self, account):
        self.client = Dropbox(account["access_token"])

    # Dropbox does not like the "/" path for some stupid reason...
    # "" refers to the root directory
    @staticmethod
    def convert_to_dropbox_path(path):
        if path == "/":
            return ""
        else:
            return path

    def make_directory(self, path):
        self.client.files_create_folder(path)

    def change_mode(self, path, mode):
        pass

    def change_owner(self, path, user_id, group_id):
        pass

    def getattr(self, path, file_handle=None):
        dropbox_path = DropboxConnector.convert_to_dropbox_path(path)
        metadata = self.client.files_get_metadata(dropbox_path)
        file_status = FileStatus()

        # I'm going to change this hard coded stuff later
        file_status.group_id = 20
        file_status.user_id = 501

    @property
    def total_storage(self):
        space_usage = self.client.users_get_space_usage()
        return space_usage.allocation.get_individual().allocated

    @property
    def free_storage(self):
        space_usage = self.client.users_get_space_usage()
        return space_usage.used
开发者ID:bbielsa,项目名称:FreeFS,代码行数:42,代码来源:DropboxConnector.py


注:本文中的dropbox.Dropbox.users_get_space_usage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。