cancel
Showing results for 
Search instead for 
Did you mean: 
Announcements
Update: Find information on Dropbox support during COVID-19 here
Close
cancel
Showing results for 
Search instead for 
Did you mean: 

Upload Error with v2 (migration from v1)

OGMC
Helpful | Level 6

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
raise bv.ValidationError(e.args[0])
ValidationError: client_modified: attribute of type 'NoneType' is not callable

 

I'm not sending a client mod time and not sure how to fix this.

 

I have to say v2 is much more complicated than v1 and feel the docs could use a lot of examples in them.

 

 

Any help would be appreciated.

2 Accepted Solutions

Accepted Solutions

Re: Upload Error with v2 (migration from v1)

OGMC
Helpful | 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.

 

 

 

View solution in original post

Re: Upload Error with v2 (migration from v1)

Dropboxer
Dropboxer
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.

View solution in original post

15 Replies 15

Re: Upload Error with v2 (migration from v1)

Dropboxer
Dropboxer
Can you share the code that produces this, and the version number of the SDK you have installed? Thanks in advance!

Re: Upload Error with v2 (migration from v1)

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

Re: Upload Error with v2 (migration from v1)

Dropboxer
Dropboxer

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! 

Re: Upload Error with v2 (migration from v1)

OGMC
Helpful | 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__

Re: Upload Error with v2 (migration from v1)

Dropboxer
Dropboxer
If 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.

Re: Upload Error with v2 (migration from v1)

OGMC
Helpful | 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.

Re: Upload Error with v2 (migration from v1)

Dropboxer
Dropboxer
Thanks! 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?

Re: Upload Error with v2 (migration from v1)

OGMC
Helpful | 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.

Re: Upload Error with v2 (migration from v1)

Dropboxer
Dropboxer
Thanks! We're looking into it.

Work Smarter with Dropbox

The way we work is changing. Share and discover new ways to work smarter with Dropbox in our community.

Sound good? Let's get started.
Who's talking

Top contributors to this post

What do Dropbox user levels mean?
Need more support?