I'm using the most recent Dropbox Python API (12.0.2) to list files in a Dropbox Application: dbx.files_list_folder succeeds, but it takes just over 100 seconds for the call to complete. 100 seconds is the amount of time the network timeout seems to be set to within the Python library itself. If I change that value directly in the library code, the response comes back almost immediately.
Notes:
Has the Python dbx library gone bad? Has something changed on the Dropbox servers?
def list_dropbox_directory( folder_path=""):
try:
# Initialize Dropbox client
dbx = Dropbox("my_token")
# Call to list folder contents
result = dbx.files_list_folder(folder_path,limit=5)
print("Directory listing for folder:", folder_path or "/")
# Process and display file/folder metadata
for entry in result.entries:
try:
entry_type = "File" if isinstance(entry, dropbox.files.FileMetadata) else "Folder"
print(f"{entry_type}: {entry.name} [Path: {entry.path_display}]")
except AttributeError as e:
print(f"Could not display entry {entry}: {e}")
# Keep iterating if there are more files (pagination)
while result.has_more:
result = dbx.files_list_folder_continue(result.cursor)
for entry in result.entries:
try:
entry_type = "File" if isinstance(entry, dropbox.files.FileMetadata) else "Folder"
print(f"{entry_type}: {entry.name} [Path: {entry.path_display}]")
except AttributeError as e:
print(f"Could not display entry {entry}: {e}")
except exceptions.AuthError as auth_err:
print("ERROR: Invalid access token.")
print(auth_err)
except Exception as e:
print("An unexpected error occurred:")
print(e)