Skip to content

Commit

Permalink
Adding ian1roberts' patch from issue #2 to fix session saving
Browse files Browse the repository at this point in the history
  • Loading branch information
handyman5 committed Mar 31, 2015
1 parent dec17c1 commit 7cd9363
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions acd
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import json
import logging
import os
import os.path
import pickle
import tempfile

try:
Expand Down Expand Up @@ -64,20 +65,24 @@ class ACDFS(fuse.Fuse):
def main(self):
try:
print "Trying to login from cached sessionfile %s" % self.sessionfile
with open(self.sessionfile, "r") as sessfile:
with open(self.sessionfile, "rb") as sessfile:
session = pyacd.auth.Session()
session.__dict__ = json.load(sessfile)
session.__dict__ = pickle.load(sessfile)
self.session = pyacd.login(session=session)
self.session.__dict__['agreed_with_terms']=True
self.session.username = self.email
if not self.session.is_valid() or not self.session.is_logined():
raise ValueError
except (IOError, ValueError, pyacd.exception.PyAmazonCloudDriveError):
print "Cached session failed; trying auth login"
if not self.email or not self.password:
# if no email or password and they're needed, error out and die
raise ValueError("No login information provided; try again with mount options 'email' and 'password'")
with open(self.sessionfile, "w") as sessfile:
with open(self.sessionfile, "wb") as sessfile:
self.session = pyacd.login(self.email, self.password)
json.dump(self.session.__dict__, sessfile)
self.session.__dict__['agreed_with_terms']=True
self.session.username = self.email
pickle.dump(self.session.__dict__, sessfile)
print "Login successful; starting filesystem"
self.download = self.api.can_device_download()

Expand Down

0 comments on commit 7cd9363

Please sign in to comment.