2012-09-12 22:03:46 +02:00
|
|
|
import xbmc
|
|
|
|
import xbmcgui
|
2012-09-12 22:30:54 +02:00
|
|
|
import xbmcvfs
|
2012-09-12 22:34:13 +02:00
|
|
|
import utils as utils
|
2012-09-12 22:03:46 +02:00
|
|
|
import time
|
2014-05-06 20:44:00 +02:00
|
|
|
import json
|
2014-07-30 22:16:58 +02:00
|
|
|
from vfs import XBMCFileSystem,DropboxFileSystem,ZipFileSystem
|
2014-10-31 17:40:47 +01:00
|
|
|
from resources.lib.guisettings import GuiSettingsManager
|
2012-10-22 22:02:30 +02:00
|
|
|
|
2014-02-09 20:56:25 +01:00
|
|
|
def folderSort(aKey):
|
|
|
|
result = aKey[0]
|
|
|
|
|
|
|
|
if(len(result) < 8):
|
|
|
|
result = result + "0000"
|
|
|
|
|
|
|
|
return result
|
|
|
|
|
|
|
|
|
2012-09-12 22:03:46 +02:00
|
|
|
class XbmcBackup:
|
2012-09-05 21:28:43 +02:00
|
|
|
#constants for initiating a back or restore
|
|
|
|
Backup = 0
|
|
|
|
Restore = 1
|
2012-11-02 21:59:40 +01:00
|
|
|
|
2014-07-30 22:16:58 +02:00
|
|
|
#file systems
|
2013-01-28 22:44:22 +01:00
|
|
|
xbmc_vfs = None
|
2012-11-04 21:39:17 +01:00
|
|
|
remote_vfs = None
|
2014-07-30 22:16:58 +02:00
|
|
|
saved_remote_vfs = None
|
|
|
|
|
2012-09-12 22:03:46 +02:00
|
|
|
restoreFile = None
|
2013-03-04 18:41:07 +01:00
|
|
|
remote_base_path = None
|
2012-09-12 22:03:46 +02:00
|
|
|
|
|
|
|
#for the progress bar
|
|
|
|
progressBar = None
|
|
|
|
filesLeft = 0
|
|
|
|
filesTotal = 1
|
|
|
|
|
|
|
|
fileManager = None
|
2012-11-28 17:19:03 +01:00
|
|
|
restore_point = None
|
2013-05-09 21:24:10 +02:00
|
|
|
skip_advanced = False #if we should check for the existance of advancedsettings in the restore
|
|
|
|
|
2012-09-05 21:28:43 +02:00
|
|
|
def __init__(self):
|
2014-10-05 21:20:23 +02:00
|
|
|
self.xbmc_vfs = XBMCFileSystem(xbmc.translatePath('special://home'))
|
2012-11-02 21:59:40 +01:00
|
|
|
|
2013-01-28 22:44:22 +01:00
|
|
|
self.configureRemote()
|
2012-11-02 21:59:40 +01:00
|
|
|
utils.log(utils.getString(30046))
|
|
|
|
|
2013-01-28 22:44:22 +01:00
|
|
|
def configureRemote(self):
|
2012-11-02 21:59:40 +01:00
|
|
|
if(utils.getSetting('remote_selection') == '1'):
|
2013-03-04 18:41:07 +01:00
|
|
|
self.remote_base_path = utils.getSetting('remote_path_2');
|
2013-01-28 22:44:22 +01:00
|
|
|
self.remote_vfs = XBMCFileSystem(utils.getSetting('remote_path_2'))
|
2014-08-01 21:14:40 +02:00
|
|
|
utils.setSetting("remote_path","")
|
2012-09-05 21:28:43 +02:00
|
|
|
elif(utils.getSetting('remote_selection') == '0'):
|
2013-03-04 18:41:07 +01:00
|
|
|
self.remote_base_path = utils.getSetting('remote_path');
|
2013-01-28 22:44:22 +01:00
|
|
|
self.remote_vfs = XBMCFileSystem(utils.getSetting("remote_path"))
|
2012-11-02 21:59:40 +01:00
|
|
|
elif(utils.getSetting('remote_selection') == '2'):
|
2013-03-04 18:41:07 +01:00
|
|
|
self.remote_base_path = "/"
|
2013-01-28 22:44:22 +01:00
|
|
|
self.remote_vfs = DropboxFileSystem("/")
|
2012-09-05 21:28:43 +02:00
|
|
|
|
2013-12-05 21:26:35 +01:00
|
|
|
def remoteConfigured(self):
|
|
|
|
result = True
|
|
|
|
|
|
|
|
if(self.remote_base_path == ""):
|
|
|
|
result = False
|
|
|
|
|
|
|
|
return result
|
|
|
|
|
2012-11-28 17:19:03 +01:00
|
|
|
def listBackups(self):
|
2013-03-04 18:41:07 +01:00
|
|
|
result = []
|
2012-11-28 17:19:03 +01:00
|
|
|
|
|
|
|
#get all the folders in the current root path
|
2013-03-04 18:41:07 +01:00
|
|
|
dirs,files = self.remote_vfs.listdir(self.remote_base_path)
|
2014-08-01 20:54:22 +02:00
|
|
|
|
2012-11-28 17:19:03 +01:00
|
|
|
for aDir in dirs:
|
2013-03-04 18:41:07 +01:00
|
|
|
if(self.remote_vfs.exists(self.remote_base_path + aDir + "/xbmcbackup.val")):
|
2012-11-28 17:19:03 +01:00
|
|
|
|
2014-02-09 20:56:25 +01:00
|
|
|
#folder may or may not contain time, older versions didn't include this
|
|
|
|
folderName = ''
|
|
|
|
if(len(aDir) > 8):
|
|
|
|
folderName = aDir[6:8] + '-' + aDir[4:6] + '-' + aDir[0:4] + " " + aDir[8:10] + ":" + aDir[10:12]
|
|
|
|
else:
|
|
|
|
folderName = aDir[6:8] + '-' + aDir[4:6] + '-' + aDir[0:4]
|
|
|
|
|
|
|
|
result.append((aDir,folderName))
|
|
|
|
|
2014-07-31 23:02:53 +02:00
|
|
|
for aFile in files:
|
|
|
|
file_ext = aFile.split('.')[-1]
|
2014-11-10 19:40:29 +01:00
|
|
|
folderName = utils.encode(aFile.split('.')[0])
|
2014-08-01 21:32:29 +02:00
|
|
|
|
|
|
|
if(file_ext == 'zip' and (len(folderName) == 12 or len(folderName) == 8) and str.isdigit(folderName)):
|
2014-07-31 23:02:53 +02:00
|
|
|
|
|
|
|
#folder may or may not contain time, older versions didn't include this
|
|
|
|
if(len(aFile ) > 8):
|
|
|
|
folderName = aFile [6:8] + '-' + aFile [4:6] + '-' + aFile [0:4] + " " + aFile [8:10] + ":" + aFile [10:12]
|
|
|
|
else:
|
|
|
|
folderName = aFile [6:8] + '-' + aFile [4:6] + '-' + aFile [0:4]
|
|
|
|
|
|
|
|
result.append((aFile ,folderName))
|
|
|
|
|
|
|
|
|
2014-02-09 20:56:25 +01:00
|
|
|
result.sort(key=folderSort)
|
|
|
|
|
2012-11-28 17:19:03 +01:00
|
|
|
return result
|
|
|
|
|
|
|
|
def selectRestore(self,restore_point):
|
|
|
|
self.restore_point = restore_point
|
|
|
|
|
2013-05-09 21:24:10 +02:00
|
|
|
def skipAdvanced(self):
|
|
|
|
self.skip_advanced = True
|
|
|
|
|
2014-01-20 19:42:49 +01:00
|
|
|
def run(self,mode=-1,progressOverride=False):
|
2014-03-18 19:48:53 +01:00
|
|
|
#set windows setting to true
|
|
|
|
window = xbmcgui.Window(10000)
|
|
|
|
window.setProperty(utils.__addon_id__ + ".running","true")
|
|
|
|
|
2012-09-05 21:28:43 +02:00
|
|
|
#append backup folder name
|
2012-11-28 16:37:37 +01:00
|
|
|
progressBarTitle = utils.getString(30010) + " - "
|
2012-11-04 21:39:17 +01:00
|
|
|
if(mode == self.Backup and self.remote_vfs.root_path != ''):
|
2014-07-30 22:16:58 +02:00
|
|
|
if(utils.getSetting("compress_backups") == 'true'):
|
2014-08-05 02:58:56 +02:00
|
|
|
#delete old temp file
|
|
|
|
if(self.xbmc_vfs.exists(xbmc.translatePath('special://temp/xbmc_backup_temp.zip'))):
|
|
|
|
self.xbmc_vfs.rmfile(xbmc.translatePath('special://temp/xbmc_backup_temp.zip'))
|
|
|
|
|
2014-07-30 22:16:58 +02:00
|
|
|
#save the remote file system and use the zip vfs
|
|
|
|
self.saved_remote_vfs = self.remote_vfs
|
2014-08-01 20:05:58 +02:00
|
|
|
self.remote_vfs = ZipFileSystem(xbmc.translatePath("special://temp/xbmc_backup_temp.zip"),"w")
|
2014-07-30 22:16:58 +02:00
|
|
|
|
2014-02-09 20:56:25 +01:00
|
|
|
self.remote_vfs.set_root(self.remote_vfs.root_path + time.strftime("%Y%m%d%H%M") + "/")
|
2014-11-21 20:25:19 +01:00
|
|
|
progressBarTitle = progressBarTitle + utils.getString(30023) + ": " + utils.getString(30016)
|
2014-07-30 22:16:58 +02:00
|
|
|
elif(mode == self.Restore and self.restore_point != None and self.remote_vfs.root_path != ''):
|
2014-07-31 23:02:53 +02:00
|
|
|
if(self.restore_point.split('.')[-1] != 'zip'):
|
|
|
|
self.remote_vfs.set_root(self.remote_vfs.root_path + self.restore_point + "/")
|
2014-11-21 20:25:19 +01:00
|
|
|
progressBarTitle = progressBarTitle + utils.getString(30023) + ": " + utils.getString(30017)
|
2014-07-30 22:16:58 +02:00
|
|
|
else:
|
2012-11-28 17:19:03 +01:00
|
|
|
#kill the program here
|
2014-07-30 22:16:58 +02:00
|
|
|
self.remote_vfs = None
|
|
|
|
return
|
2012-09-12 22:03:46 +02:00
|
|
|
|
2013-01-28 22:44:22 +01:00
|
|
|
utils.log(utils.getString(30047) + ": " + self.xbmc_vfs.root_path)
|
2012-11-04 21:39:17 +01:00
|
|
|
utils.log(utils.getString(30048) + ": " + self.remote_vfs.root_path)
|
2012-11-02 21:59:40 +01:00
|
|
|
|
2014-03-31 20:16:11 +02:00
|
|
|
|
|
|
|
#setup the progress bar
|
|
|
|
self.progressBar = BackupProgressBar(progressOverride)
|
|
|
|
self.progressBar.create(progressBarTitle,utils.getString(30049) + "......")
|
2012-11-28 16:37:37 +01:00
|
|
|
|
2012-09-05 21:28:43 +02:00
|
|
|
if(mode == self.Backup):
|
|
|
|
utils.log(utils.getString(30023) + " - " + utils.getString(30016))
|
2013-01-29 17:34:48 +01:00
|
|
|
#check if remote path exists
|
2012-11-04 21:39:17 +01:00
|
|
|
if(self.remote_vfs.exists(self.remote_vfs.root_path)):
|
2013-01-29 17:34:48 +01:00
|
|
|
#may be data in here already
|
2012-09-05 21:28:43 +02:00
|
|
|
utils.log(utils.getString(30050))
|
2012-09-12 22:03:46 +02:00
|
|
|
else:
|
2013-01-28 22:44:22 +01:00
|
|
|
#make the remote directory
|
|
|
|
self.remote_vfs.mkdir(self.remote_vfs.root_path)
|
|
|
|
|
2013-03-04 18:41:07 +01:00
|
|
|
#create a validation file for backup rotation
|
2014-10-31 15:50:37 +01:00
|
|
|
writeCheck = self._createValidationFile()
|
|
|
|
|
|
|
|
if(not writeCheck):
|
|
|
|
#we may not be able to write to this destination for some reason
|
|
|
|
shouldContinue = xbmcgui.Dialog().yesno(utils.getString(30089),utils.getString(30090), utils.getString(30044),autoclose=25000)
|
|
|
|
|
|
|
|
if(not shouldContinue):
|
|
|
|
return
|
2013-03-04 18:41:07 +01:00
|
|
|
|
2013-01-28 22:44:22 +01:00
|
|
|
utils.log(utils.getString(30051))
|
2013-01-29 17:34:48 +01:00
|
|
|
allFiles = []
|
2013-01-28 22:44:22 +01:00
|
|
|
fileManager = FileManager(self.xbmc_vfs)
|
|
|
|
|
|
|
|
#go through each of the user selected items and write them to the backup store
|
|
|
|
if(utils.getSetting('backup_addons') == 'true'):
|
2014-10-06 22:55:57 +02:00
|
|
|
fileManager.addFile("-" + xbmc.translatePath('special://home/addons'))
|
2013-01-28 22:44:22 +01:00
|
|
|
fileManager.walkTree(xbmc.translatePath('special://home/addons'))
|
|
|
|
|
2014-10-07 18:21:47 +02:00
|
|
|
fileManager.addFile("-" + xbmc.translatePath('special://home/userdata'))
|
2013-01-28 22:44:22 +01:00
|
|
|
|
|
|
|
if(utils.getSetting('backup_addon_data') == 'true'):
|
2014-10-06 22:55:57 +02:00
|
|
|
fileManager.addFile("-" + xbmc.translatePath('special://home/userdata/addon_data'))
|
2013-01-28 22:44:22 +01:00
|
|
|
fileManager.walkTree(xbmc.translatePath('special://home/userdata/addon_data'))
|
|
|
|
|
|
|
|
if(utils.getSetting('backup_database') == 'true'):
|
2014-10-06 22:55:57 +02:00
|
|
|
fileManager.addFile("-" + xbmc.translatePath('special://home/userdata/Database'))
|
2013-01-28 22:44:22 +01:00
|
|
|
fileManager.walkTree(xbmc.translatePath('special://home/userdata/Database'))
|
2012-09-12 22:03:46 +02:00
|
|
|
|
2013-01-28 22:44:22 +01:00
|
|
|
if(utils.getSetting("backup_playlists") == 'true'):
|
2014-10-06 22:55:57 +02:00
|
|
|
fileManager.addFile("-" + xbmc.translatePath('special://home/userdata/playlists'))
|
2013-01-28 22:44:22 +01:00
|
|
|
fileManager.walkTree(xbmc.translatePath('special://home/userdata/playlists'))
|
2013-10-21 15:59:04 +02:00
|
|
|
|
|
|
|
if(utils.getSetting('backup_profiles') == 'true'):
|
2014-10-06 22:55:57 +02:00
|
|
|
fileManager.addFile("-" + xbmc.translatePath('special://home/userdata/profiles'))
|
2013-10-21 15:59:04 +02:00
|
|
|
fileManager.walkTree(xbmc.translatePath('special://home/userdata/profiles'))
|
|
|
|
|
2013-01-28 22:44:22 +01:00
|
|
|
if(utils.getSetting("backup_thumbnails") == "true"):
|
2014-10-06 22:55:57 +02:00
|
|
|
fileManager.addFile("-" + xbmc.translatePath('special://home/userdata/Thumbnails'))
|
2013-01-28 22:44:22 +01:00
|
|
|
fileManager.walkTree(xbmc.translatePath('special://home/userdata/Thumbnails'))
|
2014-08-01 21:15:27 +02:00
|
|
|
|
2013-01-28 22:44:22 +01:00
|
|
|
if(utils.getSetting("backup_config") == "true"):
|
2014-10-06 22:55:57 +02:00
|
|
|
fileManager.addFile("-" + xbmc.translatePath('special://home/userdata/keymaps'))
|
2013-01-28 22:44:22 +01:00
|
|
|
fileManager.walkTree(xbmc.translatePath('special://home/userdata/keymaps'))
|
|
|
|
|
2014-10-06 22:55:57 +02:00
|
|
|
fileManager.addFile("-" + xbmc.translatePath('special://home/userdata/peripheral_data'))
|
2013-01-28 22:44:22 +01:00
|
|
|
fileManager.walkTree(xbmc.translatePath('special://home/userdata/peripheral_data'))
|
|
|
|
|
2014-10-23 16:41:10 +02:00
|
|
|
fileManager.addFile('-' + xbmc.translatePath('special://home/userdata/library'))
|
|
|
|
fileManager.walkTree(xbmc.translatePath('special://home/userdata/library'))
|
|
|
|
|
2013-01-28 22:44:22 +01:00
|
|
|
#this part is an oddity
|
|
|
|
dirs,configFiles = self.xbmc_vfs.listdir(xbmc.translatePath('special://home/userdata/'))
|
|
|
|
for aFile in configFiles:
|
|
|
|
if(aFile.endswith(".xml")):
|
|
|
|
fileManager.addFile(xbmc.translatePath('special://home/userdata/') + aFile)
|
|
|
|
|
2013-01-29 17:34:48 +01:00
|
|
|
#add to array
|
|
|
|
self.filesTotal = fileManager.size()
|
|
|
|
allFiles.append({"source":self.xbmc_vfs.root_path,"dest":self.remote_vfs.root_path,"files":fileManager.getFiles()})
|
2013-01-28 22:44:22 +01:00
|
|
|
|
2014-08-01 20:54:22 +02:00
|
|
|
orig_base_path = self.remote_vfs.root_path
|
|
|
|
|
2013-01-28 22:44:22 +01:00
|
|
|
#check if there are custom directories
|
2013-03-04 18:03:25 +01:00
|
|
|
if(utils.getSetting('custom_dir_1_enable') == 'true' and utils.getSetting('backup_custom_dir_1') != ''):
|
2013-01-28 22:44:22 +01:00
|
|
|
|
|
|
|
#create a special remote path with hash
|
2013-03-04 18:03:25 +01:00
|
|
|
self.xbmc_vfs.set_root(utils.getSetting('backup_custom_dir_1'))
|
2014-07-30 20:41:54 +02:00
|
|
|
fileManager.addFile("-custom_" + self._createCRC(self.xbmc_vfs.root_path))
|
2013-01-28 22:44:22 +01:00
|
|
|
|
2013-03-04 18:03:25 +01:00
|
|
|
#walk the directory
|
2013-01-28 22:44:22 +01:00
|
|
|
fileManager.walkTree(self.xbmc_vfs.root_path)
|
2013-01-29 17:34:48 +01:00
|
|
|
self.filesTotal = self.filesTotal + fileManager.size()
|
2013-03-04 18:03:25 +01:00
|
|
|
allFiles.append({"source":self.xbmc_vfs.root_path,"dest":self.remote_vfs.root_path + "custom_" + self._createCRC(self.xbmc_vfs.root_path),"files":fileManager.getFiles()})
|
|
|
|
|
|
|
|
if(utils.getSetting('custom_dir_2_enable') == 'true' and utils.getSetting('backup_custom_dir_2') != ''):
|
|
|
|
|
|
|
|
#create a special remote path with hash
|
|
|
|
self.xbmc_vfs.set_root(utils.getSetting('backup_custom_dir_2'))
|
2014-07-30 20:41:54 +02:00
|
|
|
fileManager.addFile("-custom_" + self._createCRC(self.xbmc_vfs.root_path))
|
2013-03-04 18:03:25 +01:00
|
|
|
|
|
|
|
#walk the directory
|
|
|
|
fileManager.walkTree(self.xbmc_vfs.root_path)
|
|
|
|
self.filesTotal = self.filesTotal + fileManager.size()
|
|
|
|
allFiles.append({"source":self.xbmc_vfs.root_path,"dest":self.remote_vfs.root_path + "custom_" + self._createCRC(self.xbmc_vfs.root_path),"files":fileManager.getFiles()})
|
|
|
|
|
2013-01-29 17:34:48 +01:00
|
|
|
|
|
|
|
#backup all the files
|
|
|
|
self.filesLeft = self.filesTotal
|
|
|
|
for fileGroup in allFiles:
|
|
|
|
self.xbmc_vfs.set_root(fileGroup['source'])
|
|
|
|
self.remote_vfs.set_root(fileGroup['dest'])
|
2014-10-31 15:56:02 +01:00
|
|
|
filesCopied = self.backupFiles(fileGroup['files'],self.xbmc_vfs,self.remote_vfs)
|
|
|
|
|
|
|
|
if(not filesCopied):
|
|
|
|
utils.showNotification(utils.getString(30092))
|
|
|
|
utils.log(utils.getString(30092))
|
2014-08-01 20:54:22 +02:00
|
|
|
|
|
|
|
#reset remote and xbmc vfs
|
2014-08-08 17:37:16 +02:00
|
|
|
self.xbmc_vfs.set_root("special://home/")
|
2014-08-01 20:54:22 +02:00
|
|
|
self.remote_vfs.set_root(orig_base_path)
|
2013-01-29 17:34:48 +01:00
|
|
|
|
2014-07-30 22:16:58 +02:00
|
|
|
if(utils.getSetting("compress_backups") == 'true'):
|
|
|
|
#send the zip file to the real remote vfs
|
2014-07-31 22:20:22 +02:00
|
|
|
zip_name = self.remote_vfs.root_path[:-1] + ".zip"
|
2014-07-30 22:16:58 +02:00
|
|
|
self.remote_vfs.cleanup()
|
2014-08-01 20:05:58 +02:00
|
|
|
self.xbmc_vfs.rename(xbmc.translatePath("special://temp/xbmc_backup_temp.zip"), xbmc.translatePath("special://temp/" + zip_name))
|
|
|
|
fileManager.addFile(xbmc.translatePath("special://temp/" + zip_name))
|
2014-07-30 22:16:58 +02:00
|
|
|
|
|
|
|
#set root to data dir home
|
2014-08-01 20:05:58 +02:00
|
|
|
self.xbmc_vfs.set_root(xbmc.translatePath("special://temp/"))
|
2014-07-30 22:16:58 +02:00
|
|
|
|
|
|
|
self.remote_vfs = self.saved_remote_vfs
|
2014-08-01 21:36:10 +02:00
|
|
|
self.progressBar.updateProgress(98, utils.getString(30088))
|
2014-10-31 15:50:37 +01:00
|
|
|
fileCopied = self.backupFiles(fileManager.getFiles(),self.xbmc_vfs, self.remote_vfs)
|
2014-07-31 22:20:22 +02:00
|
|
|
|
2014-10-31 15:50:37 +01:00
|
|
|
if(not fileCopied):
|
|
|
|
#zip archive copy filed, inform the user
|
|
|
|
shouldContinue = xbmcgui.Dialog().ok(utils.getString(30089),utils.getString(30090), utils.getString(30091))
|
|
|
|
|
2014-07-31 22:20:22 +02:00
|
|
|
#delete the temp zip file
|
2014-08-01 20:14:47 +02:00
|
|
|
self.xbmc_vfs.rmfile(xbmc.translatePath("special://temp/" + zip_name))
|
2014-07-30 22:16:58 +02:00
|
|
|
|
2013-01-29 17:34:48 +01:00
|
|
|
#remove old backups
|
2013-03-04 18:41:07 +01:00
|
|
|
self._rotateBackups()
|
2012-09-12 22:03:46 +02:00
|
|
|
|
2013-01-29 18:00:16 +01:00
|
|
|
elif (mode == self.Restore):
|
|
|
|
utils.log(utils.getString(30023) + " - " + utils.getString(30017))
|
|
|
|
|
2014-07-31 23:02:53 +02:00
|
|
|
#catch for if the restore point is actually a zip file
|
|
|
|
if(self.restore_point.split('.')[-1] == 'zip'):
|
2014-08-01 21:36:10 +02:00
|
|
|
self.progressBar.updateProgress(2, utils.getString(30088))
|
2014-08-01 19:37:57 +02:00
|
|
|
utils.log("copying zip file: " + self.restore_point)
|
|
|
|
|
2014-08-01 00:29:59 +02:00
|
|
|
#set root to data dir home
|
2014-08-01 20:05:58 +02:00
|
|
|
self.xbmc_vfs.set_root(xbmc.translatePath("special://temp/"))
|
2014-08-01 19:37:57 +02:00
|
|
|
|
2014-08-01 20:05:58 +02:00
|
|
|
if(not self.xbmc_vfs.exists(xbmc.translatePath("special://temp/" + self.restore_point))):
|
2014-08-01 19:37:57 +02:00
|
|
|
#copy just this file from the remote vfs
|
|
|
|
zipFile = []
|
|
|
|
zipFile.append(self.remote_base_path + self.restore_point)
|
2014-08-01 00:29:59 +02:00
|
|
|
|
2014-08-01 19:37:57 +02:00
|
|
|
self.backupFiles(zipFile,self.remote_vfs, self.xbmc_vfs)
|
|
|
|
else:
|
|
|
|
utils.log("zip file exists already")
|
2014-08-01 20:54:22 +02:00
|
|
|
|
2014-08-01 19:57:55 +02:00
|
|
|
#extract the zip file
|
2014-08-01 20:05:58 +02:00
|
|
|
zip_vfs = ZipFileSystem(xbmc.translatePath("special://temp/"+ self.restore_point),'r')
|
|
|
|
zip_vfs.extract(xbmc.translatePath("special://temp/"))
|
2014-08-01 21:03:03 +02:00
|
|
|
zip_vfs.cleanup()
|
|
|
|
|
2014-08-01 20:54:22 +02:00
|
|
|
#set the new remote vfs and fix xbmc path
|
2014-08-01 20:05:58 +02:00
|
|
|
self.remote_vfs = XBMCFileSystem(xbmc.translatePath("special://temp/" + self.restore_point.split(".")[0] + "/"))
|
2014-10-06 22:55:57 +02:00
|
|
|
self.xbmc_vfs.set_root(xbmc.translatePath("special://home/"))
|
2014-08-01 19:37:57 +02:00
|
|
|
|
2014-08-01 19:57:55 +02:00
|
|
|
|
|
|
|
#for restores remote path must exist
|
|
|
|
if(not self.remote_vfs.exists(self.remote_vfs.root_path)):
|
|
|
|
xbmcgui.Dialog().ok(utils.getString(30010),utils.getString(30045),self.remote_vfs.root_path)
|
|
|
|
return
|
2013-01-29 18:00:16 +01:00
|
|
|
|
2014-05-06 20:44:00 +02:00
|
|
|
if(not self._checkValidationFile(self.remote_vfs.root_path)):
|
|
|
|
#don't continue
|
|
|
|
return
|
|
|
|
|
2013-01-29 18:00:16 +01:00
|
|
|
utils.log(utils.getString(30051))
|
|
|
|
allFiles = []
|
|
|
|
fileManager = FileManager(self.remote_vfs)
|
|
|
|
|
|
|
|
#go through each of the user selected items and write them to the backup store
|
2013-05-09 21:24:10 +02:00
|
|
|
|
|
|
|
if(utils.getSetting("backup_config") == "true"):
|
|
|
|
#check for the existance of an advancedsettings file
|
|
|
|
if(self.remote_vfs.exists(self.remote_vfs.root_path + "userdata/advancedsettings.xml") and not self.skip_advanced):
|
|
|
|
#let the user know there is an advanced settings file present
|
2013-05-09 21:35:31 +02:00
|
|
|
restartXbmc = xbmcgui.Dialog().yesno(utils.getString(30038),utils.getString(30039),utils.getString(30040), utils.getString(30041))
|
2013-05-09 21:24:10 +02:00
|
|
|
|
|
|
|
if(restartXbmc):
|
|
|
|
#add only this file to the file list
|
|
|
|
fileManager.addFile(self.remote_vfs.root_path + "userdata/advancedsettings.xml")
|
|
|
|
self.backupFiles(fileManager.getFiles(),self.remote_vfs,self.xbmc_vfs)
|
|
|
|
|
|
|
|
#let the service know to resume this backup on startup
|
|
|
|
self._createResumeBackupFile()
|
|
|
|
|
|
|
|
#do not continue running
|
2013-05-09 21:35:31 +02:00
|
|
|
xbmcgui.Dialog().ok(utils.getString(30077),utils.getString(30078))
|
2013-05-09 21:24:10 +02:00
|
|
|
|
|
|
|
return
|
|
|
|
|
2014-10-08 20:01:44 +02:00
|
|
|
fileManager.addFile('-' + self.remote_vfs.root_path + 'userdata/keymaps')
|
2013-05-09 21:24:10 +02:00
|
|
|
fileManager.walkTree(self.remote_vfs.root_path + "userdata/keymaps")
|
|
|
|
|
2014-10-06 22:55:57 +02:00
|
|
|
fileManager.addFile('-' + self.remote_vfs.root_path + "userdata/peripheral_data")
|
2013-05-09 21:24:10 +02:00
|
|
|
fileManager.walkTree(self.remote_vfs.root_path + "userdata/peripheral_data")
|
|
|
|
|
2014-10-23 16:41:10 +02:00
|
|
|
fileManager.addFile('-' + self.remote_vfs.root_path + "userdata/library")
|
|
|
|
fileManager.walkTree(self.remote_vfs.root_path + "userdata/library")
|
|
|
|
|
2013-05-09 21:24:10 +02:00
|
|
|
#this part is an oddity
|
|
|
|
dirs,configFiles = self.remote_vfs.listdir(self.remote_vfs.root_path + "userdata/")
|
|
|
|
for aFile in configFiles:
|
|
|
|
if(aFile.endswith(".xml")):
|
|
|
|
fileManager.addFile(self.remote_vfs.root_path + "userdata/" + aFile)
|
|
|
|
|
2013-01-29 18:00:16 +01:00
|
|
|
if(utils.getSetting('backup_addons') == 'true'):
|
2014-10-06 22:55:57 +02:00
|
|
|
fileManager.addFile('-' + self.remote_vfs.root_path + "addons")
|
2013-01-29 18:00:16 +01:00
|
|
|
fileManager.walkTree(self.remote_vfs.root_path + "addons")
|
|
|
|
|
|
|
|
self.xbmc_vfs.mkdir(xbmc.translatePath('special://home/userdata'))
|
|
|
|
|
|
|
|
if(utils.getSetting('backup_addon_data') == 'true'):
|
2014-10-06 22:55:57 +02:00
|
|
|
fileManager.addFile('-' + self.remote_vfs.root_path + "userdata/addon_data")
|
2013-01-29 18:00:16 +01:00
|
|
|
fileManager.walkTree(self.remote_vfs.root_path + "userdata/addon_data")
|
|
|
|
|
|
|
|
if(utils.getSetting('backup_database') == 'true'):
|
2014-10-06 22:55:57 +02:00
|
|
|
fileManager.addFile('-' + self.remote_vfs.root_path + "userdata/Database")
|
2013-01-29 18:00:16 +01:00
|
|
|
fileManager.walkTree(self.remote_vfs.root_path + "userdata/Database")
|
|
|
|
|
|
|
|
if(utils.getSetting("backup_playlists") == 'true'):
|
2014-10-06 22:55:57 +02:00
|
|
|
fileManager.addFile('-' + self.remote_vfs.root_path + "userdata/playlists")
|
2013-01-29 18:00:16 +01:00
|
|
|
fileManager.walkTree(self.remote_vfs.root_path + "userdata/playlists")
|
2013-10-21 15:59:04 +02:00
|
|
|
|
|
|
|
if(utils.getSetting('backup_profiles') == 'true'):
|
2014-10-06 22:55:57 +02:00
|
|
|
fileManager.addFile('-' + self.remote_vfs.root_path + "userdata/profiles")
|
2013-10-21 15:59:04 +02:00
|
|
|
fileManager.walkTree(self.remote_vfs.root_path + "userdata/profiles")
|
2013-01-29 18:00:16 +01:00
|
|
|
|
|
|
|
if(utils.getSetting("backup_thumbnails") == "true"):
|
2014-10-06 22:55:57 +02:00
|
|
|
fileManager.addFile('-' + self.remote_vfs.root_path + "userdata/Thumbnails")
|
2013-01-29 18:00:16 +01:00
|
|
|
fileManager.walkTree(self.remote_vfs.root_path + "userdata/Thumbnails")
|
2014-08-01 21:14:40 +02:00
|
|
|
|
2013-01-29 18:00:16 +01:00
|
|
|
#add to array
|
|
|
|
self.filesTotal = fileManager.size()
|
|
|
|
allFiles.append({"source":self.remote_vfs.root_path,"dest":self.xbmc_vfs.root_path,"files":fileManager.getFiles()})
|
|
|
|
|
|
|
|
#check if there are custom directories
|
2013-03-04 18:03:25 +01:00
|
|
|
if(utils.getSetting('custom_dir_1_enable') == 'true' and utils.getSetting('backup_custom_dir_1') != ''):
|
2013-01-29 18:00:16 +01:00
|
|
|
|
2013-03-04 18:03:25 +01:00
|
|
|
self.xbmc_vfs.set_root(utils.getSetting('backup_custom_dir_1'))
|
|
|
|
if(self.remote_vfs.exists(self.remote_vfs.root_path + "custom_" + self._createCRC(self.xbmc_vfs.root_path))):
|
2013-01-29 18:00:16 +01:00
|
|
|
#index files to restore
|
2013-03-04 18:03:25 +01:00
|
|
|
fileManager.walkTree(self.remote_vfs.root_path + "custom_" + self._createCRC(self.xbmc_vfs.root_path))
|
|
|
|
self.filesTotal = self.filesTotal + fileManager.size()
|
|
|
|
allFiles.append({"source":self.remote_vfs.root_path + "custom_" + self._createCRC(self.xbmc_vfs.root_path),"dest":self.xbmc_vfs.root_path,"files":fileManager.getFiles()})
|
|
|
|
else:
|
|
|
|
xbmcgui.Dialog().ok(utils.getString(30010),utils.getString(30045),self.remote_vfs.root_path + "custom_" + self._createCRC(utils.getSetting('backup_custom_dir_1')))
|
2013-01-29 18:00:16 +01:00
|
|
|
|
2013-03-04 18:03:25 +01:00
|
|
|
if(utils.getSetting('custom_dir_2_enable') == 'true' and utils.getSetting('backup_custom_dir_2') != ''):
|
|
|
|
|
|
|
|
self.xbmc_vfs.set_root(utils.getSetting('backup_custom_dir_2'))
|
|
|
|
if(self.remote_vfs.exists(self.remote_vfs.root_path + "custom_" + self._createCRC(self.xbmc_vfs.root_path))):
|
|
|
|
#index files to restore
|
|
|
|
fileManager.walkTree(self.remote_vfs.root_path + "custom_" + self._createCRC(self.xbmc_vfs.root_path))
|
2013-01-29 18:00:16 +01:00
|
|
|
self.filesTotal = self.filesTotal + fileManager.size()
|
2013-03-04 18:03:25 +01:00
|
|
|
allFiles.append({"source":self.remote_vfs.root_path + "custom_" + self._createCRC(self.xbmc_vfs.root_path),"dest":self.xbmc_vfs.root_path,"files":fileManager.getFiles()})
|
2013-01-29 18:00:16 +01:00
|
|
|
else:
|
2013-03-04 18:03:25 +01:00
|
|
|
xbmcgui.Dialog().ok(utils.getString(30010),utils.getString(30045),self.remote_vfs.root_path + "custom_" + self._createCRC(utils.getSetting('backup_custom_dir_2')))
|
|
|
|
|
2013-01-29 18:00:16 +01:00
|
|
|
|
|
|
|
#restore all the files
|
|
|
|
self.filesLeft = self.filesTotal
|
|
|
|
for fileGroup in allFiles:
|
|
|
|
self.remote_vfs.set_root(fileGroup['source'])
|
|
|
|
self.xbmc_vfs.set_root(fileGroup['dest'])
|
|
|
|
self.backupFiles(fileGroup['files'],self.remote_vfs,self.xbmc_vfs)
|
|
|
|
|
2014-08-01 20:05:58 +02:00
|
|
|
if(self.restore_point.split('.')[-1] == 'zip'):
|
|
|
|
#delete the zip file and the extracted directory
|
2014-08-01 20:12:43 +02:00
|
|
|
self.xbmc_vfs.rmfile(xbmc.translatePath("special://temp/" + self.restore_point))
|
2014-08-01 20:05:58 +02:00
|
|
|
self.xbmc_vfs.rmdir(self.remote_vfs.root_path)
|
|
|
|
|
2014-10-31 17:40:47 +01:00
|
|
|
if(utils.getSetting("backup_config") == "true"):
|
|
|
|
#update the guisettings information (or what we can from it)
|
|
|
|
gui_settings = GuiSettingsManager('special://home/userdata/guisettings.xml')
|
|
|
|
gui_settings.run()
|
|
|
|
|
2013-01-29 18:32:47 +01:00
|
|
|
#call update addons to refresh everything
|
|
|
|
xbmc.executebuiltin('UpdateLocalAddons')
|
|
|
|
|
2014-07-30 22:16:58 +02:00
|
|
|
self.xbmc_vfs.cleanup()
|
|
|
|
self.remote_vfs.cleanup()
|
2014-03-31 20:16:11 +02:00
|
|
|
self.progressBar.close()
|
2013-01-29 18:00:16 +01:00
|
|
|
|
2014-03-18 19:48:53 +01:00
|
|
|
#reset the window setting
|
|
|
|
window.setProperty(utils.__addon_id__ + ".running","")
|
|
|
|
|
2013-01-28 22:44:22 +01:00
|
|
|
def backupFiles(self,fileList,source,dest):
|
2014-10-31 15:50:37 +01:00
|
|
|
result = True
|
|
|
|
|
2012-11-04 21:39:17 +01:00
|
|
|
utils.log("Writing files to: " + dest.root_path)
|
2013-01-29 17:34:48 +01:00
|
|
|
utils.log("Source: " + source.root_path)
|
2012-09-12 22:03:46 +02:00
|
|
|
for aFile in fileList:
|
2014-03-31 20:16:11 +02:00
|
|
|
if(not self.progressBar.checkCancel()):
|
2013-01-28 22:44:22 +01:00
|
|
|
utils.log('Writing file: ' + aFile,xbmc.LOGDEBUG)
|
|
|
|
if(aFile.startswith("-")):
|
2014-03-31 20:16:11 +02:00
|
|
|
self._updateProgress(aFile[len(source.root_path) + 1:])
|
2013-01-28 22:44:22 +01:00
|
|
|
dest.mkdir(dest.root_path + aFile[len(source.root_path) + 1:])
|
2012-09-12 22:03:46 +02:00
|
|
|
else:
|
2014-03-31 20:16:11 +02:00
|
|
|
self._updateProgress()
|
2014-10-31 15:50:37 +01:00
|
|
|
wroteFile = True
|
2012-11-06 18:37:39 +01:00
|
|
|
if(isinstance(source,DropboxFileSystem)):
|
|
|
|
#if copying from dropbox we need the file handle, use get_file
|
2014-10-31 15:50:37 +01:00
|
|
|
wroteFile = source.get_file(aFile,dest.root_path + aFile[len(source.root_path):])
|
2012-11-06 18:37:39 +01:00
|
|
|
else:
|
|
|
|
#copy using normal method
|
2014-10-31 15:50:37 +01:00
|
|
|
wroteFile = dest.put(aFile,dest.root_path + aFile[len(source.root_path):])
|
|
|
|
|
|
|
|
#if result is still true but this file failed
|
|
|
|
if(not wroteFile and result):
|
|
|
|
result = False
|
|
|
|
|
|
|
|
|
|
|
|
return result
|
2013-01-28 22:44:22 +01:00
|
|
|
|
|
|
|
def _createCRC(self,string):
|
|
|
|
#create hash from string
|
|
|
|
string = string.lower()
|
|
|
|
bytes = bytearray(string.encode())
|
|
|
|
crc = 0xffffffff;
|
|
|
|
for b in bytes:
|
|
|
|
crc = crc ^ (b << 24)
|
|
|
|
for i in range(8):
|
|
|
|
if (crc & 0x80000000 ):
|
|
|
|
crc = (crc << 1) ^ 0x04C11DB7
|
|
|
|
else:
|
|
|
|
crc = crc << 1;
|
|
|
|
crc = crc & 0xFFFFFFFF
|
|
|
|
|
|
|
|
return '%08x' % crc
|
2012-09-12 22:03:46 +02:00
|
|
|
|
2014-03-31 20:16:11 +02:00
|
|
|
def _updateProgress(self,message=None):
|
|
|
|
self.filesLeft = self.filesLeft - 1
|
|
|
|
self.progressBar.updateProgress(int((float(self.filesTotal - self.filesLeft)/float(self.filesTotal)) * 100),message)
|
2013-01-29 17:34:48 +01:00
|
|
|
|
2013-03-04 18:41:07 +01:00
|
|
|
def _rotateBackups(self):
|
|
|
|
total_backups = int(utils.getSetting('backup_rotation'))
|
2014-11-21 20:25:19 +01:00
|
|
|
|
2013-03-04 18:41:07 +01:00
|
|
|
if(total_backups > 0):
|
|
|
|
#get a list of valid backup folders
|
|
|
|
dirs = self.listBackups()
|
2014-11-21 20:25:19 +01:00
|
|
|
|
2013-03-04 18:41:07 +01:00
|
|
|
if(len(dirs) > total_backups):
|
|
|
|
#remove backups to equal total wanted
|
2014-02-09 20:56:25 +01:00
|
|
|
remove_num = 0
|
2013-03-04 18:41:07 +01:00
|
|
|
self.filesTotal = self.filesTotal + remove_num + 1
|
|
|
|
|
|
|
|
#update the progress bar if it is available
|
2014-03-31 20:16:11 +02:00
|
|
|
while(remove_num < (len(dirs) - total_backups) and not self.progressBar.checkCancel()):
|
2014-02-09 20:56:25 +01:00
|
|
|
self._updateProgress(utils.getString(30054) + " " + dirs[remove_num][1])
|
|
|
|
utils.log("Removing backup " + dirs[remove_num][0])
|
2014-08-01 20:12:43 +02:00
|
|
|
|
|
|
|
if(dirs[remove_num][0].split('.')[-1] == 'zip'):
|
|
|
|
#this is a file, remove it that way
|
|
|
|
self.remote_vfs.rmfile(self.remote_base_path + dirs[remove_num][0])
|
|
|
|
else:
|
|
|
|
self.remote_vfs.rmdir(self.remote_base_path + dirs[remove_num][0] + "/")
|
|
|
|
|
2014-02-09 20:56:25 +01:00
|
|
|
remove_num = remove_num + 1
|
2013-03-04 18:41:07 +01:00
|
|
|
|
|
|
|
def _createValidationFile(self):
|
|
|
|
vFile = xbmcvfs.File(xbmc.translatePath(utils.data_dir() + "xbmcbackup.val"),'w')
|
2014-05-06 20:44:00 +02:00
|
|
|
vFile.write(json.dumps({"name":"XBMC Backup Validation File","xbmc_version":xbmc.getInfoLabel('System.BuildVersion')}))
|
|
|
|
vFile.write("")
|
2013-03-04 18:41:07 +01:00
|
|
|
vFile.close()
|
|
|
|
|
2014-10-31 15:50:37 +01:00
|
|
|
success = self.remote_vfs.put(xbmc.translatePath(utils.data_dir() + "xbmcbackup.val"),self.remote_vfs.root_path + "xbmcbackup.val")
|
|
|
|
|
|
|
|
return success
|
2013-03-04 18:41:07 +01:00
|
|
|
|
2014-05-06 20:44:00 +02:00
|
|
|
def _checkValidationFile(self,path):
|
|
|
|
result = False
|
|
|
|
|
|
|
|
#copy the file and open it
|
|
|
|
self.xbmc_vfs.put(path + "xbmcbackup.val",xbmc.translatePath(utils.data_dir() + "xbmcbackup.val"))
|
|
|
|
|
|
|
|
vFile = xbmcvfs.File(xbmc.translatePath(utils.data_dir() + "xbmcbackup.val"),'r')
|
|
|
|
jsonString = vFile.read()
|
|
|
|
vFile.close()
|
|
|
|
|
|
|
|
try:
|
|
|
|
json_dict = json.loads(jsonString)
|
|
|
|
|
|
|
|
if(xbmc.getInfoLabel('System.BuildVersion') == json_dict['xbmc_version']):
|
|
|
|
result = True
|
|
|
|
else:
|
|
|
|
result = xbmcgui.Dialog().yesno(utils.getString(30085),utils.getString(30086),utils.getString(30044))
|
|
|
|
|
|
|
|
except ValueError:
|
|
|
|
#may fail on older archives
|
|
|
|
result = True
|
|
|
|
|
|
|
|
return result
|
|
|
|
|
2013-05-09 21:24:10 +02:00
|
|
|
def _createResumeBackupFile(self):
|
|
|
|
rFile = xbmcvfs.File(xbmc.translatePath(utils.data_dir() + "resume.txt"),'w')
|
|
|
|
rFile.write(self.restore_point)
|
|
|
|
rFile.close()
|
|
|
|
|
2013-01-29 17:34:48 +01:00
|
|
|
class FileManager:
|
|
|
|
fileArray = []
|
|
|
|
not_dir = ['.zip','.xsp','.rar']
|
|
|
|
vfs = None
|
|
|
|
|
|
|
|
def __init__(self,vfs):
|
|
|
|
self.vfs = vfs
|
|
|
|
|
|
|
|
def walkTree(self,directory):
|
2014-01-12 17:12:09 +01:00
|
|
|
|
2014-11-21 17:44:53 +01:00
|
|
|
if(self.vfs.exists(directory + "/")):
|
2013-10-21 15:59:04 +02:00
|
|
|
dirs,files = self.vfs.listdir(directory)
|
2013-01-29 17:34:48 +01:00
|
|
|
|
2013-10-21 15:59:04 +02:00
|
|
|
#create all the subdirs first
|
|
|
|
for aDir in dirs:
|
|
|
|
dirPath = xbmc.translatePath(directory + "/" + aDir)
|
|
|
|
file_ext = aDir.split('.')[-1]
|
2014-07-31 23:02:53 +02:00
|
|
|
|
2014-08-01 20:06:35 +02:00
|
|
|
self.addFile("-" + dirPath)
|
2014-01-12 17:12:09 +01:00
|
|
|
|
2013-10-21 15:59:04 +02:00
|
|
|
#catch for "non directory" type files
|
2014-01-12 17:12:09 +01:00
|
|
|
shouldWalk = True
|
|
|
|
|
|
|
|
for s in file_ext:
|
|
|
|
if(s in self.not_dir):
|
|
|
|
shouldWalk = False
|
|
|
|
|
|
|
|
if(shouldWalk):
|
2013-10-21 15:59:04 +02:00
|
|
|
self.walkTree(dirPath)
|
2013-01-29 17:34:48 +01:00
|
|
|
|
2013-10-21 15:59:04 +02:00
|
|
|
#copy all the files
|
|
|
|
for aFile in files:
|
2014-08-01 20:06:35 +02:00
|
|
|
filePath = xbmc.translatePath(directory + "/" + aFile)
|
|
|
|
self.addFile(filePath)
|
2013-01-29 17:34:48 +01:00
|
|
|
|
|
|
|
def addFile(self,filename):
|
|
|
|
try:
|
|
|
|
filename = filename.decode('UTF-8')
|
|
|
|
except UnicodeDecodeError:
|
|
|
|
filename = filename.decode('ISO-8859-2')
|
|
|
|
|
|
|
|
#write the full remote path name of this file
|
|
|
|
utils.log("Add File: " + filename,xbmc.LOGDEBUG)
|
|
|
|
self.fileArray.append(filename)
|
|
|
|
|
|
|
|
def getFiles(self):
|
|
|
|
result = self.fileArray
|
|
|
|
self.fileArray = []
|
|
|
|
return result
|
|
|
|
|
|
|
|
def size(self):
|
|
|
|
return len(self.fileArray)
|
2014-03-31 20:16:11 +02:00
|
|
|
|
|
|
|
class BackupProgressBar:
|
|
|
|
NONE = 2
|
|
|
|
DIALOG = 0
|
|
|
|
BACKGROUND = 1
|
|
|
|
|
|
|
|
mode = 2
|
|
|
|
progressBar = None
|
|
|
|
override = False
|
|
|
|
|
|
|
|
def __init__(self,progressOverride):
|
|
|
|
self.override = progressOverride
|
|
|
|
|
|
|
|
#check if we should use the progress bar
|
|
|
|
if(int(utils.getSetting('progress_mode')) != 2):
|
|
|
|
#check if background or normal
|
|
|
|
if(int(utils.getSetting('progress_mode')) == 0 and not self.override):
|
|
|
|
self.mode = self.DIALOG
|
|
|
|
self.progressBar = xbmcgui.DialogProgress()
|
|
|
|
else:
|
|
|
|
self.mode = self.BACKGROUND
|
|
|
|
self.progressBar = xbmcgui.DialogProgressBG()
|
|
|
|
|
|
|
|
def create(self,heading,message):
|
|
|
|
if(self.mode != self.NONE):
|
|
|
|
self.progressBar.create(heading,message)
|
|
|
|
|
|
|
|
def updateProgress(self,percent,message=None):
|
|
|
|
|
|
|
|
#update the progress bar
|
|
|
|
if(self.mode != self.NONE):
|
|
|
|
if(message != None):
|
|
|
|
#need different calls for dialog and background bars
|
|
|
|
if(self.mode == self.DIALOG):
|
|
|
|
self.progressBar.update(percent,message)
|
|
|
|
else:
|
|
|
|
self.progressBar.update(percent,message=message)
|
|
|
|
else:
|
2014-08-01 21:15:27 +02:00
|
|
|
self.progressBar.update(percent)
|
2014-03-31 20:16:11 +02:00
|
|
|
|
|
|
|
def checkCancel(self):
|
|
|
|
result = False
|
|
|
|
|
|
|
|
if(self.mode == self.DIALOG):
|
|
|
|
result = self.progressBar.iscanceled()
|
|
|
|
|
|
|
|
return result
|
|
|
|
|
|
|
|
def close(self):
|
|
|
|
if(self.mode != self.NONE):
|
|
|
|
self.progressBar.close()
|