Need to see if your shared folder is taking up space on your dropbox 👨💻? Find out how to check here.
Forum Discussion
OGMC
9 years agoHelpful | Level 6
Upload Error with v2 (migration from v1)
Hi I am currently in the process of migrating my code to use v2 and am hitting an error when trying to upload in python.
Error:
stone_serializers.py", line 887, in _make_stone_friendly rais...
- 9 years ago
Ok after some investigating I have noticed the first attempt gives no errors, all subsequent attempts give the client modified nonetype error.
After some googling I finally came accross some info that this is a known issue with datetime in python.
I found this:
try: datetime.strptime(date_string, format) except TypeError: datetime(*(time.strptime(date_string, format)[0:6]))So I decided to manually tweak the make stone friendly function in the api to this.
def _make_stone_friendly( data_type, val, alias_validators, strict, validate, for_msgpack): """ Convert a Python object to a type that will pass validation by its validator. Validation by ``alias_validators`` is performed even if ``validate`` is false. """ if isinstance(data_type, bv.Timestamp): try: ret = datetime.datetime.strptime(val, data_type.format) except: print("datetime.datetime.strptime(val, data_type.format) returned NoneType. Trying alterntive") pass try: ret = datetime.datetime(*(time.strptime(val, data_type.format)[0:6])) except (TypeError, ValueError) as e: raise bv.ValidationError(e.args[0]) elif isinstance(data_type, bv.Bytes): if for_msgpack: if isinstance(val, six.text_type): ret = val.encode('utf-8') else: ret = val else: try: ret = base64.b64decode(val) except TypeError: raise bv.ValidationError('invalid base64-encoded bytes') elif isinstance(data_type, bv.Void): if strict and val is not None: raise bv.ValidationError("expected null, got value") return None else: if validate: data_type.validate(val) ret = val if alias_validators is not None and data_type in alias_validators: alias_validators[data_type](ret) return retI can say it is now working every time without error.
I'm sure you don't like the code being altered and I can totally understand that but if you think the code doesn't look like it will yeild any issues then I'm happy to do a pull request on github.
- 9 years agoThanks! I'm glad to hear you got this working. I'll ask the team to take a look over to see if this is a change that should be added to the SDK.
OGMC
9 years agoHelpful | Level 6
Yes I had downloaded the master from github.
I've now downloaded 8.2.0 but I'm getting the same error.
Here is the stack trace.
Traceback (most recent call last):
File "/Users/John/Library/Application Support/Kodi/addons/script.module.python.koding.aio/lib/koding/router.py", line 133, in Run
master_modes[mode]["function"](*evaled_args)
File "/Users/John/Library/Application Support/Kodi/addons/plugin.program.ogtools/resources/lib/modules/dbox.py", line 296, in browseUploader
largeUploader(localFile=file2upload, dispName=fileName, silent=False)
File "/Users/John/Library/Application Support/Kodi/addons/plugin.program.ogtools/resources/lib/modules/dbox.py", line 208, in largeUploader
dbx.files_upload_session_finish(f.read(CHUNK_SIZE), cursor, commit)
File "/Users/John/Library/Application Support/Kodi/addons/script.module.dropbox2/lib/dropbox/base.py", line 2034, in files_upload_session_finish
f,
File "/Users/John/Library/Application Support/Kodi/addons/script.module.dropbox2/lib/dropbox/dropbox.py", line 250, in request
returned_data_type, obj, strict=False)
File "/Users/John/Library/Application Support/Kodi/addons/script.module.dropbox2/lib/dropbox/stone_serializers.py", line 523, in json_compat_obj_decode
data_type, obj, alias_validators, strict, old_style, for_msgpack)
File "/Users/John/Library/Application Support/Kodi/addons/script.module.dropbox2/lib/dropbox/stone_serializers.py", line 536, in _json_compat_obj_decode_helper
data_type, obj, alias_validators, strict, old_style, for_msgpack)
File "/Users/John/Library/Application Support/Kodi/addons/script.module.dropbox2/lib/dropbox/stone_serializers.py", line 581, in _decode_struct
old_style, for_msgpack)
File "/Users/John/Library/Application Support/Kodi/addons/script.module.dropbox2/lib/dropbox/stone_serializers.py", line 605, in _decode_struct_fields
old_style, for_msgpack)
File "/Users/John/Library/Application Support/Kodi/addons/script.module.dropbox2/lib/dropbox/stone_serializers.py", line 557, in _json_compat_obj_decode_helper
data_type, obj, alias_validators, strict, False, for_msgpack)
File "/Users/John/Library/Application Support/Kodi/addons/script.module.dropbox2/lib/dropbox/stone_serializers.py", line 887, in _make_stone_friendly
raise bv.ValidationError(e.args[0])
ValidationError: client_modified: attribute of type 'NoneType' is not callable
I hope this helps.
Thanks again.
Greg-DB
Dropbox Community Moderator
9 years agoThanks! Since you downloaded the source, did you run `python setup.py install` as instructed here?
https://github.com/dropbox/dropbox-sdk-python#installation
Please do so if you haven't already. If you did, did you get any errors?
https://github.com/dropbox/dropbox-sdk-python#installation
Please do so if you haven't already. If you did, did you get any errors?
- OGMC9 years agoHelpful | Level 6
Hi yes, I did that but same outcome. (no errors on install)
I just noticed the item does actually upload but looks like the return meta is giving a none type for client mod and it doesn't like it.
I maybe misreading that but still getting the error.
- Greg-DB9 years ago
Dropbox Community Moderator
Thanks! We're looking into it. - Greg-DB9 years ago
Dropbox Community Moderator
Also, can you let us know what version of Python itself you're using? Thanks in advance! - OGMC9 years agoHelpful | Level 6
Hi,
Python 2.7
Thanks.
- Greg-DB9 years ago
Dropbox Community Moderator
We could use a bit more information. Can you run the following and share the output? Thanks in advance!
python -c 'import dropbox;print dropbox.__version__;print dropbox.__package__;print dropbox.__file__'
- OGMC9 years agoHelpful | Level 6
Hi,
Here you go.
8.2.0
dropbox
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/dropbox-8.2.0-py2.7.egg/dropbox/__init__.pycand here it is from the kodi module i made
8.2.0
dropbox
/Users/John/Library/Application Support/Kodi/addons/script.module.dropbox2/lib/dropbox/__init__.pyo - OGMC9 years agoHelpful | Level 6
Ok after some investigating I have noticed the first attempt gives no errors, all subsequent attempts give the client modified nonetype error.
After some googling I finally came accross some info that this is a known issue with datetime in python.
I found this:
try: datetime.strptime(date_string, format) except TypeError: datetime(*(time.strptime(date_string, format)[0:6]))So I decided to manually tweak the make stone friendly function in the api to this.
def _make_stone_friendly( data_type, val, alias_validators, strict, validate, for_msgpack): """ Convert a Python object to a type that will pass validation by its validator. Validation by ``alias_validators`` is performed even if ``validate`` is false. """ if isinstance(data_type, bv.Timestamp): try: ret = datetime.datetime.strptime(val, data_type.format) except: print("datetime.datetime.strptime(val, data_type.format) returned NoneType. Trying alterntive") pass try: ret = datetime.datetime(*(time.strptime(val, data_type.format)[0:6])) except (TypeError, ValueError) as e: raise bv.ValidationError(e.args[0]) elif isinstance(data_type, bv.Bytes): if for_msgpack: if isinstance(val, six.text_type): ret = val.encode('utf-8') else: ret = val else: try: ret = base64.b64decode(val) except TypeError: raise bv.ValidationError('invalid base64-encoded bytes') elif isinstance(data_type, bv.Void): if strict and val is not None: raise bv.ValidationError("expected null, got value") return None else: if validate: data_type.validate(val) ret = val if alias_validators is not None and data_type in alias_validators: alias_validators[data_type](ret) return retI can say it is now working every time without error.
I'm sure you don't like the code being altered and I can totally understand that but if you think the code doesn't look like it will yeild any issues then I'm happy to do a pull request on github.
- Greg-DB9 years ago
Dropbox Community Moderator
Thanks! I'm glad to hear you got this working. I'll ask the team to take a look over to see if this is a change that should be added to the SDK.
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.
If you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X, Facebook or Instagram.
For more info on available support options for your Dropbox plan, see this article.
If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!