mirror of
https://github.com/robweber/xbmcbackup.git
synced 2024-11-14 20:35:48 +01:00
adding hardcoded strings to strings.xml - not fully localized yet
This commit is contained in:
parent
c409bf01a4
commit
7ca7912749
43
default.py
43
default.py
@ -4,6 +4,9 @@ import xbmcgui
|
|||||||
import resources.lib.vfs as vfs
|
import resources.lib.vfs as vfs
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
__addon_id__ = 'script.xbmcbackup'
|
||||||
|
__Addon = xbmcaddon.Addon(__addon_id__)
|
||||||
|
|
||||||
class FileManager:
|
class FileManager:
|
||||||
walk_path = ''
|
walk_path = ''
|
||||||
addonDir = ''
|
addonDir = ''
|
||||||
@ -79,8 +82,7 @@ class FileManager:
|
|||||||
return self.fileArray
|
return self.fileArray
|
||||||
|
|
||||||
class XbmcBackup:
|
class XbmcBackup:
|
||||||
__addon_id__ = 'script.xbmcbackup'
|
addon = None
|
||||||
Addon = xbmcaddon.Addon(__addon_id__)
|
|
||||||
local_path = ''
|
local_path = ''
|
||||||
remote_path = ''
|
remote_path = ''
|
||||||
restoreFile = None
|
restoreFile = None
|
||||||
@ -92,17 +94,18 @@ class XbmcBackup:
|
|||||||
|
|
||||||
fileManager = None
|
fileManager = None
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self,__Addon):
|
||||||
|
self.addon = __Addon
|
||||||
self.local_path = xbmc.translatePath("special://home").encode("utf-8");
|
self.local_path = xbmc.translatePath("special://home").encode("utf-8");
|
||||||
|
|
||||||
if(self.Addon.getSetting('remote_selection') == '1' and vfs.exists(self.Addon.getSetting('remote_path_2'))):
|
if(self.addon.getSetting('remote_selection') == '1' and vfs.exists(self.addon.getSetting('remote_path_2'))):
|
||||||
self.remote_path = self.Addon.getSetting('remote_path_2')
|
self.remote_path = self.addon.getSetting('remote_path_2')
|
||||||
self.Addon.setSetting("remote_path","")
|
self.addon.setSetting("remote_path","")
|
||||||
elif(self.Addon.getSetting('remote_selection') == '0' and vfs.exists(self.Addon.getSetting("remote_path"))):
|
elif(self.addon.getSetting('remote_selection') == '0' and vfs.exists(self.addon.getSetting("remote_path"))):
|
||||||
self.remote_path = self.Addon.getSetting("remote_path")
|
self.remote_path = self.addon.getSetting("remote_path")
|
||||||
|
|
||||||
if(self.Addon.getSetting("backup_name") != '' and self.remote_path != ''):
|
if(self.addon.getSetting("backup_name") != '' and self.remote_path != ''):
|
||||||
self.remote_path = self.remote_path + self.Addon.getSetting("backup_name") + "/"
|
self.remote_path = self.remote_path + self.addon.getSetting("backup_name") + "/"
|
||||||
else:
|
else:
|
||||||
self.remote_path = ""
|
self.remote_path = ""
|
||||||
|
|
||||||
@ -114,16 +117,16 @@ class XbmcBackup:
|
|||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
#check if we should use the progress bar
|
#check if we should use the progress bar
|
||||||
if(self.Addon.getSetting('run_silent') == 'false'):
|
if(self.addon.getSetting('run_silent') == 'false'):
|
||||||
self.progressBar = xbmcgui.DialogProgress()
|
self.progressBar = xbmcgui.DialogProgress()
|
||||||
self.progressBar.create('XBMC Backup','Gathering file list.....')
|
self.progressBar.create('XBMC Backup','Gathering file list.....')
|
||||||
|
|
||||||
#check what mode were are in
|
#check what mode were are in
|
||||||
if(int(self.Addon.getSetting('addon_mode')) == 0):
|
if(int(self.addon.getSetting('addon_mode')) == 0):
|
||||||
self.fileManager = FileManager(self.local_path,self.Addon.getAddonInfo('profile'))
|
self.fileManager = FileManager(self.local_path,self.addon.getAddonInfo('profile'))
|
||||||
self.syncFiles()
|
self.syncFiles()
|
||||||
else:
|
else:
|
||||||
self.fileManager = FileManager(self.remote_path,self.Addon.getAddonInfo('profile'))
|
self.fileManager = FileManager(self.remote_path,self.addon.getAddonInfo('profile'))
|
||||||
self.restoreFiles()
|
self.restoreFiles()
|
||||||
|
|
||||||
def syncFiles(self):
|
def syncFiles(self):
|
||||||
@ -135,7 +138,7 @@ class XbmcBackup:
|
|||||||
vfs.mkdir(self.remote_path)
|
vfs.mkdir(self.remote_path)
|
||||||
|
|
||||||
self.log("Creating Files List")
|
self.log("Creating Files List")
|
||||||
self.fileManager.createFileList(self.Addon)
|
self.fileManager.createFileList(self.addon)
|
||||||
|
|
||||||
allFiles = self.fileManager.getFileList()
|
allFiles = self.fileManager.getFileList()
|
||||||
|
|
||||||
@ -143,7 +146,7 @@ class XbmcBackup:
|
|||||||
self.writeFiles(allFiles,self.local_path,self.remote_path)
|
self.writeFiles(allFiles,self.local_path,self.remote_path)
|
||||||
|
|
||||||
def restoreFiles(self):
|
def restoreFiles(self):
|
||||||
self.fileManager.createFileList(self.Addon)
|
self.fileManager.createFileList(self.addon)
|
||||||
|
|
||||||
self.log("Creating Files List")
|
self.log("Creating Files List")
|
||||||
allFiles = self.fileManager.getFileList()
|
allFiles = self.fileManager.getFileList()
|
||||||
@ -169,7 +172,7 @@ class XbmcBackup:
|
|||||||
else:
|
else:
|
||||||
vfs.copy(source + aFile,dest + aFile)
|
vfs.copy(source + aFile,dest + aFile)
|
||||||
|
|
||||||
if(self.Addon.getSetting('run_silent') == 'false'):
|
if(self.addon.getSetting('run_silent') == 'false'):
|
||||||
self.progressBar.close()
|
self.progressBar.close()
|
||||||
|
|
||||||
def updateProgress(self,message=''):
|
def updateProgress(self,message=''):
|
||||||
@ -188,15 +191,15 @@ class XbmcBackup:
|
|||||||
return result
|
return result
|
||||||
|
|
||||||
def log(self,message):
|
def log(self,message):
|
||||||
xbmc.log(self.__addon_id__ + ": " + message)
|
xbmc.log(self.addon.getLocalizedString(30010) + ": " + message)
|
||||||
|
|
||||||
def isReady(self):
|
def isReady(self):
|
||||||
return True if self.remote_path != '' else False
|
return True if self.remote_path != '' else False
|
||||||
|
|
||||||
#run the profile backup
|
#run the profile backup
|
||||||
backup = XbmcBackup()
|
backup = XbmcBackup(__Addon)
|
||||||
|
|
||||||
if(backup.isReady()):
|
if(backup.isReady()):
|
||||||
backup.run()
|
backup.run()
|
||||||
else:
|
else:
|
||||||
xbmcgui.Dialog().ok('XBMC Backup','Error: Remote path cannot be empty')
|
xbmcgui.Dialog().ok(__Addon.getLocalizedString(30010),__Addon.getLocalizedString(30045))
|
||||||
|
@ -23,4 +23,12 @@
|
|||||||
<string id="30034">Thumbnails/Fanart</string>
|
<string id="30034">Thumbnails/Fanart</string>
|
||||||
<string id="30035">Config Files</string>
|
<string id="30035">Config Files</string>
|
||||||
|
|
||||||
|
<string id="30045">Error: Remote path cannot be empty</string>
|
||||||
|
<string id="30046">Starting</string>
|
||||||
|
<string id="30047">Local Dir</string>
|
||||||
|
<string id="30048">Remote Dir</string>
|
||||||
|
<string id="30049">Gathering file list</string>
|
||||||
|
<string id="30050">Remote Path exists - may have old files in it!</string>
|
||||||
|
<string id="30051">Creating Files List</string>
|
||||||
|
<string id="30052">Writing file</string>
|
||||||
</strings>
|
</strings>
|
||||||
|
Loading…
Reference in New Issue
Block a user