mirror of
https://github.com/robweber/xbmcbackup.git
synced 2025-04-20 17:16:14 +02:00
added "restore" to Dropbox functions
This commit is contained in:
parent
535cd43e8a
commit
be7aea90bb
@ -225,7 +225,12 @@ class XbmcBackup:
|
|||||||
if (aFile.startswith("-")):
|
if (aFile.startswith("-")):
|
||||||
dest.mkdir(dest.root_path + aFile[1:])
|
dest.mkdir(dest.root_path + aFile[1:])
|
||||||
else:
|
else:
|
||||||
dest.copy(source.root_path + aFile,dest.root_path + aFile)
|
if(isinstance(source,DropboxFileSystem)):
|
||||||
|
#if copying from dropbox we need the file handle, use get_file
|
||||||
|
source.get_file(source.root_path + aFile,dest.root_path + aFile)
|
||||||
|
else:
|
||||||
|
#copy using normal method
|
||||||
|
dest.put(source.root_path + aFile,dest.root_path + aFile)
|
||||||
|
|
||||||
def updateProgress(self,message=''):
|
def updateProgress(self,message=''):
|
||||||
self.filesLeft = self.filesLeft - 1
|
self.filesLeft = self.filesLeft - 1
|
||||||
|
@ -31,9 +31,12 @@ class Vfs:
|
|||||||
def mkdir(self,directory):
|
def mkdir(self,directory):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def copy(self,source,dest):
|
def put(self,source,dest):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
def getFile(self,source):
|
||||||
|
return True
|
||||||
|
|
||||||
def rmdir(self,directory):
|
def rmdir(self,directory):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@ -48,9 +51,9 @@ class XBMCFileSystem(Vfs):
|
|||||||
def mkdir(self,directory):
|
def mkdir(self,directory):
|
||||||
return xbmcvfs.mkdir(directory)
|
return xbmcvfs.mkdir(directory)
|
||||||
|
|
||||||
def copy(self,source,dest):
|
def put(self,source,dest):
|
||||||
return xbmcvfs.copy(source,dest)
|
return xbmcvfs.copy(source,dest)
|
||||||
|
|
||||||
def rmdir(self,directory):
|
def rmdir(self,directory):
|
||||||
return xbmcvfs.rmdir(directory,True)
|
return xbmcvfs.rmdir(directory,True)
|
||||||
|
|
||||||
@ -125,7 +128,7 @@ class DropboxFileSystem(Vfs):
|
|||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def copy(self,source,dest):
|
def put(self,source,dest):
|
||||||
if(self.client != None):
|
if(self.client != None):
|
||||||
f = open(source,'rb')
|
f = open(source,'rb')
|
||||||
try:
|
try:
|
||||||
@ -137,7 +140,16 @@ class DropboxFileSystem(Vfs):
|
|||||||
return self.copy(source,dest)
|
return self.copy(source,dest)
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
def get_file(self,source,dest):
|
||||||
|
if(self.client != None):
|
||||||
|
#write the file locally
|
||||||
|
out = open(dest,'wb')
|
||||||
|
f = self.client.get_file(source).read()
|
||||||
|
out.write(f)
|
||||||
|
out.close()
|
||||||
|
else:
|
||||||
|
return False
|
||||||
def setToken(self,key,secret):
|
def setToken(self,key,secret):
|
||||||
#write the token files
|
#write the token files
|
||||||
token_file = open(xbmc.translatePath(utils.data_dir() + "tokens.txt"),'w')
|
token_file = open(xbmc.translatePath(utils.data_dir() + "tokens.txt"),'w')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user