Code Monkey home page Code Monkey logo

dropbox-sdk-python's Introduction

https://cfl.dropboxstatic.com/static/images/sdk/python_banner.png

The offical Dropbox SDK for Python.

Documentation can be found on Read The Docs.

Installation

Create an app via the Developer Console.

Install via pip:

$ pip install dropbox

Install from source:

$ git clone git://github.com/dropbox/dropbox-sdk-python.git
$ cd dropbox-sdk-python
$ python setup.py install

After installation, follow one of our Examples or read the documentation on Read The Docs.

You can also view our OAuth Guide.

Examples

We provide Examples to help get you started with a lot of the basic functionality in the SDK.

  • OAuth
  • Other Examples
    • Updown - Sample application that uploads the contents of your Downloads folder to Dropbox.
    • Backup and Restore - Sample application that shows how you can backup a file and restore previous versions if the file was modified/corrupted in any way.

Getting Help

If you find a bug, please see CONTRIBUTING.md for information on how to report it.

If you need help that is not specific to this SDK, please reach out to Dropbox Support.

License

This SDK is distributed under the MIT license, please see LICENSE for more information.

dropbox-sdk-python's People

Contributors

bastianzim avatar braincore avatar brent1lt avatar connorworley avatar deckhubbot avatar dennissiemensma avatar dependabot[bot] avatar dnlcrl avatar dropboxbot avatar eugeneyche avatar ewjoachim avatar fviard avatar greg-db avatar karandeep-johar avatar kratos83 avatar maxbelanger avatar mbogosian avatar mtruong-dbx avatar rianhunter avatar risforrob avatar rogebrd avatar sagarvora avatar sderickson avatar stanislau-arkhipenka avatar starforever avatar steko avatar tivaliy avatar varenc avatar vinodc avatar yuxiang-he avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dropbox-sdk-python's Issues

Limiting retries due to rate-limited requests, and determining the suggested backoff.

It would be preferable to avoid the potential infinite loop here on 429 errors:

# Do not count a rate limiting error as an attempt

Could there be some mechanism to separately control the number of retries for rate-limited requests? I would prefer our implementation to retry on 5** errors, but immediately fail on 429 errors providing me with an option on when to retry based on the Retry-After header in the response.

I believe this would also require the TODO item at

# TODO(kelkabany): Use backoff if provided in response.
to be implemented, storing the backoff value based on the Retry-After header, unless I'm mistaken.

Bad Request for url: https://www.dropbox.com/1/oauth2/token

After issue #31 was solved, I get the following error when running the example-code from the docs with version 3.42:

Traceback (most recent call last):
  File "test.py", line 15, in <module>
    access_token, user_id = auth_flow.finish(auth_code)
  File "/usr/local/lib/python2.7/dist-packages/dropbox/oauth.py", line 178, in finish
    return self._finish(code, None)
  File "/usr/local/lib/python2.7/dist-packages/dropbox/oauth.py", line 60, in _finish
    resp.raise_for_status()
  File "/usr/local/lib/python2.7/dist-packages/requests/models.py", line 837, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
HTTPError: 400 Client Error: Bad Request for url: https://www.dropbox.com/1/oauth2/token

files_get_metadata result does not include sharing_info

I'm getting a discrepancy between the curl result for files/get_metadata and the Python object returned by files_get_metadata for a file in a shared folder. Specifically, the sharing_info field is not present and so I cannot access modified_by.

It is not possible list root folder's content

I am not sure if I am doing something wrong or if it is even possible to list root folder's content. After login when I try to user files_list_folder or files_get_metadata I got an error:
ApiError: ListFolderError(u'path', LookupError(u'malformed_path', None))

I've tried to list other folders' content and it is working.

Fastest way to check for existence of a file?

I'm writing a Dropbox provider for the bioinformatics workflow engine, Snakemake. When a Snakemake workflow is executed it builds its directed acyclic graph of rules to execute based on which files exist. Consequently, it can check for the existence of many files, often several times. I want a fast way to check whether or not a file exists on Dropbox.

What is the best practice for checking file existence on Dropbox via the Python SDK for the v2 API?

So far, I have the following candidate functions (stripped-down example):

import dropbox

dbx = dropbox.Dropbox(oauth2_access_token="mytoken")

path = "/path/to/my/file.bam"

def exists(path):
    return os.path.basename(path) in [e.name for e in dbx.files_list_folder(path=os.path.dirname(path)).entries]

def exists2(path):
    try:
        dbx.files_get_metadata(path)
        return True
    except:
        return False

Is there a faster way? Thanks!

Organize the documentation

Hello,

I was invited by Steeve Marx to create issues for my remarks on the API, so here it is.

For now, your documentation is really hard to grasp. I can really see that it's just the output of Sphinx' Autodoc, but it could help if there was an introduction, some documented examples on most of the methods on the Dropbox object etc. It took me some time to figure out that all I ever have to instantiate was a Dropbox object. Lots and lots of classes listed here are for "internal" use only (for example, the *Args).

Inconsistent Handling of Upload Paths

Behavior when providing upload paths to different methods is inconsistent when an app has permissions restricted to its own folder.

Here is some examples of what I mean

Method Call Real Destination Expected
client.put_file("subdir/file.txt", f) Dropbox/Apps/MyApp/subdir/file.txt Yes
client.put_file("MyApp/subdir/file.txt", f) Dropbox/Apps/MyApp/MyApp/subdir/file.txt Yes
client.commit_chunked_upload("subdir/file.txt", id) Dropbox/Apps/MyApp/Apps/file.txt No
client.commit_chunked_upload("MyApp/subdir/file.txt", id) Dropbox/Apps/MyApp/subdir/file.txt No
client.commit_chunked_upload("JustRandomText/subdir/file.txt", id) Dropbox/Apps/MyApp/subdir/file.txt Hell No

It appears to be related to put_file appending self.session.root before the path but commit_chunked_upload not doing so.

This behavior is inconsistent and confusing. I don't necessarily think the existing code should be changed, since people who have already found and worked around this behavior will have their code broken, but the documentation of commit_chunked_upload should make this behavior clear.

Feature Request: checksum attribute

Maybe I missed it somewhere in the docs, but is it possible to access the checksum values of the stored files on the server? I've found the rev attribute but that is only useful after I've downloaded and hashed the file at least once. Is there a way to compare the values of remote files to local files without first downloading them? Thanks for the awesome product and your continued work.

Make the API a little more pythonic, more friendly

Hello,

I was invited by Steeve Marx to create issues for my remarks on the API, so here it is.

This is not a "bug" per se, but a sum of different remarkes that make me not completely convinced by the SDK's API as of today. It's nothing more than my own personnal 2 cents and I don't claim to represent anyone's opinion except my own.

For now, there are still things that are really unnatural when working with the dropbox API with python. The profusion of "everything being made into a class inheriting object" and in the same time, the fact it's not-using lots of classical python constructs really feels as if the whole API was ported from another language...

All the things I've seen so far:

  • The APIError that has a reason property which is an *Error class that inherits object : why wouldn't the error class BE the exception itself ? it forces the user to make a complicated construct of:
if isinstance(exc.reason, SomethingError):
    # blabla
elif isinstance(exc.reason, SomethingElseError):
   # blabla

Where the simpler try/except would do it.

  • ListFolderResult inherits object and is not iterable. This feels strange. Plus, its entries are not easily sortable. if you want just the Files of just the Folders, you have, again, to filter everything using isinstance. It's not encouraging readable code on our side. A suggestion : why not providing a "walk" method similar to os.walk (but with metadata elements instead of strings ?)
  • The fact that, in metadata, you only have the choice between "path_lower" and "name" makes it really a pain to get a properly cased path (e.g. to show the user. We don't want to show them a lowercase path). The fact that there's no easy way to get the "parent" MetaData or the children metadata for a folder makes it all the more complicated. What would be really useful is that when I do a files_list_folder(recursive=True), the SDK would organize the result so that if I find an interesting folder, I can get its (metadata) content. Another thing that would be great : if files_list_folder could provide a generator that would automatically call "continue" when everything has been yielded without having to do it by ourselves.
  • When looking at the code, it seems there are a lots of copy/pasted constructs (all the properties for instance, with the something_present attribute being set manually. Some are completely copy-pasted (id for FileMetaData and FolderMetaData). This makes reading the code not an easy task.
  • I didn't get into much details and I'm probably wrong but it feels like some constructs could be greatly simplified using **kwargs more often and inheritance/mixin between classes providing similar functionalities. Today, for example, ListSharedFolderResults and ListResults are not related.

Wrong content-type returned by files_list_folder_longpoll, "text/plain" instead of "application/json"

The following sample code:

#!/usr/bin/python
import dropbox, os
dbx = dropbox.Dropbox(os.environ['DROPBOX_TOKEN'])
root = dbx.files_list_folder('')
print dbx.files_list_folder_longpoll(root.cursor, timeout=30)

returns:

Traceback (most recent call last):
  File "longpoll_test.py", line 7, in <module>
    print dbx.files_list_folder_longpoll(root.cursor, timeout=30)
  File "/home/rrerolle/Workspace/Code/rembox/venv/local/lib/python2.7/site-packages/dropbox/base.py", line 89, in files_list_folder_longpoll
    None)
  File "/home/rrerolle/Workspace/Code/rembox/venv/local/lib/python2.7/site-packages/dropbox/dropbox.py", line 175, in request
    request_binary)
  File "/home/rrerolle/Workspace/Code/rembox/venv/local/lib/python2.7/site-packages/dropbox/dropbox.py", line 256, in request_json_string_with_retry
    request_binary)
  File "/home/rrerolle/Workspace/Code/rembox/venv/local/lib/python2.7/site-packages/dropbox/dropbox.py", line 337, in request_json_string
    r.headers.get('content-type'))
AssertionError: Expected content-type to be application/json, got 'text/plain'

It appears the request succeeds, but returns a "text/plain" content-type, while the dropbox v2 client explicitly expects "application/json", as demonstrated in

assert r.headers.get('content-type') == 'application/json', (
'Expected content-type to be application/json, got %r' %
r.headers.get('content-type'))

This is probably an overlook in the v2 API server itself so I'm not sure there is anything to do client wise. Still, for now, using it requires either catching the AssertionError, or running python with -O to disable the asserts.

Allow dropbox.base.files_move/files_copy to accept unique ID value in addition to path for source argument.

From the HTTP documentation it seems as though this isn't an issue with the Python SDK, but I'm not sure in which repository to request the feature.

files_move(), files_copy and the associated HTTP API endpoints of files/move and files/copy currently accepts paths as the source as destination arguments. Considering that dropbox.files.FolderMetadata and dropbox.files.FileMetadata now contain unique identifiers that represent the file or folder in question, it would be a welcome enhancement to allow the specification of the id value as the source (currently the from_path argument) for both endpoints.

If there's a more appropriate place to file this request, please let me know.

Inconsistency between the docs and the example

The docs says for the class MetaData :

client_modified – For files, this is the modification time set by the desktop
client when the file was added to Dropbox. Since this time is not verified
(the Dropbox server stores whatever the desktop client sends up), this
should only be used for display purposes (such as sorting) and not, for
example, to determine if a file has changed or not.

And updown.py does :

if (isinstance(md, dropbox.files.FileMetadata) and
    mtime_dt == md.client_modified and size == md.size):
    print(name, 'is already synced [stats match]')

So should we do like the example does or what the doc says ?

APIError Exceptions / Errors makes no sense

Sorry to raise this issue, but I've given them a good try, and still can't make sense of them.
I've checked out your examples, and I've read your documentation:
http://dropbox-sdk-python.readthedocs.org/en/master/moduledoc.html#dropbox.files.ListFolderError

I think you need a lot more examples of usual errors that might crop up whilst using your API.

Since I'm here anyway, can anyone point me in the right direction on how to handle the following scenario:
I want to check if a folder exists, and if it is not found, I want to create that folder.

Other than that, its pretty good stuff!

Is current version up to date?

When I installed via git clone and python setup.py install, the version is 0.1, but when I search the dropbox2 in pip, it said the latest version is 1.7.1.

Installer broken with Python3

The latest release 3.12 has broken the package when installing with Python 3.4

pip install dropbox
Downloading/unpacking dropbox
  Downloading dropbox-3.12.tar.gz (107kB): 107kB downloaded
  Running setup.py (path:/home/tims/.virtualenvs/testp3/build/dropbox/setup.py) egg_info for package dropbox
    Traceback (most recent call last):
      File "<string>", line 17, in <module>
      File "/home/tims/.virtualenvs/testp3/build/dropbox/setup.py", line 4, in <module>
        from ez_setup import use_setuptools
    ImportError: No module named 'ez_setup'
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):

  File "<string>", line 17, in <module>

  File "/home/tims/.virtualenvs/testp3/build/dropbox/setup.py", line 4, in <module>

    from ez_setup import use_setuptools

ImportError: No module named 'ez_setup'

Was picked up by our CI server.

InternalServerError when trying to upload with updown.py

I am trying to use updown.py to upload the contents of a local subfolder to my dropbox and I keep getting this exception:

$ python updown.py --token MYTOKEN /Dropbox/path local/relative/path
Dropbox folder name: /Dropbox/path
Local directory: local/relative/path
Total elapsed time for list_folder: 1.146
Descending into  ...
file010.bin is already synced [stats match]
file008.bin is already synced [stats match]
file007.bin is already synced [stats match]
Upload file003.bin? [Y/n]
Total elapsed time for upload 3974 bytes: 26.167
Traceback (most recent call last):
  File "updown.py", line 247, in <module>
    main()
  File "updown.py", line 108, in main
    upload(dbx, fullname, folder, subfolder, name)
  File "updown.py", line 185, in upload
    mute=True)
  File "/usr/local/lib/python2.7/dist-packages/dropbox/base.py", line 393, in files_upload
    f)
  File "/usr/local/lib/python2.7/dist-packages/dropbox/dropbox.py", line 175, in request
    request_binary)
  File "/usr/local/lib/python2.7/dist-packages/dropbox/dropbox.py", line 256, in request_json_string_with_retry
    request_binary)
  File "/usr/local/lib/python2.7/dist-packages/dropbox/dropbox.py", line 320, in request_json_string
    raise InternalServerError(r.status_code, r.text)
dropbox.exceptions.InternalServerError

In local/relative/path I have several random binary files. As you can see in the output despite the exception the files seem to be uploaded correctly. In this case I am running the script the fourth time. Is there something I need to check for myself? Or is there really an InternalServerError?

SDK incompatible with stock OS X 10.11 six module (Xcode, not Homebrew)

Hi, using Xcode latest and OS X 10.11, I encountered this issue with the Dropbox SDK:

Eugeny/reconfigure#17

The version of six provided with OS X does not include the PY2 constant, and so your SDK fails to operate correctly.

I encountered significant difficulty trying to upgrade the system-provided six, as System Protection prohibits alteration of the non-user-installed six library. I eventually worked around this issue with:

sudo pip install --force-reinstall -I --no-cache-dir six

Which instructed it to simply install the new version, with no regard for whether it was already installed or not.

But this entire issue would be repaired by simply not using the PY2 constant for the version check, as done at the pull request above. I propose this would improve your compatibility with OS X in general.

Feature request: batch upload/download files

It would be awesome if there were a way to upload and download files in batches - having a method that wouldn't involve connection setup + teardown per file upload/download.

This would be super helpful for projects like git-remote-dropbox that transfer lots of small objects. (currently, the bottleneck is with having lots of connections and round trips to the Dropbox servers)

fix examples on 2.2.0

is this the official place for the SDK i can download on dropbox.com?

this seems outdated. i wanted to patch the examples to work with python3 as they are failing currently because of syntax errors.

It is no longer possible to upload a file that is composed of an in-memory StringIO stream.

In the previous version of the API, it was possible to create an in-memory stream and use that as a file-like object for creating a new file:

import StringIO
stream = StringIO.StringIO()
stream.write(u'This is a test.\n')
response = client.put_file(u'/magnum-opus.txt', stream)
print "uploaded:", response

With the new API, the use of a StringIO stream produces an error:

data = StringIO.StringIO()
data.write(u'This is a test.\n')
path = u'/testing.txt'
client.files_upload(data, path)

# raises a ConnectionError
> ConnectionError: ('Connection aborted.', BadStatusLine("''",))

The solution is, somewhat obviously, to simply eschew the stream construct and pass the unicode data directly to the data parameter of files_upload() via StringIO.getvalue(). However, I can't think of a reason why the file-like object should produce such an error instead of extracting out the correct value.

Internal server error while uploading files

When I call files_upload() a bunch of times, sometimes I get an internal server error. (Retrying usually solves the problem).

What's the reason for this?

If it's some form of rate limiting, would a 4xx error be more appropriate?

Dropbox emailed me that my Python Core SDK is out of date

I just started using the master build of the dropbox-sdk found here and today I got this email from [email protected] (with app name redacted)

We're writing to you because our logs indicate that you have at least one Dropbox API app (...) using an old version of the Python Core
SDK, with an out of date certificate file.

The Dropbox Python Core SDK implements certificate pinning, based on a list of certificates included in the SDK, in order to help secure the
connection to the Dropbox API servers.

On August 1st, 2016, the Dropbox API servers will be updated to use a new certificate, so you’ll need to update the version of the SDK used in your
app to match. The latest version of the Python Core SDK already contains the updated certificate file:

https://www.dropbox.com/l/xPCwR0s4CoICzox5c2OOxh?text=1[1]

You can refer to the CHANGELOG file included in the SDK for a list of changes.

Please update your app to use the latest SDK by 8/1/16 to ensure continued access to the Dropbox API.

Thanks!

- The Dropbox Platform Team

Is this some known current deficiency of this v2 preview SDK? If nothing else, perhaps this ticket will help others that are puzzled/confused by this. Thanks!

Size Error When Getting Image Thumbnail

When getting the thumbnail using the following format:
client.files_get_thumbnail(<path>)
I receive the following response:
(400, u'Error in call to API function "files/get_thumbnail": HTTP header "Dropbox-API-Arg": size: unknown tag \'s\'')

python 3.4 'module' object has no attribute 'quote' urllib.quote is used

from dropbox import Dropbox, DropboxOAuth2Flow

target = reverse('login')
redirect_uri = request.build_absolute_uri(target)
client = DropboxOAuth2Flow(creds['client_id'], creds['client_secret'], redirect_uri, request.session, 'dropbox-auth-csrf-token')

throws an error

File "social.py" in _authorize
  153.                 return HttpResponseRedirect(client.start())
File "/Users/admin/Envs/env3/lib/python3.4/site-packages/dropbox/oauth.py" in start
  276.         return self._get_authorize_url(self.redirect_uri, state)
File "/Users/admin/Envs/env3/lib/python3.4/site-packages/dropbox/oauth.py" in _get_authorize_url
  40.         return self.build_url(Dropbox.HOST_WEB, '/oauth2/authorize', params)
File "/Users/admin/Envs/env3/lib/python3.4/site-packages/dropbox/oauth.py" in build_url
  104.         return "https://%s.%s%s" % (host, self._domain, self.build_path(target, params))
File "/Users/admin/Envs/env3/lib/python3.4/site-packages/dropbox/oauth.py" in build_path
  79.         target_path = urllib.quote(target)
Exception Value:    
'module' object has no attribute 'quote'
Exception Location: /Users/admin/Envs/env3/lib/python3.4/site-packages/dropbox/oauth.py in build_path, line 79
Python Executable:  /Users/admin/Envs/env3/bin/python
Python Version: 3.4.3

so apparently python 3 support is not implemented here

Tag API releases?

Hey Dropbox Devs,

Congrats on your v2 release. Would it be possible to add pip versions as Git tags in future releases?

It would be really nice to be able to browse what's in a release here on Github rather than downloading it from pip.

Thanks!

files_upload cause dropbox.exceptions.InternalServerError: (500, '')

Hi, recently, I always got this error and never successfully upload file.
The script used to be working fine.
It just happened recently.

File "build.py", line 104, in
main()
File "build.py", line 31, in main
upload(dbx, localpath+os.sep+filename, 'app\u8bbe\u8ba1', 'apk', finalapk, False)
File "build.py", line 58, in upload
mute=True)
File "H:\Python34\lib\site-packages\dropbox\base.py", line 326, in files_upload
f)
File "H:\Python34\lib\site-packages\dropbox\dropbox.py", line 178, in request
request_binary)
File "H:\Python34\lib\site-packages\dropbox\dropbox.py", line 259, in request_json_string_with_retry
request_binary)
File "H:\Python34\lib\site-packages\dropbox\dropbox.py", line 322, in request_json_string
raise InternalServerError(r.status_code, r.text)
dropbox.exceptions.InternalServerError: (500, '')

Don't raise an exception on dropbox.files.files_list_folder() call when folder is empty.

As demonstrated in the current updown.py example.

The HTTP-based API docs does not make it clear if this is the expected result, either. It seems like the not_found error might be what's going on, but if so that seems wrong – we know there's a folder at the specified location, and it just so happens to be empty. Handling this currently entails catching an exception that may or may not be raised depending on the point-in-time number of files in the folder in question.

An empty folder should simply return a ListFolderResult with no entries.

Passing in Flask's request.args into DropboxOAuth2Flow's finish raises CsrfException

Flask's request.args seems to return a MultiDict with the state and code params as strings.

An example request.args:

ImmutableMultiDict([('code', 'YTUikDoXcTAAAAAAAAAAHXP77TSxxgsDq4feLLcqAFo'), ('state', "b'AS3w7Msx1ogjdQF30rRVyA=='")])

This results in a comparison of the stored session's CSRF to fail in comparison to the returned state's CSRF as a byte value is being compared to a string value:

dropbox.client.CsrfException: expected b'04z6aywDB0ynAlvU42NJyQ==', got "b'04z6aywDB0ynAlvU42NJyQ=='"

I was able to get around this by writing my own utility function but I was just wanted to perhaps put the issue out there so others don't have to slog through SDK debugging.

users_get_space_usage function broken in API V2

Just observed that the users_get_space_usage() function is broken is API V2.

The expected field names are "allocated" and "used" as per users.py for _decode_struct_fields function, but the API V2 is returning a nested JSON of the form

{
  'allocation': 
        {
        '.tag': 'individual', 
        'allocated': xxxxxxxxx
        }, 
  'used': xxxxxxxxxx
}

Where the parent key is allocation (which is not the expected Field) which results in the error
dropbox.babel_validators.ValidationError: missing required field 'allocated', as the expected key allocated becomes None because the if condition breaks

Sample Curl Request to the API

curl -X POST https://api.dropboxapi.com/2-beta-2/users/get_space_usage \
    --header "Authorization: Bearer xyxyxyxyxxyxyxyxyxxyxy" \
    --header "Content-Type: application/json" \
    --data "null"
{"used": xxxxxxx, "allocation": {".tag": "individual", "allocated": xxxxxxx}}

Has this new JSON Schema change happened with the API V2 ?

out of date certificate file in SDK?

Hi Team,

I got the mail from api support of Dropbox as below:

We're writing to you because our logs indicate that you have at least one Dropbox API app (XXXX, XXXX) using an old version of the Python Core SDK, with an out of date certificate file.

The Dropbox Python Core SDK implements certificate pinning, based on a list of certificates included in the SDK, in order to help secure the connection to the Dropbox API servers.

On August 1st, 2016, the Dropbox API servers will be updated to use a new certificate, so you’ll need to update the version of the SDK used in your app to match. The latest version of the Python Core SDK already contains the updated certificate file:

https://www.dropbox.com/developers-v1/core/sdks/python

However, the link points to v1-API whose certificate file (trusted-certs.crt) is the same as the one inside of v2 sdk.

So, should I care this notification or the trusted-certs.crt needs to be updated?

Thank you.

FolderMetadata.path_display casing issues

  1. Create a folder structure in your Dropbox specifically as follows /AAA/BBB/CCC/DDD
  2. Rename folder CCC to CCC_
  3. Rename folder CCC_ to ccc
  4. Generate a Dropbox API token and run the following code
import dropbox
client = dropbox.Dropbox("ACCESS_TOKEN")
listing =  client.files_list_folder('', recursive=True)
for entry in listing.entries:
        print entry.path_display
  1. You should see the following output
/AAA
/AAA/BBB
/AAA/BBB/ccc
/AAA/BBB/CCC/DDD

Issue: You can see that ccc suddenly changes back to CCC

Not compatible with 3.4

Lines 47 and 48:
args = parser.parse_args()
if sum([bool(b) for b in args.yes, args.no, args.default]) > 1:

Pycharm is telling me that:
"Python 3.4 does not support this syntax in list comprehensions"

Internal Server error when using files_move and files_copy

Hi,
I'm receiving an InternalServerError everytime I call files_move or files_copy. I'm currently working around the issue from downloading and re-uploading each file instead. Here is my traceback

File "C:\Python27\lib\custom\dropbox_backup.py", line 69, in move_sequential_files
self.dropbox.rename(file_path, this_path)
File "C:\Python27\lib\custom\dropbox\dropbox_wrapper.py", line 113, in rename
self.client.files_move(old_path, new_path)
File "C:\Python27\lib\site-packages\dropbox\base.py", line 544, in files_move
None)
File "C:\Python27\lib\site-packages\dropbox\dropbox.py", line 175, in request
request_binary)
File "C:\Python27\lib\site-packages\dropbox\dropbox.py", line 256, in request_json_string_with_retry
request_binary)
File "C:\Python27\lib\site-packages\dropbox\dropbox.py", line 320, in request_json_string
raise InternalServerError(r.status_code, r.text)
InternalServerError

Make sure HTTP 400 error message body is shown by default.

In #33, someone got an HTTP 400 exception and didn't know what to do.

The Dropbox server usually puts useful information in HTTP 400 error responses. If that error message were surfaced by default (i.e. visible in the stack trace) the issue might have been easier to resolve.

Add support for file id

I'm guessing the SDK needs to be updated to support fileIds:

>>> dbx.files_download('id:YYYYYYYYYYY')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/path/to/lib/python2.7/site-packages/dropbox/base.py", line 200, in files_download
    rev)
  File "/path/to/lib/python2.7/site-packages/dropbox/files.py", line 1623, in __init__
    self.path = path
  File "/path/to/lib/python2.7/site-packages/dropbox/files.py", line 1641, in path
    val = self._path_validator.validate(val)
  File "/path/to/lib/python2.7/site-packages/dropbox/babel_validators.py", line 296, in validate
    % (val, self.pattern))
dropbox.babel_validators.ValidationError: 'id:YYYYYYYYYYY' did not match pattern '/.*'

Changelog?

Is there a Changelog for the new SDK? The releases seem to be coming rapidly. I'm using dropbox 2.2.0, but versions 3, 4, and 5 have come out recently and there is no way to know what changes they contain. I don't know if I should upgrade or not, and if I do upgrade what changes I should make.

Is there a Changelog anywhere? And if not, I would like to request one.

Use tox for runtests

From @ewjoachim: Would you be ok to using tox instead of calling "python2" and "python3" directly in runtests. For those using virtualenvs instead of globally installing packages, that can smooth this a lot.

'str' object has no attribute 'copy'

running the example in http://dropbox-sdk-python.readthedocs.org/en/master/moduledoc.html#module-dropbox.oauth.DropboxOAuth2FlowNoRedirect:

breaks in self.build_path with:

AttributeError: 'str' object has no attribute 'copy'

seems happening in here:
@111 return "https://%s%s" % (self._host, self.build_path(target, params))

as self.build_url expect the second argument to be a dict (as by docstring) but actually is a string:
@50 url = self.build_url(Dropbox.HOST_API, '/oauth2/token')

Hope it helps.
L.

lost timezone

In dropbox.babel_serializers.js, it appears that the UTC/GMT timezone in the original datetime string is lost during the conversion of a Timestamp value to python object,

    if isinstance(data_type, bv.Timestamp):
        try:
            return datetime.datetime.strptime(val, data_type.format)
        except ValueError as e:
            raise bv.ValidationError(e.args[0])

DropboxOAuth2Flow.start() produces incorrect URL on Python 3

dropbox.DropboxOAuth2Flow(
    APP_KEY, APP_SECRET,
    redirect_uri, session, 'dropbox-auth-csrf-token'
).start()

This code returns:

https://www.dropbox.com/1/oauth2/authorize?redirect_uri=http://localhost:5000/dropbox-auth-finish&response_type=code&client_id=REDACTED&state=b'REDACTED'

Notice that at the end this contains a representation of a bytestring, which is invalid.

Consequently:

dropbox.oauth.CsrfException: expected b'REDACTED', got "b'REDACTED'"

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.