Hello,
I want to obtain the corresponding values for Usage (in MB, updates every 8 hours) obteined using the manual export member data in the admin console.
Currently this is my test code:
def get_users_list(token) :
dbx = dropbox.DropboxTeam(token)
members = dbx.team_members_list(include_removed= True).members
# Collect member information
member_data = []
for member in members:
member_info = {
"team_member_id": member.profile.team_member_id,
"email": member.profile.email,
"status": str(member.profile.status),
"role": str(member.role)
}
member_data.append(member_info)
# Get the path to the parent directory of the current script's directory
parent_dir_path = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
# Write user data to a JSON file in the parent directory
json_file_path = os.path.join(parent_dir_path, 'get_users_list.json')
with open(json_file_path, 'w') as json_file:
json.dump(member_data, json_file, indent=4)
print(f"List members data has been written to '{json_file_path}'")
return member_data
def get_team_members(dbx_team) :
members = []
result = dbx_team.team_members_list()
members.extend(result.members)
while result.has_more:
result = dbx_team.team_members_list_continue(result.cursor)
members.extend(result.members)
return members
if __name__ == "__main__":
if access_token:
dbx_team = dropbox.DropboxTeam(access_token)
data = get_users_list(access_token)
specific_member = {
"team_member_id": "xxxxxx",
"email": "xxxxx",
"status": "xxxxx",
"role": "Axxxx"
}
# Procesar solo el miembro específico
user_dbx = dbx_team.as_user(specific_member['team_member_id'])
account_info = user_dbx.users_get_space_usage()
used_bytes = account_info.used
allocation = account_info.allocation
if allocation.is_individual():
total_bytes = allocation.get_individual().allocated
elif allocation.is_team():
total_bytes = allocation.get_team().allocated
else:
total_bytes = 'Desconocido'
used_mb = used_bytes / (1024 ** 2) # Convertir a MB
total_mb = total_bytes / (1024 ** 2) if total_bytes != 'Desconocido' else 'Desconocido'
print(f"Usuario: {specific_member['email']}")
print(f"Espacio utilizado (bytes): {used_bytes}")
print(f"Espacio total (bytes): {total_bytes}")
print(f"Espacio utilizado (MB): {used_mb:.2f}")
print(f"Espacio total (MB): {total_mb}\n")
# Obtener el espacio utilizado y total para el miembro específico usando dbx
account_info = user_dbx.users_get_space_usage()
used = account_info.used
print(f"Espacio utilizado: {used/ (1024 ** 2)} megabytes")
But I only get "Data (MB) member has access to".
this is my test response
Usuario: xxxxxxx
Espacio utilizado (bytes): 12290447226920
Espacio total (bytes): 11922399716966400
Espacio utilizado (MB): 11721083.86
Espacio total (MB): 11370086400.0
Espacio utilizado: 11721083.85 megabytes
| Usage (in MB, updates every 8 hours) | Data (MB) member has access to |
| 1.05 | 11,721,083.86 |
To sum up I want to extract Usage (in MB, updates every 8 hours) which in the example is 1.05
Kind regards