You might see that the Dropbox Community team have been busy working on some major updates to the Community itself! So, here is some info on what’s changed, what’s staying the same and what you can expect from the Dropbox Community overall.
Forum Discussion
OGMC
8 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...
- 8 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 ret
I 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.
- 8 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
Helpful | 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__.pyc
and 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
OGMC
8 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 ret
I 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-DB8 years agoDropbox StaffThanks! 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.
5,910 PostsLatest Activity: 4 days agoIf 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 or Facebook.
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!
Related Content
- 2 years agoanonymous