本文整理汇总了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'])
示例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