handyman5 / acd_fuse

FUSE filesystem driver for Amazon Cloud Drive
Other
187 stars 23 forks source link

uk access and json save session bug #2

Closed ian1roberts closed 11 years ago

ian1roberts commented 11 years ago

Firstly, thanks for this tool. I've just got my cloud drive mounted on my fedora system.

I had a couple of issues 1) (not your concern) pyacd has configs for www.amazon.com and www.amazon.jp, so I had to add www.amazon.co.uk to pyacd.init.py, and set ubid ln 100. amazon_domain="www.amazon.co.uk" ln 135 "www.amazon.co.uk": "ubid-acbuk",

2) edit session dictionary object to 'accept_terms' and set username in acd ln 81-2 self.session.dict['agreed_with_terms']=True self.session.username = self.email

3) unable to dump session to file as session dictionary is not serializable. I commented out ln 83 to allow the cloud drive to mount

Would be interested in knowing if you've got a fix for (3)

Thanks again, Ian

Below is the error from json. Mounting proceeds if caching is commented out (ln 81-82)

Trying to login from cached sessionfile /tmp/acd_fuse/sessionfile
Cached session failed; trying auth login
Traceback (most recent call last):
  File "/home/ian/bin/acd", line 464, in <module>
    fs.main()
  File "/home/ian/bin/acd", line 83, in main
    json.dump(self.session.__dict__, sessfile)
  File "/usr/lib64/python2.7/json/__init__.py", line 181, in dump
    for chunk in iterable:
  File "/usr/lib64/python2.7/json/encoder.py", line 428, in _iterencode
    for chunk in _iterencode_dict(o, _current_indent_level):
  File "/usr/lib64/python2.7/json/encoder.py", line 402, in _iterencode_dict
    for chunk in chunks:
  File "/usr/lib64/python2.7/json/encoder.py", line 436, in _iterencode
    o = _default(o)
  File "/usr/lib64/python2.7/json/encoder.py", line 178, in default
    raise TypeError(repr(o) + " is not JSON serializable")
TypeError: <pyacd.auth.PicklableCookieJar[Cookie(version=0, 
etc etc etc
]> is not JSON serializable
ian1roberts commented 11 years ago

Little work around. I suggest changing json for pickle, this seems to fix the serialization issue. pyacd must have changed session api. a little.

e.g.

ln 74
            if not self.session.is_logged_in:

The following seems to work with session caching for me

ian@nixbox ~$ acd amazon_cloud
/tmp/acd_fuse/sessionfile
Trying to login from cached sessionfile /tmp/acd_fuse/sessionfile
Login successful; starting filesystem

These were the lines I changed ...

import pickle
ln 68
           with open(self.sessionfile, "rb") as sessfile

ln 70-3
                session.__dict__ = pickle.load(sessfile)
                self.session = pyacd.login(session=session)
                self.session.__dict__['agreed_with_terms']=True
                self.session.username = self.email

ln 81
            with open(self.sessionfile, "wb") as sessfile:
ln 85
                self.session.__dict__['agreed_with_terms']=True
                self.session.username = self.email
                pickle.dump(self.session.__dict__, sessfile)