mirror of
https://github.com/robweber/xbmcbackup.git
synced 2024-11-15 04:45:49 +01:00
updated dropbox methods - listdir now works
This commit is contained in:
parent
5b6b5d6c9a
commit
535cd43e8a
@ -83,6 +83,23 @@ class DropboxFileSystem(Vfs):
|
|||||||
self.client = client.DropboxClient(sess)
|
self.client = client.DropboxClient(sess)
|
||||||
utils.log(str(self.client.account_info()))
|
utils.log(str(self.client.account_info()))
|
||||||
|
|
||||||
|
def listdir(self,directory):
|
||||||
|
if(self.client != None and self.exists(directory)):
|
||||||
|
files = []
|
||||||
|
dirs = []
|
||||||
|
metadata = self.client.metadata(directory)
|
||||||
|
|
||||||
|
for aFile in metadata['contents']:
|
||||||
|
if(aFile['is_dir']):
|
||||||
|
dirs.append(aFile['path'][len(directory):])
|
||||||
|
else:
|
||||||
|
files.append(aFile['path'][len(directory):])
|
||||||
|
|
||||||
|
return [dirs,files]
|
||||||
|
else:
|
||||||
|
return [[],[]]
|
||||||
|
|
||||||
|
|
||||||
def mkdir(self,directory):
|
def mkdir(self,directory):
|
||||||
if(self.client != None):
|
if(self.client != None):
|
||||||
if(not self.exists(directory)):
|
if(not self.exists(directory)):
|
||||||
@ -91,6 +108,12 @@ class DropboxFileSystem(Vfs):
|
|||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
def rmdir(self,directory):
|
||||||
|
if(self.client != None and self.exists(directory)):
|
||||||
|
self.client.file_delete(directory)
|
||||||
|
else:
|
||||||
|
return False
|
||||||
|
|
||||||
def exists(self,aFile):
|
def exists(self,aFile):
|
||||||
if(self.client != None):
|
if(self.client != None):
|
||||||
try:
|
try:
|
||||||
@ -105,8 +128,13 @@ class DropboxFileSystem(Vfs):
|
|||||||
def copy(self,source,dest):
|
def copy(self,source,dest):
|
||||||
if(self.client != None):
|
if(self.client != None):
|
||||||
f = open(source,'rb')
|
f = open(source,'rb')
|
||||||
|
try:
|
||||||
response = self.client.put_file(dest,f,True)
|
response = self.client.put_file(dest,f,True)
|
||||||
return True
|
return True
|
||||||
|
except:
|
||||||
|
#if we have an exception retry
|
||||||
|
retry = True
|
||||||
|
return self.copy(source,dest)
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user