mirror of
https://github.com/robweber/xbmcbackup.git
synced 2024-12-23 06:27:55 +01:00
fixed Dropbox VFS
This commit is contained in:
parent
625de8fa71
commit
7e703ca08c
@ -11,9 +11,6 @@ APP_SECRET = utils.getSetting('dropbox_secret')
|
|||||||
class Vfs:
|
class Vfs:
|
||||||
root_path = None
|
root_path = None
|
||||||
|
|
||||||
def __init(self):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def __init__(self,rootString):
|
def __init__(self,rootString):
|
||||||
self.set_root(rootString)
|
self.set_root(rootString)
|
||||||
|
|
||||||
@ -70,8 +67,8 @@ class DropboxFileSystem(Vfs):
|
|||||||
client = None
|
client = None
|
||||||
|
|
||||||
def __init__(self,rootString):
|
def __init__(self,rootString):
|
||||||
|
self.set_root(rootString)
|
||||||
self.setup()
|
self.setup()
|
||||||
Vfs.__init__(rootString)
|
|
||||||
|
|
||||||
def setup(self):
|
def setup(self):
|
||||||
if(APP_KEY == '' or APP_SECRET == ''):
|
if(APP_KEY == '' or APP_SECRET == ''):
|
||||||
@ -123,6 +120,7 @@ class DropboxFileSystem(Vfs):
|
|||||||
|
|
||||||
|
|
||||||
def mkdir(self,directory):
|
def mkdir(self,directory):
|
||||||
|
directory = self._fix_slashes(directory)
|
||||||
if(self.client != None):
|
if(self.client != None):
|
||||||
if(not self.exists(directory)):
|
if(not self.exists(directory)):
|
||||||
self.client.file_create_folder(directory)
|
self.client.file_create_folder(directory)
|
||||||
@ -131,12 +129,14 @@ class DropboxFileSystem(Vfs):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
def rmdir(self,directory):
|
def rmdir(self,directory):
|
||||||
|
directory = self._fix_slashes(directory)
|
||||||
if(self.client != None and self.exists(directory)):
|
if(self.client != None and self.exists(directory)):
|
||||||
self.client.file_delete(directory)
|
self.client.file_delete(directory)
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def exists(self,aFile):
|
def exists(self,aFile):
|
||||||
|
aFile = self._fix_slashes(aFile)
|
||||||
if(self.client != None):
|
if(self.client != None):
|
||||||
try:
|
try:
|
||||||
meta_data = self.client.metadata(aFile)
|
meta_data = self.client.metadata(aFile)
|
||||||
@ -148,6 +148,8 @@ class DropboxFileSystem(Vfs):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
def put(self,source,dest):
|
def put(self,source,dest):
|
||||||
|
dest = self._fix_slashes(dest)
|
||||||
|
|
||||||
if(self.client != None):
|
if(self.client != None):
|
||||||
f = open(source,'rb')
|
f = open(source,'rb')
|
||||||
try:
|
try:
|
||||||
@ -170,6 +172,9 @@ class DropboxFileSystem(Vfs):
|
|||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
def _fix_slashes(self,filename):
|
||||||
|
return filename.replace('\\','/')
|
||||||
|
|
||||||
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…
Reference in New Issue
Block a user