mirror of
https://github.com/robweber/xbmcbackup.git
synced 2025-06-22 02:33:41 +02:00
Merge branch 'master' into matrix
This commit is contained in:
@ -2,6 +2,7 @@ import json
|
||||
import xbmc
|
||||
import xbmcgui
|
||||
import xbmcvfs
|
||||
import os.path
|
||||
from . import utils as utils
|
||||
|
||||
|
||||
@ -180,14 +181,14 @@ class AdvancedBackupEditor:
|
||||
while(exitCondition != -1):
|
||||
# load the custom paths
|
||||
listItem = xbmcgui.ListItem(utils.getString(30126), '')
|
||||
listItem.setArt({'icon': utils.addon_dir() + 'resources/images/plus-icon.png'})
|
||||
listItem.setArt({'icon': os.path.join(utils.addon_dir(), 'resources', 'images', 'plus-icon.png')})
|
||||
options = [listItem]
|
||||
|
||||
for index in range(0, len(customPaths.getSets())):
|
||||
aSet = customPaths.getSet(index)
|
||||
|
||||
listItem = xbmcgui.ListItem(aSet['name'], utils.getString(30121) + ': ' + aSet['set']['root'])
|
||||
listItem.setArt({'icon': utils.addon_dir() + 'resources/images/folder-icon.png'})
|
||||
listItem.setArt({'icon': os.path.join(utils.addon_dir(), 'resources', 'images', 'folder-icon.png')})
|
||||
options.append(listItem)
|
||||
|
||||
# show the gui
|
||||
@ -226,7 +227,7 @@ class AdvancedBackupEditor:
|
||||
shouldContinue = self.dialog.yesno(utils.getString(30139), utils.getString(30140), utils.getString(30141))
|
||||
|
||||
if(shouldContinue):
|
||||
source = xbmc.translatePath(utils.addon_dir() + "/resources/data/default_files.json")
|
||||
dest = xbmc.translatePath(utils.data_dir() + "/custom_paths.json")
|
||||
source = xbmc.translatePath(os.path.join(utils.addon_dir(), 'resources', 'data', 'default_files.json'))
|
||||
dest = xbmc.translatePath(os.path.join(utils.data_dir(), 'custom_paths.json'))
|
||||
|
||||
xbmcvfs.copy(source, dest)
|
||||
|
@ -124,14 +124,14 @@ class XbmcBackup:
|
||||
utils.log('File Selection Type: ' + str(utils.getSetting('backup_selection_type')))
|
||||
allFiles = []
|
||||
|
||||
if(int(utils.getSetting('backup_selection_type')) == 0):
|
||||
if(utils.getSettingInt('backup_selection_type') == 0):
|
||||
# read in a list of the directories to backup
|
||||
selectedDirs = self._readBackupConfig(utils.addon_dir() + "/resources/data/default_files.json")
|
||||
|
||||
# simple mode - get file listings for all enabled directories
|
||||
for aDir in self.simple_directory_list:
|
||||
# if this dir enabled
|
||||
if(utils.getSetting('backup_' + aDir) == 'true'):
|
||||
if(utils.getSettingBool('backup_' + aDir)):
|
||||
# get a file listing and append it to the allfiles array
|
||||
allFiles.append(self._addBackupDir(aDir, selectedDirs[aDir]['root'], selectedDirs[aDir]['dirs']))
|
||||
else:
|
||||
@ -176,7 +176,7 @@ class XbmcBackup:
|
||||
self.xbmc_vfs.set_root("special://home/")
|
||||
self.remote_vfs.set_root(orig_base_path)
|
||||
|
||||
if(utils.getSetting("compress_backups") == 'true'):
|
||||
if(utils.getSettingBool("compress_backups")):
|
||||
fileManager = FileManager(self.xbmc_vfs)
|
||||
|
||||
# send the zip file to the real remote vfs
|
||||
@ -333,7 +333,7 @@ class XbmcBackup:
|
||||
# append backup folder name
|
||||
progressBarTitle = utils.getString(30010) + " - "
|
||||
if(mode == self.Backup and self.remote_vfs.root_path != ''):
|
||||
if(utils.getSetting("compress_backups") == 'true'):
|
||||
if(utils.getSettingBool("compress_backups")):
|
||||
# delete old temp file
|
||||
if(self.xbmc_vfs.exists(xbmc.translatePath('special://temp/xbmc_backup_temp.zip'))):
|
||||
if(not self.xbmc_vfs.rmfile(xbmc.translatePath('special://temp/xbmc_backup_temp.zip'))):
|
||||
@ -387,7 +387,9 @@ class XbmcBackup:
|
||||
|
||||
for aFile in fileList:
|
||||
if(not self.progressBar.checkCancel()):
|
||||
utils.log('Writing file: ' + aFile, xbmc.LOGDEBUG)
|
||||
if(utils.getSettingBool('verbose_logging')):
|
||||
utils.log('Writing file: ' + aFile)
|
||||
|
||||
if(aFile.startswith("-")):
|
||||
self._updateProgress(aFile[len(source.root_path) + 1:])
|
||||
dest.mkdir(dest.root_path + aFile[len(source.root_path) + 1:])
|
||||
@ -438,7 +440,7 @@ class XbmcBackup:
|
||||
self.progressBar.updateProgress(int((float(self.filesTotal - self.filesLeft) / float(self.filesTotal)) * 100), message)
|
||||
|
||||
def _rotateBackups(self):
|
||||
total_backups = int(utils.getSetting('backup_rotation'))
|
||||
total_backups = utils.getSettingInt('backup_rotation')
|
||||
|
||||
if(total_backups > 0):
|
||||
# get a list of valid backup folders
|
||||
@ -522,14 +524,12 @@ class XbmcBackup:
|
||||
return result
|
||||
|
||||
def _createResumeBackupFile(self):
|
||||
rFile = xbmcvfs.File(xbmc.translatePath(utils.data_dir() + "resume.txt"), 'w')
|
||||
rFile.write(self.restore_point)
|
||||
rFile.close()
|
||||
with xbmcvfs.File(xbmc.translatePath(utils.data_dir() + "resume.txt"), 'w') as f:
|
||||
f.write(self.restore_point)
|
||||
|
||||
def _readBackupConfig(self, aFile):
|
||||
jFile = xbmcvfs.File(xbmc.translatePath(aFile), 'r')
|
||||
jsonString = jFile.read()
|
||||
jFile.close()
|
||||
with xbmcvfs.File(xbmc.translatePath(aFile), 'r') as f:
|
||||
jsonString = f.read()
|
||||
return json.loads(jsonString)
|
||||
|
||||
|
||||
@ -552,7 +552,9 @@ class FileManager:
|
||||
self.walkTree(xbmc.translatePath(aDir['path']), aDir['recurse'])
|
||||
|
||||
def walkTree(self, directory, recurse=True):
|
||||
utils.log('walking ' + directory + ', recurse: ' + str(recurse))
|
||||
if(utils.getSettingBool('verbose_logging')):
|
||||
utils.log('walking ' + directory + ', recurse: ' + str(recurse))
|
||||
|
||||
if(directory[-1:] == '/' or directory[-1:] == '\\'):
|
||||
directory = directory[:-1]
|
||||
|
||||
@ -593,11 +595,12 @@ class FileManager:
|
||||
|
||||
def addFile(self, filename):
|
||||
# write the full remote path name of this file
|
||||
utils.log("Add File: " + filename)
|
||||
if(utils.getSettingBool('verbose_logging')):
|
||||
utils.log("Add File: " + filename)
|
||||
|
||||
self.fileArray.append(filename)
|
||||
|
||||
def excludeFile(self, filename):
|
||||
|
||||
# remove trailing slash
|
||||
if(filename[-1] == '/' or filename[-1] == '\\'):
|
||||
filename = filename[:-1]
|
||||
|
@ -15,9 +15,9 @@ class BackupProgressBar:
|
||||
self.override = progressOverride
|
||||
|
||||
# check if we should use the progress bar
|
||||
if(int(utils.getSetting('progress_mode')) != 2):
|
||||
if(utils.getSettingInt('progress_mode') != 2):
|
||||
# check if background or normal
|
||||
if(int(utils.getSetting('progress_mode')) == 0 and not self.override):
|
||||
if(utils.getSettingInt('progress_mode') == 0 and not self.override):
|
||||
self.mode = self.DIALOG
|
||||
self.progressBar = xbmcgui.DialogProgress()
|
||||
else:
|
||||
|
@ -9,4 +9,4 @@ def shorten(aUrl):
|
||||
data = req.read()
|
||||
|
||||
# should be a tiny url
|
||||
return str(data)
|
||||
return data
|
||||
|
@ -30,6 +30,14 @@ def getSetting(name):
|
||||
return __Addon.getSetting(name)
|
||||
|
||||
|
||||
def getSettingBool(name):
|
||||
return bool(__Addon.getSettingBool(name))
|
||||
|
||||
|
||||
def getSettingInt(name):
|
||||
return __Addon.getSettingInt(name)
|
||||
|
||||
|
||||
def setSetting(name, value):
|
||||
__Addon.setSetting(name, value)
|
||||
|
||||
|
@ -1,9 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<settings>
|
||||
<category id="general" label="30011">
|
||||
<category id="general" label="30011" level="expert">
|
||||
<setting id="compress_backups" type="bool" label="30087" default="false" />
|
||||
<setting id="backup_rotation" type="number" label="30026" default="0" />
|
||||
<setting id="progress_mode" type="enum" label="30022" lvalues="30082|30083|30084" default="0" />
|
||||
<setting type="sep" />
|
||||
<setting id="verbose_logging" type="bool" label="Enable Verbose Logging" default="false" />
|
||||
<setting id="upgrade_notes" type="number" label="upgrade_notes" visible="false" default="1" />
|
||||
</category>
|
||||
<category id="backup_path" label="30048">
|
||||
|
Reference in New Issue
Block a user