cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Back again with another edition of 'How we use Dropbox', so find out how Emma uses to-do lists to get it all done here!

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Python SDK constant errors

Python SDK constant errors

RCR
Explorer | Level 3

Trying to make a small app that will read a pair of files from a dropbox folder and compile a small database from them. Just getting started, following the sample but I keep getting errors of different kinds.

I'm using virtualenv and have only installed dropbox and its dependencies using 

 

pip install dropbox

 

This is my pip freeze:

 

appdirs==1.4.3
certifi==2017.4.17
chardet==3.0.3
dropbox==7.3.1
idna==2.5
packaging==16.8
pyparsing==2.2.0
requests==2.16.5
six==1.10.0
urllib3==1.21.1

 

Trying to run the files_list_folder example, I first had an issue that any folder name would not pass some regex validation. Even a name as simple as 'testFolder' would fail.

Traceback (most recent call last):
  File "process-dropbox.py", line 7, in <module>
    for entry in dbx.files_list_folder('testFolder').entries:
  File ".../dbdata/backend/tests/dropbox/app-dropbox/lib/python2.7/site-packages/dropbox/base.py", line 710, in files_list_folder
    include_has_explicit_shared_members)
  File ".../dbdata/backend/tests/dropbox/app-dropbox/lib/python2.7/site-packages/dropbox/files.py", line 3180, in __init__
    self.path = path
  File ".../dbdata/backend/tests/dropbox/app-dropbox/lib/python2.7/site-packages/dropbox/files.py", line 3204, in path
    val = self._path_validator.validate(val)
  File ".../dbdata/backend/tests/dropbox/app-dropbox/lib/python2.7/site-packages/dropbox/stone_validators.py", line 316, in validate
    % (val, self.pattern))
dropbox.stone_validators.ValidationError: ‘testFolder’ did not match pattern '(/(.|[\r\n])*)?|(ns:[0-9]+(/.*)?)'

 

 

I decided to try an empty name (supposedly for the root directory) and that seems to pass the validation, but then it throws this error.

Traceback (most recent call last):
File "process-dropbox.py", line 5, in <module>
dbx.users_get_current_account()
File ".../dbdata/backend/tests/dropbox/app-dropbox/lib/python2.7/site-packages/dropbox/base.py", line 3277, in users_get_current_account
None,
File ".../dbdata/backend/tests/dropbox/app-dropbox/lib/python2.7/site-packages/dropbox/dropbox.py", line 239, in request
timeout=timeout)
File ".../dbdata/backend/tests/dropbox/app-dropbox/lib/python2.7/site-packages/dropbox/dropbox.py", line 330, in request_json_string_with_retry
timeout=timeout)
File ".../dbdata/backend/tests/dropbox/app-dropbox/lib/python2.7/site-packages/dropbox/dropbox.py", line 414, in request_json_string
timeout=timeout,
File ".../dbdata/backend/tests/dropbox/app-dropbox/lib/python2.7/site-packages/requests/sessions.py", line 570, in post
return self.request('POST', url, data=data, json=json, **kwargs)
File ".../dbdata/backend/tests/dropbox/app-dropbox/lib/python2.7/site-packages/requests/sessions.py", line 523, in request
resp = self.send(prep, **send_kwargs)
File ".../dbdata/backend/tests/dropbox/app-dropbox/lib/python2.7/site-packages/requests/sessions.py", line 643, in send
r = adapter.send(request, **kwargs)
File ".../dbdata/backend/tests/dropbox/app-dropbox/lib/python2.7/site-packages/requests/adapters.py", line 440, in send
timeout=timeout
File ".../dbdata/backend/tests/dropbox/app-dropbox/lib/python2.7/site-packages/urllib3/connectionpool.py", line 587, in urlopen
timeout_obj = self._get_timeout(timeout)
File ".../dbdata/backend/tests/dropbox/app-dropbox/lib/python2.7/site-packages/urllib3/connectionpool.py", line 302, in _get_timeout
return Timeout.from_float(timeout)
File ".../dbdata/backend/tests/dropbox/app-dropbox/lib/python2.7/site-packages/urllib3/util/timeout.py", line 154, in from_float
return Timeout(read=timeout, connect=timeout)
File ".../dbdata/backend/tests/dropbox/app-dropbox/lib/python2.7/site-packages/urllib3/util/timeout.py", line 94, in __init__
self._connect = self._validate_timeout(connect, 'connect')
File ".../dbdata/backend/tests/dropbox/app-dropbox/lib/python2.7/site-packages/urllib3/util/timeout.py", line 127, in _validate_timeout
"int, float or None." % (name, value))
ValueError: Timeout value connect was Timeout(connect=30, read=30, total=None), but it must be an int, float or None.

 


I also tried users_get_current_account and got the same error.

Not sure where to go from here. This feels like the dependencies are perhaps not the right versions or something. I am not sure where to go from here.

Thanks in advance for any help.

1 Accepted Solution

Accepted Solutions

Re: Python SDK constant errors

Greg-DB
Dropboxer
It looks like the ValueError issue is fixed in requests v2.17.1, so please update to that and let me know if you're still seeing any issues.

View solution in original post

13 Replies 13

Re: Python SDK constant errors

Greg-DB
Dropboxer
Thanks for writing in. Note that the first error is because non-root paths should start with a '/'. So, your path there should be "/testFolder", not "testFolder". The root path is identified by the empty path "".

The second error did start occurring with recent changes to the requests dependency. We're looking into that. As a workaround though, you can downgrade to requests v2.15.1.

Re: Python SDK constant errors

RCR
Explorer | Level 3

Thanks! By downgrading I have managed to run some of the API functions, but now I have another problem.

The app I started using has App Folder permissions (set to 'testFolder') and from what I can tell, the path used for endpoints is relative to that folder. So, if I want to list the contents of 'testFolder' I actually pass an empty path, correct?

Now, the issue is that I get an empty 'entries' array when I try to list the contents of 'testFolder' even though there is a file there.

I tested listing the contents of 'testFolder' with an app with 'Full Dropbox' permissions and it does list the file.

Any idea what could be the issue?

Re: Python SDK constant errors

Greg-DB
Dropboxer
That's correct, if your app has the "app folder" permission, everything your app does or "sees" is relative to the app folder itself. You would use "" to refer to the app folder itself, since it's your app's root, or "/subfolder", etc. to refer to something inside your app folder.

From your first paragraph, it sounds like "testFolder" is your app folder itself, so to list its contents you would use a path parameter of "". In your second paragraph, it sounds like you may be trying to specify "testFolder", which wouldn't be necessary. If you're still not seeing the expected results, please share the code and output.

Also, note that the full Dropbox version wouldn't be looking at the same files if you pass the same path string. I.e., using the path "/testFolder" would list the following folders, as seen on the Dropbox web site, for the respective permissions:

- full Dropbox: /testFolder

- app folder: /Apps/<app folder name>/testFolder

Re: Python SDK constant errors

Greg-DB
Dropboxer
It looks like the ValueError issue is fixed in requests v2.17.1, so please update to that and let me know if you're still seeing any issues.

View solution in original post

Re: Python SDK constant errors

RCR
Explorer | Level 3

Sorry I wasn't clear. Let me try again.

I have a folder called 'testFolder' and two apps. The folder itself has 1 PDF file.


For the app with access to a single folder, (set to 'testFolder' in the app settings), the following produces an empty list of entries:

for entry in dbx.files_list_folder('').entries:
    print(entry.name)

Now, for the app with full access, the following produces a list with the one entry for the PDF file:

for entry in dbx.files_list_folder('/Apps/testFolder').entries:
    print(entry.name)

These two operations are supposed to be accessing the same folder, are they not?

Thank you for your help so far

Re: Python SDK constant errors

Greg-DB
Dropboxer
Thanks for clarifying. Yes, those two should give you the same listing.

Make sure both apps are linked to the same account though. You can use users_get_current_account to check that.

If you're still getting unexpected results, feel free to open a ticket with the specific code and output from the affected account and we'll be happy to look into it specifically for you:

https://www.dropbox.com/developers/contact

Re: Python SDK constant errors

RCR
Explorer | Level 3

Well, this is curious. I have firgured it out, but I'm not sure if this is a glitch or not.

So, the original name of the folder for the app was the name of the App (something like App-Test-Name), but, like I said, I changed it in the settings to 'testFolder'.

I then created a folder with that name within the Apps folder. Right beside the original App-Test-Name folder.

I tested now (by adding a different file to App-Test-Name), and the single-folder app is actually listing the contents of the 'App-Test-Name' folder instead of  'testFolder'.

 

Something seems off here...

Re: Python SDK constant errors

Greg-DB
Dropboxer
Manually creating a folder won't connect it to your app. The app folder is a special app folder automatically created for the app when the app is linked to the user's account.

Also, if you change the app folder name setting for an app, it won't change the name of any app folders already created in already linked user accounts.

So, it sounds like this is working as expected, since the existing app folder was "App-Test-Name", and "testFolder" was just the normal folder you created after the fact.

Re: Python SDK constant errors

RCR
Explorer | Level 3

I see...

 

But then, what is the purpose of the 'App folder name' setting in the App dashboard?

 

I assumed that it would change the name of the connected folder after I changed the setting, but when it didn't, that's when I created the other folder.

Poll
We love to learn from the educators who use Dropbox. Whether you teach kids, teens, adults or a combination of all three, we want to know what apps and integrations you use with Dropbox to help with teaching. Which of the ones below is your favorite, or most used tool?
Who's talking

Top contributors to this post

  • User avatar
    Greg-DB Dropboxer
  • User avatar
    getrt1991 New member | Level 2
  • User avatar
    scps950707 Explorer | Level 4
  • User avatar
    RCR Explorer | Level 3
What do Dropbox user levels mean?
Need more support?