cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
What’s new: end-to-end encryption, Replay and Dash updates. Find out more about these updates, new features and more here.

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Re: Upload Error with v2 (migration from v1)

Upload Error with v2 (migration from v1)

OGMC
Helpful | Level 6
Go to solution

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.

15 Replies 15

Greg-DB
Dropbox Staff
Go to solution
Also, can you let us know what version of Python itself you're using? Thanks in advance!

OGMC
Helpful | Level 6
Go to solution

Hi,

 

Python 2.7

 

Thanks.

Greg-DB
Dropbox Staff
Go to solution

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__'

OGMC
Helpful | Level 6
Go to solution

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
Helpful | Level 6
Go to solution

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-DB
Dropbox Staff
Go to solution
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.
Need more support?