Hi,
This was working up until a few weeks ago and I can't for the life of me see what is wrong - maybe a fresh set of eyes will help.
I am trying to loop through the contents of a directory and upload the unique files to an applicaiton folder in dropbox apps:
import dropbox
import os
from datetime import datetime
access_token = '########################'
def upload_file(file_from, file_to):
print "Source :"+file_from
print "Dest :"+file_to
dbx = dropbox.Dropbox(access_token)
f = open(file_from, 'rb')
dbx.files_upload(f.read(), file_to)
for jpgfile in os.listdir("/home/pi/pir/captures/jpg"):
if jpgfile.endswith(".jpg"):
print datetime.now().strftime("%y/%m/%d %H:%M:%S")+": "+"Uploading capture image."#
file_from='/home/pi/pir/captures/jpg/180817182433.jpg'
file_to = '/PIR_APP/180817182433.jpg
upload_file(file_from, file_to)
Note, I have hardcoded the file name for testing purposes.
I get the following error:
Traceback (most recent call last):
File "dp_test.py", line 26, in <module>
upload_file(file_from, file_to)
File "dp_test.py", line 14, in upload_file
dbx.files_upload(f.read(), file_to)
File "/usr/local/lib/python2.7/dist-packages/dropbox/base.py", line 2207, in files_upload
f,
File "/usr/local/lib/python2.7/dist-packages/dropbox/dropbox.py", line 274, in request
timeout=timeout)
File "/usr/local/lib/python2.7/dist-packages/dropbox/dropbox.py", line 365, in request_json_string_with_retry
timeout=timeout)
File "/usr/local/lib/python2.7/dist-packages/dropbox/dropbox.py", line 449, in request_json_string
timeout=timeout,
File "/usr/lib/python2.7/dist-packages/requests/sessions.py", line 500, in post
return self.request('POST', url, data=data, json=json, **kwargs)
File "/usr/lib/python2.7/dist-packages/requests/sessions.py", line 457, in request
resp = self.send(prep, **send_kwargs)
File "/usr/lib/python2.7/dist-packages/requests/sessions.py", line 569, in send
r = adapter.send(request, **kwargs)
File "/usr/lib/python2.7/dist-packages/requests/adapters.py", line 362, in send
timeout=timeout
File "/usr/lib/python2.7/dist-packages/urllib3/connectionpool.py", line 516, in urlopen
body=body, headers=headers)
File "/usr/lib/python2.7/dist-packages/urllib3/connectionpool.py", line 308, in _make_request
conn.request(method, url, **httplib_request_kw)
File "/usr/lib/python2.7/httplib.py", line 1039, in request
self._send_request(method, url, body, headers)
File "/usr/lib/python2.7/httplib.py", line 1073, in _send_request
self.endheaders(body)
File "/usr/lib/python2.7/httplib.py", line 1035, in endheaders
self._send_output(message_body)
File "/usr/lib/python2.7/httplib.py", line 879, in _send_output
self.send(msg)
File "/usr/lib/python2.7/httplib.py", line 855, in send
self.sock.sendall(data)
File "/usr/lib/python2.7/dist-packages/urllib3/contrib/pyopenssl.py", line 208, in sendall
return self.connection.sendall(data)
File "/usr/lib/python2.7/dist-packages/OpenSSL/SSL.py", line 977, in sendall
self._raise_ssl_error(self._ssl, result)
File "/usr/lib/python2.7/dist-packages/OpenSSL/SSL.py", line 849, in _raise_ssl_error
raise WantWriteError()
OpenSSL.SSL.WantWriteError
Any ideas?
Thanks in advance,
Matt