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 Greg,
What file is the version number in? i can't seem to find it.
the current code i'm using has evolved from the example you posted in another thread which was giving me the same error.
with open(localFile, 'rb') as f: CHUNK_SIZE = 4 * 1024 * 1024 if fileSize <= CHUNK_SIZE: smallFileUpload(client, dpBG, localFile, destPath, overwrite, dispName, silent) else: upload_session_start_result = dbx.files_upload_session_start(f.read(CHUNK_SIZE)) cursor = dropbox.files.UploadSessionCursor(session_id=upload_session_start_result.session_id, offset=f.tell()) commit = dropbox.files.CommitInfo(path=destPath) while f.tell() < fileSize: if ((fileSize - f.tell()) <= CHUNK_SIZE): dbx.files_upload_session_finish(f.read(CHUNK_SIZE), cursor, commit) else: dbx.files_upload_session_append_v2(f.read(CHUNK_SIZE), cursor) cursor.offset = f.tell() if not silent: if dpBG == "dpbg": dpbg.update(100, "", "Upload Complete") dpbg.close() elif dpBG == "dp": dp.update(100, "", "COMPLETE!") dp.close() else: Notify(title=SubTitle, message="[COLORyellow]%s[/COLOR] Upload [COLORlimegreen]Complete[/COLOR]!" % (dispName), duration=4000, icon=ART_URL + 'ogdb.png') if xbmcaddon.Addon(thisAddonID).getSetting("backres_dbox_removelocal") == 'true': try: os.remove(localFile) except: pass
Greg-DB
8 years agoDropbox Staff
You can see the version by printing dropbox.__version__. The latest release is v8.2.0. If you're not already on that, please upgrade and try again.
If you are seeing this on the latest version, please share the whole stack trace. I can't seem to reproduce this issue with v8.2.0, and it's unclear in which line of your code this is occuring. Thanks in advance!
- OGMC8 years agoHelpful | Level 6
Hi Greg,
Thanks for getting back to me.
I'm a tad confused. I get 0.0.0 when i print dropbox.__version__
- Greg-DB8 years agoDropbox StaffIf it's printing 0.0.0, that should indicate that your copy was just pulled from master, as opposed to installed from a particular release.
Do you know recall you got the SDK exactly? For example, if you cloned it, please pull the latest from master. Alternatively, please install the latest, e.g., using pip.- OGMC8 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.
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!