Esempio n. 1
0
    def erase(self):
        self.showOnly(self.style + ERASE)

        #Not implemented yet
        #if self.flirc.version > 1:
        #    self.getControl(self.style + ERASE_STOP + 1000).setVisible(True)

        self.freeRemote()
        self.timerOff()

        self.lockInfobox = True
        self.setInfoBox(utils.getString(self.style + ERASE_STOP))

        response = self.flirc.erase()
        self.timerOn()

        self.setInfoBox(utils.getString(response))

        self.sleep(INFOSECS)  #1 second

        self.showAll()

        self.getControl(self.style + ERASE_STOP + 1000).setVisible(False)

        self.lockInfobox = False
        self._setFocus(self.style + ERASE)
Esempio n. 2
0
    def erase(self):
        self.showOnly(self.style + ERASE)

        #Not implemented yet
        #if self.flirc.version > 1:
        #    self.getControl(self.style + ERASE_STOP + 1000).setVisible(True)

        self.freeRemote()
        self.timerOff()

        self.lockInfobox = True
        self.setInfoBox(utils.getString(self.style + ERASE_STOP))
        
        response = self.flirc.erase()
        self.timerOn()        
        
        self.setInfoBox(utils.getString(response))        

        self.sleep(INFOSECS) #1 second

        self.showAll()

        self.getControl(self.style + ERASE_STOP + 1000).setVisible(False)

        self.lockInfobox = False
        self._setFocus(self.style + ERASE)
Esempio n. 3
0
    def startRecording(self, controlId):
        #utils.log("******************* startRecording *******************")
        #utils.log(controlId)
        self.currentButton = controlId

        if self.currentButton == 0:
            return

        self.lockInfobox = True

        self.showOnly(self.currentButton)

        cmd = utils.getRecordCommandString(controlId)
        text = utils.getString(
            utils.RECORD_TEXT) % utils.getString(controlId).lower()

        self.setInfoBox(text)

        response = self.flirc.recordKey(cmd)

        self.setInfoBox(utils.getString(response))

        ret = True

        if response == utils.RECORD_OK:
            self.sleep(INFOSECS)  #1 second
        else:
            self.sleep(2 * INFOSECS)  #2 seconds
            ret = False

        #self._setFocus(controlId)

        self.lockInfobox = False

        return ret
Esempio n. 4
0
def main(argv):

    params = getParams(argv)

    if 'profile' in params:
        profilenum = params['profile']

    makemkvpath = utils.getSetting(profilenum + 'makemkvpath')
    if not makemkvpath:
        makemkvpath = utils.getSetting('defaultmakemkvpath')
    if not makemkvpath:
        # Please Set MakeMKVCon Path
        utils.exitFailed(
            '{pleaseset} {pathtomakemkvcon}'.format(
                pleaseset=utils.getString(30072),
                pathtomakemkvcon=utils.getString(30016)),
            '{pleaseset} {pathtomakemkvcon}'.format(
                pleaseset=utils.getString(30072),
                pathtomakemkvcon=utils.getString(30016)))
    command = '"{makemkvpath}" info list -r'.format(makemkvpath=makemkvpath)
    try:
        if sys.version_info[:2] == (2, 7):
            output = subprocess.check_output(command,
                                             stderr=subprocess.STDOUT,
                                             shell=True)
        elif sys.version_info[:2] == (2, 6):
            output = utils.check_output(command,
                                        stderr=subprocess.STDOUT,
                                        shell=True)
    except subprocess.CalledProcessError, e:
        output = e.output
Esempio n. 5
0
    def extract(self, zipFile, outLoc, progressBar):
        utils.log("extracting zip archive")

        result = True  #result is true unless we fail

        #update the progress bar
        progressBar.updateProgress(0, utils.getString(30100))

        #list the files
        fileCount = float(len(zipFile.listFiles()))
        currentFile = 0

        try:
            for aFile in zipFile.listFiles():
                #update the progress bar
                currentFile += 1
                progressBar.updateProgress(
                    int((currentFile / fileCount) * 100),
                    utils.getString(30100))

                #extract the file
                zipFile.extract(aFile, outLoc)

        except Exception, e:
            print str(e)
            utils.log("Error extracting file", xbmc.LOGDEBUG)
            result = False
Esempio n. 6
0
 def extract(self,zipFile,outLoc,progressBar):
     utils.log("extracting zip archive")
     
     result = True #result is true unless we fail
     
     #update the progress bar
     progressBar.updateProgress(0,utils.getString(30100))
     
     #list the files 
     fileCount = float(len(zipFile.listFiles()))
     currentFile = 0
     
     try:
         for aFile in zipFile.listFiles():
             #update the progress bar
             currentFile += 1
             progressBar.updateProgress(int((currentFile/fileCount) * 100),utils.getString(30100))
             
             #extract the file
             zipFile.extract(aFile,outLoc)
             
     except Exception,e:
         print str(e)
         utils.log("Error extracting file", xbmc.LOGDEBUG)
         result = False
Esempio n. 7
0
    def run(self):
        
        #check if there is even a file playing
        if(self.localPlayer.isPlaying()):
            #figure out what xbmc to send to
            selected_xbmc = xbmcgui.Dialog().select(utils.getString(30036),self.host_manager.listHosts())

            if(selected_xbmc != -1):
                #create a local host
                local_host = XbmcHost("Local","127.0.0.1","8080")
                
                #get the address of the host
                remote_host = self.host_manager.getHost(selected_xbmc)

                #check if the remote player is currently playing something
                remote_player = remote_host.isPlaying()

                if(remote_player >= 0 and utils.getSetting("override_destination") == 'true'):
                     #we need to stop the player before sending the new file
                     remote_host.stop()
                     self.sendTo(local_host,remote_host)
                 
                elif(remote_player >= 0 and utils.getSetting("override_destination") == "false"):
                    #we can't stop the player, notify the user
                    xbmcgui.Dialog().ok("SendTo",remote_host.name + " " + utils.getString(30039),utils.getString(30037))

                elif(remote_player == -2):
                    #catch for if the player is off
                    xbmcgui.Dialog().ok("SendTo",remote_host.name + " " + utils.getString(30040),utils.getString(30038))
                    
                else:
                    #not playing anything, send as normal
                    self.sendTo(local_host,remote_host)
Esempio n. 8
0
    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_restore.val"))

        vFile = xbmcvfs.File(xbmc.translatePath(utils.data_dir() + "xbmcbackup_restore.val"),'r')
        jsonString = vFile.read()
        vFile.close()

        #delete after checking
        xbmcvfs.delete(xbmc.translatePath(utils.data_dir() + "xbmcbackup_restore.val"))

        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
Esempio n. 9
0
    def startRecording(self, controlId):
        #utils.log("******************* startRecording *******************")
        #utils.log(controlId)
        self.currentButton = controlId

        if self.currentButton == 0:
            return

        self.lockInfobox = True

        self.showOnly(self.currentButton)       

        cmd  = utils.getRecordCommandString(controlId)
        text = utils.getString(utils.RECORD_TEXT) % utils.getString(controlId).lower()

        self.setInfoBox(text)

        response = self.flirc.recordKey(cmd)

        self.setInfoBox(utils.getString(response))

        ret = True
        
        if response == utils.RECORD_OK:
            self.sleep(INFOSECS) #1 second
        else:
            self.sleep(2*INFOSECS) #2 seconds
            ret = False

        #self._setFocus(controlId)

        self.lockInfobox = False

        return ret
Esempio n. 10
0
    def __init__(self,rootString):
        self.set_root(rootString)

        authorizer = DropboxAuthorizer()

        if(authorizer.isAuthorized()):
            self.client = authorizer.getClient()
        else:
            #tell the user to go back and run the authorizer
            xbmcgui.Dialog().ok(utils.getString(30010),utils.getString(30105))
            sys.exit()
Esempio n. 11
0
    def __init__(self, rootString):
        self.set_root(rootString)

        authorizer = DropboxAuthorizer()

        if (authorizer.isAuthorized()):
            self.client = authorizer.getClient()
        else:
            #tell the user to go back and run the authorizer
            xbmcgui.Dialog().ok(utils.getString(30010), utils.getString(30105))
            sys.exit()
Esempio n. 12
0
    def format(self):
        #utils.log("******************* format *******************")
        if not utils.yesno(1, 7, 0, 8):
            self.setInfoBox(utils.getString(4))
            return

        self.timerOff()
        self.setInfoBox(utils.getString(9))
        self.sleep(INFOSECS) #1 second   
        response = self.flirc.format()
        self.timerOn()        
        self.setInfoBox(utils.getString(response))
        self.sleep(INFOSECS) #1 second
Esempio n. 13
0
    def format(self):
        #utils.log("******************* format *******************")
        if not utils.yesno(1, 7, 0, 8):
            self.setInfoBox(utils.getString(4))
            return

        self.timerOff()
        self.setInfoBox(utils.getString(9))
        self.sleep(INFOSECS)  #1 second
        response = self.flirc.format()
        self.timerOn()
        self.setInfoBox(utils.getString(response))
        self.sleep(INFOSECS)  #1 second
Esempio n. 14
0
    def loadConfig(self):
        utils.log("******************* load *******************")

        filename = utils.fileBrowse(14, 'fcfg')
        if not filename:
            return

        self.timerOff()
        self.setInfoBox(utils.getString(15))
        self.sleep(INFOSECS)  #1 second
        response = self.flirc.loadConfig(filename)
        self.timerOn()
        self.setInfoBox(utils.getString(response))
        self.sleep(INFOSECS)  #1 second
Esempio n. 15
0
    def upgradeFW(self):
        utils.log("******************* upgrade *******************")

        filename = utils.fileBrowse(10, 'bin')
        if not filename:
            return

        self.timerOff()
        self.setInfoBox(utils.getString(11))
        self.sleep(INFOSECS)  #1 second
        response = self.flirc.upgradeFW(filename)
        self.timerOn()
        self.setInfoBox(utils.getString(response))
        self.sleep(INFOSECS)  #1 second
Esempio n. 16
0
    def loadConfig(self):
        utils.log("******************* load *******************")

        filename = utils.fileBrowse(14, 'fcfg')
        if not filename:
            return

        self.timerOff()
        self.setInfoBox(utils.getString(15))
        self.sleep(INFOSECS) #1 second   
        response = self.flirc.loadConfig(filename)
        self.timerOn()        
        self.setInfoBox(utils.getString(response))
        self.sleep(INFOSECS) #1 second
Esempio n. 17
0
    def upgradeFW(self):
        utils.log("******************* upgrade *******************")


        filename = utils.fileBrowse(10, 'bin')
        if not filename:
            return

        self.timerOff()
        self.setInfoBox(utils.getString(11))
        self.sleep(INFOSECS) #1 second   
        response = self.flirc.upgradeFW(filename)
        self.timerOn()        
        self.setInfoBox(utils.getString(response))
        self.sleep(INFOSECS) #1 second
Esempio n. 18
0
    def saveConfig(self):
        utils.log("******************* save *******************")

        folder = utils.folderBrowse(12)

        filename = 'my_flirc_config.fcfg'
        filename = os.path.join(folder, filename)

        self.timerOff()
        self.setInfoBox(utils.getString(13))
        self.sleep(INFOSECS) #1 second   
        response = self.flirc.saveConfig(filename)
        self.timerOn()        
        self.setInfoBox(utils.getString(response))
        self.sleep(INFOSECS) #1 second
Esempio n. 19
0
    def saveConfig(self):
        utils.log("******************* save *******************")

        folder = utils.folderBrowse(12)

        filename = 'my_flirc_config.fcfg'
        filename = os.path.join(folder, filename)

        self.timerOff()
        self.setInfoBox(utils.getString(13))
        self.sleep(INFOSECS)  #1 second
        response = self.flirc.saveConfig(filename)
        self.timerOn()
        self.setInfoBox(utils.getString(response))
        self.sleep(INFOSECS)  #1 second
Esempio n. 20
0
    def __init__(self,rootString):
        self.set_root(rootString)

        authorizer = GoogleDriveAuthorizer()

        if(authorizer.isAuthorized()):
            self.drive = authorizer.getClient()
        else:
            #tell the user to go back and run the authorizer
            xbmcgui.Dialog().ok(utils.getString(30010),utils.getString(30105))
            sys.exit()

        #make sure we have the folder we need
        xbmc_folder = self._getGoogleFile(self.root_path)
        if(xbmc_folder == None):
            self.mkdir(self.root_path)
Esempio n. 21
0
    def doAutoMode(self):

        self.showAll()
        failed = False

        self.autoModeOn = True

        self.timerOff()
        #self.flirc.format()

        for i in range(self.buttonMin + 10,
                       self.buttonMax + 1):  #+10 ignore 'Functional' Buttons
            if not self._onClick(i):
                failed = True
                break
        self.timerOn()

        self.autoModeOn = False
        self.getControl(self.style + GO_STOP + 1000).setVisible(False)

        self.showAll()
        self.currentButton = 0
        self.loseFocus()

        if failed:
            return

        utils.setSetting('autoStart', 'false')

        self.lockInfobox = True
        self._setFocus(self.style + GO)
        self.lockInfobox = False

        self.setInfoBox(utils.getString(utils.AUTO_OK))
        self.sleep(10 * INFOSECS)
Esempio n. 22
0
    def doAutoMode(self):        
        
        self.showAll()
        failed = False

        self.autoModeOn = True

        self.timerOff()
        #self.flirc.format()

        for i in range(self.buttonMin+10, self.buttonMax+1): #+10 ignore 'Functional' Buttons
            if not self._onClick(i):             
                failed = True
                break 
        self.timerOn()            

        self.autoModeOn = False
        self.getControl(self.style + GO_STOP + 1000).setVisible(False)

        self.showAll()
        self.currentButton = 0
        self.loseFocus()

        if failed:
            return

        utils.setSetting('autoStart', 'false')

        self.lockInfobox = True
        self._setFocus(self.style + GO)
        self.lockInfobox = False

        self.setInfoBox(utils.getString(utils.AUTO_OK))
        self.sleep(10*INFOSECS)
Esempio n. 23
0
    def __init__(self, rootString):
        self.set_root(rootString)

        authorizer = GoogleDriveAuthorizer()

        if (authorizer.isAuthorized()):
            self.drive = authorizer.getClient()
        else:
            #tell the user to go back and run the authorizer
            xbmcgui.Dialog().ok(utils.getString(30010), utils.getString(30105))
            sys.exit()

        #make sure we have the folder we need
        xbmc_folder = self._getGoogleFile(self.root_path)
        if (xbmc_folder == None):
            self.mkdir(self.root_path)
Esempio n. 24
0
    def _rotateBackups(self):
        total_backups = int(utils.getSetting('backup_rotation'))

        if (total_backups > 0):
            #get a list of valid backup folders
            dirs = self.listBackups()

            if (len(dirs) > total_backups):
                #remove backups to equal total wanted
                remove_num = 0
                self.filesTotal = self.filesTotal + remove_num + 1

                #update the progress bar if it is available
                while (remove_num < (len(dirs) - total_backups)
                       and not self.progressBar.checkCancel()):
                    self._updateProgress(
                        utils.getString(30054) + " " + dirs[remove_num][1])
                    utils.log("Removing backup " + dirs[remove_num][0])

                    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] + "/")

                    remove_num = remove_num + 1
Esempio n. 25
0
    def sendTo(self,local_host,remote_host,reverse=False):
        
        #get the player/playlist id
        playerid = str(local_host.isPlaying())
           
        #get the percentage played and position
        player_props = local_host.playingProperties(playerid)

        #check if the player is currently paused
        if(player_props['speed'] != 0):
            #pause the playing file
            self.pausePlayback(local_host)

        #if reverse these checks don't matter
        keep_playing = True
        if(not reverse):
            #check if we should prompt to keep playback paused
            if(utils.getSetting("pause_prompt") == "true"):
                keep_playing = not xbmcgui.Dialog().yesno(utils.getString(30000),utils.getString(30041))
        
        #get a list of all items in the playlist
        playlist = local_host.getPlaylist(playerid)

        #add these files to the other playlist
        remote_host.addItems(playlist,playerid)

        #play remote playlist
        remote_host.playPosition(str(player_props['position']),playerid)

        #pause the player
        self.pausePlayback(remote_host)

        #seek to the correct spot
        remote_host.seekFile(player_props['percentage'],playerid)

        if(utils.getSetting('continue_host_on_transfer') == 'false'):
            #stop the current player
            local_host.stop(playerid)
            local_host.executeJSON('Playlist.Clear','{"playlistid": ' + playerid + '}')
        else:
            #continue playing
            self.pausePlayback(local_host)
            
        if(keep_playing):
            #unpause
            self.pausePlayback(remote_host)
Esempio n. 26
0
def docSummaryEx1(document, ordered = False, language = 'portuguese'):
	if isinstance(document, str):
		documentString = getString(document)
		document = getSentences(documentString, language)
	invIndex = invertedIndex(document)
	graphDict = createGraph(document, invIndex)
	pRankDict = pageRank(graphDict)
	topSentences = getTopSentences(pRankDict, document, ordered)
	return topSentences
def trainPerceptron():
    pathTrain = './corpus_train/train_set/'
    pathTest = './corpus_train/test_set/'
    trainDocs = os.listdir(pathTrain)
    testDocs = os.listdir(pathTest)
    classifier = Perceptron()

    for i in range(0, len(os.listdir(pathTrain))):
        trainDocString = getString(pathTrain + trainDocs[i])
        testDocString = getString(pathTest + testDocs[i])

        trainSentences = getSentences(trainDocString)
        testSentences = getSentences(testDocString)

        docFeatures = getFeatures(trainDocString, trainSentences)
        docTargets = getTargets(trainSentences, testSentences)

        classifier.partial_fit(docFeatures, docTargets, classes=[0, 1])
    return classifier
Esempio n. 28
0
    def restoreFiles(self):
        self.fileManager.createFileList()

        utils.log(utils.getString(30051))
        allFiles = self.fileManager.getFileList()

        #write list from remote to local
        self.writeFiles(allFiles,self.remote_path,self.local_path)

        #call update addons to refresh everything
        xbmc.executebuiltin('UpdateLocalAddons')
Esempio n. 29
0
    def syncFiles(self):
        
        #make the remote directory
        vfs.mkdir(self.remote_path)

        utils.log(utils.getString(30051))
        self.fileManager.createFileList()

        allFiles = self.fileManager.getFileList()

        #write list from local to remote
        self.writeFiles(allFiles,self.local_path,self.remote_path)
Esempio n. 30
0
    def onFocus(self, controlId): 
        #updates text in the infobox for the current focused key 
        if self.lockInfobox:
            return
        
        if controlId > self.buttonMax:
            controlId -= 1000  

        if controlId == SWITCH:
            controlId += self.style
  
        self.setInfoBox(utils.getString(controlId))
Esempio n. 31
0
    def onFocus(self, controlId):
        #updates text in the infobox for the current focused key
        if self.lockInfobox:
            return

        if controlId > self.buttonMax:
            controlId -= 1000

        if controlId == SWITCH:
            controlId += self.style

        self.setInfoBox(utils.getString(controlId))
Esempio n. 32
0
    def setup(self):
        if (APP_KEY == '' or APP_SECRET == ''):
            xbmcgui.Dialog().ok(utils.getString(30010), utils.getString(30058),
                                utils.getString(30059))
            return

        user_token_key, user_token_secret = self.getToken()

        sess = session.DropboxSession(APP_KEY, APP_SECRET, "app_folder")

        if (user_token_key == '' and user_token_secret == ''):
            token = sess.obtain_request_token()
            url = sess.build_authorize_url(token)

            #print url in log
            utils.log("Authorize URL: " + url)
            xbmcgui.Dialog().ok(utils.getString(30010), utils.getString(30056),
                                utils.getString(30057))

            #if user authorized this will work
            user_token = sess.obtain_access_token(token)
            self.setToken(user_token.key, user_token.secret)

        else:
            sess.set_token(user_token_key, user_token_secret)

        self.client = client.DropboxClient(sess)

        try:
            utils.log(str(self.client.account_info()))
        except:
            #this didn't work, delete the token file
            self.deleteToken()
Esempio n. 33
0
    def setup(self):
        if(APP_KEY == '' or APP_SECRET == ''):
            xbmcgui.Dialog().ok(utils.getString(30010),utils.getString(30058),utils.getString(30059))
            return
        
        user_token_key,user_token_secret = self.getToken()
        
        sess = session.DropboxSession(APP_KEY,APP_SECRET,"app_folder")

        if(user_token_key == '' and user_token_secret == ''):
            token = sess.obtain_request_token()
            url = sess.build_authorize_url(token)

            #print url in log
            utils.log("Authorize URL: " + url)
            xbmcgui.Dialog().ok(utils.getString(30010),utils.getString(30056),utils.getString(30057))  
            
            #if user authorized this will work
            user_token = sess.obtain_access_token(token)
            self.setToken(user_token.key,user_token.secret)
            
        else:
            sess.set_token(user_token_key,user_token_secret)
        
        self.client = client.DropboxClient(sess)

        try:
            utils.log(str(self.client.account_info()))
        except:
            #this didn't work, delete the token file
            self.deleteToken()
Esempio n. 34
0
    def run(self,params):
        
        #check if there is even a file playing
        if(self.localPlayer.isPlaying()):
            
            selected_xbmc = -1
            if('host' in params):
                selected_xbmc = self.host_manager.getHostByName(params['host'])
            else:
                #figure out what xbmc to send to
                selected_xbmc = xbmcgui.Dialog().select(utils.getString(30036),self.host_manager.listHosts())

            if(selected_xbmc != -1):
                #create a local host
                local_host = XbmcHost("Local","127.0.0.1",8080,"","")
                
                #get the address of the host
                remote_host = self.host_manager.getHost(selected_xbmc)

                #check if the remote player is currently playing something
                remote_player = remote_host.isPlaying()

                if(remote_player >= 0 and utils.getSetting("override_destination") == 'true'):
                     #we need to stop the player before sending the new file
                     remote_host.stop()
                     self.sendTo(local_host,remote_host)
                 
                elif(remote_player >= 0 and utils.getSetting("override_destination") == "false"):
                    #we can't stop the player, notify the user
                    xbmcgui.Dialog().ok("SendTo",remote_host.name + " " + utils.getString(30039),utils.getString(30037))

                elif(remote_player == -2):
                    #catch for if the player is off
                    xbmcgui.Dialog().ok("SendTo",remote_host.name + " " + utils.getString(30040),utils.getString(30038))
                    
                else:
                    #not playing anything, send as normal
                    self.sendTo(local_host,remote_host)
Esempio n. 35
0
    def _rotateBackups(self):
        total_backups = int(utils.getSetting('backup_rotation'))
        if(total_backups > 0):
            #get a list of valid backup folders
            dirs = self.listBackups()

            if(len(dirs) > total_backups):
                #remove backups to equal total wanted
                remove_num = 0
                self.filesTotal = self.filesTotal + remove_num + 1

                #update the progress bar if it is available
                while(remove_num < (len(dirs) - total_backups) and not self.progressBar.checkCancel()):
                    self._updateProgress(utils.getString(30054) + " " + dirs[remove_num][1])
                    utils.log("Removing backup " + dirs[remove_num][0])
                    self.remote_vfs.rmdir(self.remote_base_path + dirs[remove_num][0] + "/")
                    remove_num = remove_num + 1
Esempio n. 36
0
    def __init__(self):
        self.local_path = xbmc.makeLegalFilename(xbmc.translatePath("special://home"),False);
      
	if(utils.getSetting('remote_selection') == '1'):
	    self.remote_path = utils.getSetting('remote_path_2')
	    utils.setSetting("remote_path","")
        elif(utils.getSetting('remote_selection') == '0'):
            self.remote_path = utils.getSetting("remote_path")

        #fix slashes
        self.remote_path = self.remote_path.replace("\\","/")
        
        #check if trailing slash is included
        if(self.remote_path[-1:] != "/"):
            self.remote_path = self.remote_path + "/"
        
        utils.log(utils.getString(30046))
def docSummaryEx3(document, weightsList):
    if isinstance(document, str):
        documentString = getString(document)
        document = getSentences(documentString)
    invIndex = invertedIndex(document)
    graphDict = createGraph(document, invIndex)
    documentScore = {}

    #Calculate features and update sentences scores
    priorDictSim = nodePriorSimilarity(invIndex, document, documentString)
    priorDictDegree = nodePriorDegree(invIndex, document)
    priorDictPosition = nodePriorPosition(document, documentString)
    priorDictScores = nodePriorScores(invIndex, document, documentString)

    for node in range(0, len(document)):
        documentScore[node] = priorDictSim[node] * weightsList[
            0] + priorDictDegree[node] * weightsList[1] + priorDictPosition[
                node] * weightsList[2] + priorDictScores[node] * weightsList[3]

    topSentences = getTopSentences(documentScore, document)
    return topSentences
def docSummaryEx2(document):
	if isinstance(document, str):
		documentString = getString(document)
		document = getSentences(documentString)
	invIndex = invertedIndex(document)
	graphDict = createGraph(document, invIndex)

	#Prior Functions
	priorDict = nodePriorPosition(document, documentString)
	#priorDict = nodePriorSimilarity(invIndex, document, documentString)
	#priorDict = nodePriorDegree(graphDict, document)
	#priorDict = nodePriorScores(invIndex, document, documentString)
	#priorDict = nodePriorNoun(document)

	#Weight Functions
	weightDict = edgeWeightScores(graphDict, invIndex, document, documentString)
	#weightDict = edgeWeightSimilarity(invIndex, graphDict, document)
	#weightDict = edgeWeightNoun(graphDict, document)

	pRankDict = pageRankOpt(graphDict, priorDict, weightDict)
	topSentences = getTopSentences(pRankDict, document)
	return topSentences
Esempio n. 39
0
    def doCountdown(self):        
        self.cancelCountdown = 5
        count = COUNTDOWN 
        text  = utils.getString(utils.AUTO_TEXT)
        
        self.lockInfobox = True

        #self.timerOff()
        while count > 0 and self.cancelCountdown > 0:
            self.setInfoBox(text % count)
            self.cancelCountdown = 5
            count -= 1
            xbmc.sleep(1000)
        #self.timerOn()

        self.lockInfobox = False

        #was the coundtdown canceled?
        if self.cancelCountdown < 1:
            self.loseFocus()
            return False

        return True
Esempio n. 40
0
    def doCountdown(self):
        self.cancelCountdown = 5
        count = COUNTDOWN
        text = utils.getString(utils.AUTO_TEXT)

        self.lockInfobox = True

        #self.timerOff()
        while count > 0 and self.cancelCountdown > 0:
            self.setInfoBox(text % count)
            self.cancelCountdown = 5
            count -= 1
            xbmc.sleep(1000)
        #self.timerOn()

        self.lockInfobox = False

        #was the coundtdown canceled?
        if self.cancelCountdown < 1:
            self.loseFocus()
            return False

        return True
Esempio n. 41
0
    #DRV:1,256,999,0,"","",""
    #DRV:2,256,999,0,"","",""

    lines = iter(output.splitlines())
    for line in lines:
        drive = line.split(',')
        if len(drive) >= 7:
            if drive[5] != '""':
                gooddrives = '{gooddrives} {drivenum}: {discname} '.format(
                    gooddrives=gooddrives,
                    drivenum=drive[0].split(':')[1],
                    discname=drive[5].replace('"', ''))

    if gooddrives == '':
        # 30073 == Please Put a Disc in the Drive to Identify
        utils.exitFailed(utils.getString(30073), utils.getString(30073))
    else:
        utils.showOK(gooddrives)
    return 0


def getParams(argv):
    param = {}
    if (len(argv) > 1):
        for i in argv:
            args = i
            if (args.startswith('?')):
                args = args[1:]
            param.update(dict(urlparse.parse_qsl(args)))

    return param
Esempio n. 42
0
    def run(self,mode=-1,runSilent=False):
	#check if we should use the progress bar
        if(utils.getSetting('run_silent') == 'false' and not runSilent):
            self.progressBar = xbmcgui.DialogProgress()
            self.progressBar.create(utils.getString(30010),utils.getString(30049) + "......")

        #determine backup mode
        if(mode == -1):
            mode = int(utils.getSetting('addon_mode'))

        #append backup folder name
        if(mode == self.Backup and self.remote_path != ''):
            self.remote_path = self.remote_path + time.strftime("%Y%m%d") + "/"
	elif(mode == self.Restore and utils.getSetting("backup_name") != '' and self.remote_path != ''):
	    self.remote_path = self.remote_path + utils.getSetting("backup_name") + "/"
	else:
	    self.remote_path = ""

        utils.log(utils.getString(30047) + ": " + self.local_path)
        utils.log(utils.getString(30048) + ": " + self.remote_path)

        #run the correct mode
        if(mode == self.Backup):
            utils.log(utils.getString(30023) + " - " + utils.getString(30016))
            self.fileManager = FileManager(self.local_path)

            #for backups check if remote path exists
            if(vfs.exists(self.remote_path)):
                #this will fail - need a disclaimer here
                utils.log(utils.getString(30050))

            self.syncFiles()
        else:
            utils.log(utils.getString(30023) + " - " + utils.getString(30017))
            self.fileManager = FileManager(self.remote_path)

            #for restores remote path must exist
            if(vfs.exists(self.remote_path)):
                self.restoreFiles()
            else:
                xbmcgui.Dialog().ok(utils.getString(30010),utils.getString(30045),self.remote_path)

        if(utils.getSetting('run_silent') == 'false' and not runSilent):
            self.progressBar.close()
Esempio n. 43
0
    def __init__(self):
        self.xbmc_vfs = XBMCFileSystem(xbmc.translatePath('special://home'))

        self.configureRemote()
        utils.log(utils.getString(30046))
Esempio n. 44
0
    def run(self,mode=-1,progressOverride=False):
        #set windows setting to true
        window = xbmcgui.Window(10000)
        window.setProperty(utils.__addon_id__ + ".running","true")
        
        #append backup folder name
        progressBarTitle = utils.getString(30010) + " - "
        if(mode == self.Backup and self.remote_vfs.root_path != ''):
            if(utils.getSetting("compress_backups") == 'true'):
                #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'))):
                        #we had some kind of error deleting the old file
                        xbmcgui.Dialog().ok(utils.getString(30010),utils.getString(30096),utils.getString(30097))
                        return
                    
                #save the remote file system and use the zip vfs
                self.saved_remote_vfs = self.remote_vfs
                self.remote_vfs = ZipFileSystem(xbmc.translatePath("special://temp/xbmc_backup_temp.zip"),"w")
                
            self.remote_vfs.set_root(self.remote_vfs.root_path + time.strftime("%Y%m%d%H%M") + "/")
            progressBarTitle = progressBarTitle + utils.getString(30023) + ": " + utils.getString(30016)
        elif(mode == self.Restore and self.restore_point != None and self.remote_vfs.root_path != ''):
            if(self.restore_point.split('.')[-1] != 'zip'):
                self.remote_vfs.set_root(self.remote_vfs.root_path + self.restore_point + "/")
            progressBarTitle = progressBarTitle + utils.getString(30023) + ": " + utils.getString(30017)
        else:
            #kill the program here
            self.remote_vfs = None
            return

        utils.log(utils.getString(30047) + ": " + self.xbmc_vfs.root_path)
        utils.log(utils.getString(30048) + ": " + self.remote_vfs.root_path)

        
        #setup the progress bar
        self.progressBar = BackupProgressBar(progressOverride)
        self.progressBar.create(progressBarTitle,utils.getString(30049) + "......")

        if(mode == self.Backup):
            utils.log(utils.getString(30023) + " - " + utils.getString(30016))
            #check if remote path exists
            if(self.remote_vfs.exists(self.remote_vfs.root_path)):
                #may be data in here already
                utils.log(utils.getString(30050))
            else:
                #make the remote directory
                self.remote_vfs.mkdir(self.remote_vfs.root_path)

            #create a validation file for backup rotation
            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

            utils.log(utils.getString(30051))
            allFiles = []
            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'):
                fileManager.addFile("-" + xbmc.translatePath('special://home/addons'))
                fileManager.walkTree(xbmc.translatePath('special://home/addons'))

            fileManager.addFile("-" + xbmc.translatePath('special://home/userdata'))

            if(utils.getSetting('backup_addon_data') == 'true'):
                fileManager.addFile("-" + xbmc.translatePath('special://home/userdata/addon_data'))
                fileManager.walkTree(xbmc.translatePath('special://home/userdata/addon_data'))

            if(utils.getSetting('backup_database') == 'true'):
                fileManager.addFile("-" + xbmc.translatePath('special://home/userdata/Database'))
                fileManager.walkTree(xbmc.translatePath('special://home/userdata/Database'))
        
            if(utils.getSetting("backup_playlists") == 'true'):
                fileManager.addFile("-" + xbmc.translatePath('special://home/userdata/playlists'))
                fileManager.walkTree(xbmc.translatePath('special://home/userdata/playlists'))

            if(utils.getSetting('backup_profiles') == 'true'):
                fileManager.addFile("-" + xbmc.translatePath('special://home/userdata/profiles'))
                fileManager.walkTree(xbmc.translatePath('special://home/userdata/profiles'))
            
            if(utils.getSetting("backup_thumbnails") == "true"):
                fileManager.addFile("-" + xbmc.translatePath('special://home/userdata/Thumbnails'))
                fileManager.walkTree(xbmc.translatePath('special://home/userdata/Thumbnails'))
 
            if(utils.getSetting("backup_config") == "true"):
                fileManager.addFile("-" + xbmc.translatePath('special://home/userdata/keymaps'))
                fileManager.walkTree(xbmc.translatePath('special://home/userdata/keymaps'))
                
                fileManager.addFile("-" + xbmc.translatePath('special://home/userdata/peripheral_data'))
                fileManager.walkTree(xbmc.translatePath('special://home/userdata/peripheral_data'))
            
                fileManager.addFile('-' + xbmc.translatePath('special://home/userdata/library'))
                fileManager.walkTree(xbmc.translatePath('special://home/userdata/library'))
            
                #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)

            #add to array
            self.filesTotal = fileManager.size()
            allFiles.append({"source":self.xbmc_vfs.root_path,"dest":self.remote_vfs.root_path,"files":fileManager.getFiles()})

            orig_base_path = self.remote_vfs.root_path
            
            #check if there are custom directories
            if(utils.getSetting('custom_dir_1_enable') == 'true' and utils.getSetting('backup_custom_dir_1') != ''):

                #create a special remote path with hash                
                self.xbmc_vfs.set_root(utils.getSetting('backup_custom_dir_1'))
                fileManager.addFile("-custom_" + self._createCRC(self.xbmc_vfs.root_path))

                #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()})

            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'))
                fileManager.addFile("-custom_" + self._createCRC(self.xbmc_vfs.root_path))

                #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()})


            #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'])
                filesCopied = self.backupFiles(fileGroup['files'],self.xbmc_vfs,self.remote_vfs)
                
                if(not filesCopied):
                    utils.showNotification(utils.getString(30092))
                    utils.log(utils.getString(30092))
            
            #reset remote and xbmc vfs
            self.xbmc_vfs.set_root("special://home/")
            self.remote_vfs.set_root(orig_base_path)

            if(utils.getSetting("compress_backups") == 'true'):
                #send the zip file to the real remote vfs
                zip_name = self.remote_vfs.root_path[:-1] + ".zip"
                self.remote_vfs.cleanup()
                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))
               
                #set root to data dir home 
                self.xbmc_vfs.set_root(xbmc.translatePath("special://temp/"))
               
                self.remote_vfs = self.saved_remote_vfs
                self.progressBar.updateProgress(98, utils.getString(30088))
                fileCopied = self.backupFiles(fileManager.getFiles(),self.xbmc_vfs, self.remote_vfs)
                
                if(not fileCopied):
                    #zip archive copy filed, inform the user
                    shouldContinue = xbmcgui.Dialog().ok(utils.getString(30089),utils.getString(30090), utils.getString(30091))
                    
                #delete the temp zip file
                self.xbmc_vfs.rmfile(xbmc.translatePath("special://temp/" + zip_name))

            #remove old backups
            self._rotateBackups()

        elif (mode == self.Restore):
            utils.log(utils.getString(30023) + " - " + utils.getString(30017))

            #catch for if the restore point is actually a zip file
            if(self.restore_point.split('.')[-1] == 'zip'):
                self.progressBar.updateProgress(2, utils.getString(30088))
                utils.log("copying zip file: " + self.restore_point)
                
                #set root to data dir home 
                self.xbmc_vfs.set_root(xbmc.translatePath("special://temp/"))
                
                if(not self.xbmc_vfs.exists(xbmc.translatePath("special://temp/" + self.restore_point))):
                    #copy just this file from the remote vfs
                    zipFile = []
                    zipFile.append(self.remote_base_path + self.restore_point)
               
                    self.backupFiles(zipFile,self.remote_vfs, self.xbmc_vfs)
                else:
                    utils.log("zip file exists already")
                
                #extract the zip file
                zip_vfs = ZipFileSystem(xbmc.translatePath("special://temp/"+ self.restore_point),'r')
                zip_vfs.extract(xbmc.translatePath("special://temp/"))
                zip_vfs.cleanup()
                
                #set the new remote vfs and fix xbmc path
                self.remote_vfs = XBMCFileSystem(xbmc.translatePath("special://temp/" + self.restore_point.split(".")[0] + "/"))
                self.xbmc_vfs.set_root(xbmc.translatePath("special://home/"))
                
            
            #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

            if(not self._checkValidationFile(self.remote_vfs.root_path)):
                #don't continue
                return

            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

            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
                    restartXbmc = xbmcgui.Dialog().yesno(utils.getString(30038),utils.getString(30039),utils.getString(30040), utils.getString(30041))

                    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
                        xbmcgui.Dialog().ok(utils.getString(30077),utils.getString(30078))
                        
                        return
                
                fileManager.addFile('-' + self.remote_vfs.root_path + 'userdata/keymaps')
                fileManager.walkTree(self.remote_vfs.root_path + "userdata/keymaps")
                
                fileManager.addFile('-' + self.remote_vfs.root_path + "userdata/peripheral_data")
                fileManager.walkTree(self.remote_vfs.root_path + "userdata/peripheral_data")
            
                fileManager.addFile('-' + self.remote_vfs.root_path + "userdata/library")
                fileManager.walkTree(self.remote_vfs.root_path + "userdata/library")
            
                #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)

            if(utils.getSetting('backup_addons') == 'true'):
                fileManager.addFile('-' + self.remote_vfs.root_path + "addons")
                fileManager.walkTree(self.remote_vfs.root_path + "addons")

            self.xbmc_vfs.mkdir(xbmc.translatePath('special://home/userdata'))

            if(utils.getSetting('backup_addon_data') == 'true'):
                fileManager.addFile('-' + self.remote_vfs.root_path + "userdata/addon_data")
                fileManager.walkTree(self.remote_vfs.root_path + "userdata/addon_data")

            if(utils.getSetting('backup_database') == 'true'):
                fileManager.addFile('-' + self.remote_vfs.root_path + "userdata/Database")
                fileManager.walkTree(self.remote_vfs.root_path + "userdata/Database")
        
            if(utils.getSetting("backup_playlists") == 'true'):
                fileManager.addFile('-' + self.remote_vfs.root_path + "userdata/playlists")
                fileManager.walkTree(self.remote_vfs.root_path + "userdata/playlists")

            if(utils.getSetting('backup_profiles') == 'true'):
                fileManager.addFile('-' + self.remote_vfs.root_path + "userdata/profiles")
                fileManager.walkTree(self.remote_vfs.root_path + "userdata/profiles")
                
            if(utils.getSetting("backup_thumbnails") == "true"):
                fileManager.addFile('-' + self.remote_vfs.root_path + "userdata/Thumbnails")
                fileManager.walkTree(self.remote_vfs.root_path + "userdata/Thumbnails")

            #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
            if(utils.getSetting('custom_dir_1_enable') == 'true' and utils.getSetting('backup_custom_dir_1') != ''):

                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))):
                    #index files to restore
                    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')))

            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))
                    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_2')))


            #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)

            if(self.restore_point.split('.')[-1] == 'zip'):
                #delete the zip file and the extracted directory
                self.xbmc_vfs.rmfile(xbmc.translatePath("special://temp/" + self.restore_point))
                self.xbmc_vfs.rmdir(self.remote_vfs.root_path)

            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()

            #call update addons to refresh everything
            xbmc.executebuiltin('UpdateLocalAddons')

        self.xbmc_vfs.cleanup()
        self.remote_vfs.cleanup()
        self.progressBar.close()

        #reset the window setting
        window.setProperty(utils.__addon_id__ + ".running","")
Esempio n. 45
0
    def run(self,mode=-1,progressOverride=False):
        #set windows setting to true
        window = xbmcgui.Window(10000)
        window.setProperty(utils.__addon_id__ + ".running","true")
        
        #append backup folder name
        progressBarTitle = utils.getString(30010) + " - "
        if(mode == self.Backup and self.remote_vfs.root_path != ''):
            self.remote_vfs.set_root(self.remote_vfs.root_path + time.strftime("%Y%m%d%H%M") + "/")
            progressBarTitle = progressBarTitle + utils.getString(30016)
	elif(mode == self.Restore and self.restore_point != None and self.remote_vfs.root_path != ''):
	    self.remote_vfs.set_root(self.remote_vfs.root_path + self.restore_point + "/")
	    progressBarTitle = progressBarTitle + utils.getString(30017)
	else:
            #kill the program here
	    self.remote_vfs = None
	    return

        utils.log(utils.getString(30047) + ": " + self.xbmc_vfs.root_path)
        utils.log(utils.getString(30048) + ": " + self.remote_vfs.root_path)

        
        #setup the progress bar
        self.progressBar = BackupProgressBar(progressOverride)
        self.progressBar.create(progressBarTitle,utils.getString(30049) + "......")

        if(mode == self.Backup):
            utils.log(utils.getString(30023) + " - " + utils.getString(30016))
            #check if remote path exists
            if(self.remote_vfs.exists(self.remote_vfs.root_path)):
                #may be data in here already
                utils.log(utils.getString(30050))
            else:
                #make the remote directory
                self.remote_vfs.mkdir(self.remote_vfs.root_path)

            #create a validation file for backup rotation
            self._createValidationFile()

            utils.log(utils.getString(30051))
            allFiles = []
            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'):
                self.remote_vfs.mkdir(self.remote_vfs.root_path + "addons")
                fileManager.walkTree(xbmc.translatePath('special://home/addons'))

            self.remote_vfs.mkdir(self.remote_vfs.root_path + "userdata")

            if(utils.getSetting('backup_addon_data') == 'true'):
                self.remote_vfs.mkdir(self.remote_vfs.root_path + "userdata/addon_data")
                fileManager.walkTree(xbmc.translatePath('special://home/userdata/addon_data'))

            if(utils.getSetting('backup_database') == 'true'):
                self.remote_vfs.mkdir(self.remote_vfs.root_path + "userdata/Database")
                fileManager.walkTree(xbmc.translatePath('special://home/userdata/Database'))
        
            if(utils.getSetting("backup_playlists") == 'true'):
                self.remote_vfs.mkdir(self.remote_vfs.root_path + "userdata/playlists")
                fileManager.walkTree(xbmc.translatePath('special://home/userdata/playlists'))

            if(utils.getSetting('backup_profiles') == 'true'):
                self.remote_vfs.mkdir(self.remote_vfs.root_path + "userdata/profiles")
                fileManager.walkTree(xbmc.translatePath('special://home/userdata/profiles'))
            
            if(utils.getSetting("backup_thumbnails") == "true"):
                self.remote_vfs.mkdir(self.remote_vfs.root_path + "userdata/Thumbnails")
                fileManager.walkTree(xbmc.translatePath('special://home/userdata/Thumbnails'))
	  
            if(utils.getSetting("backup_config") == "true"):
                self.remote_vfs.mkdir(self.remote_vfs.root_path + "userdata/keymaps")
                fileManager.walkTree(xbmc.translatePath('special://home/userdata/keymaps'))
                
                self.remote_vfs.mkdir(self.remote_vfs.root_path + "userdata/peripheral_data")
                fileManager.walkTree(xbmc.translatePath('special://home/userdata/peripheral_data'))
            
                #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)

            #add to array
            self.filesTotal = fileManager.size()
            allFiles.append({"source":self.xbmc_vfs.root_path,"dest":self.remote_vfs.root_path,"files":fileManager.getFiles()})

            #check if there are custom directories
            if(utils.getSetting('custom_dir_1_enable') == 'true' and utils.getSetting('backup_custom_dir_1') != ''):

                #create a special remote path with hash                
                self.xbmc_vfs.set_root(utils.getSetting('backup_custom_dir_1'))
                self.remote_vfs.mkdir(self.remote_vfs.root_path + "custom_" + self._createCRC(self.xbmc_vfs.root_path))

                #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()})

            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'))
                self.remote_vfs.mkdir(self.remote_vfs.root_path + "custom_" + self._createCRC(self.xbmc_vfs.root_path))

                #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()})


            #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'])
                self.backupFiles(fileGroup['files'],self.xbmc_vfs,self.remote_vfs)

            #remove old backups
            self._rotateBackups()

        elif (mode == self.Restore):
            utils.log(utils.getString(30023) + " - " + utils.getString(30017))

            #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

            if(not self._checkValidationFile(self.remote_vfs.root_path)):
                #don't continue
                return

            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

            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
                    restartXbmc = xbmcgui.Dialog().yesno(utils.getString(30038),utils.getString(30039),utils.getString(30040), utils.getString(30041))

                    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
                        xbmcgui.Dialog().ok(utils.getString(30077),utils.getString(30078))
                        
                        return
                
                self.xbmc_vfs.mkdir(xbmc.translatePath('special://home/userdata/keymaps'))
                fileManager.walkTree(self.remote_vfs.root_path + "userdata/keymaps")
                
                self.xbmc_vfs.mkdir(xbmc.translatePath('special://home/userdata/peripheral_data'))
                fileManager.walkTree(self.remote_vfs.root_path + "userdata/peripheral_data")
            
                #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)

            if(utils.getSetting('backup_addons') == 'true'):
                self.xbmc_vfs.mkdir(xbmc.translatePath('special://home/addons'))
                fileManager.walkTree(self.remote_vfs.root_path + "addons")

            self.xbmc_vfs.mkdir(xbmc.translatePath('special://home/userdata'))

            if(utils.getSetting('backup_addon_data') == 'true'):
                self.xbmc_vfs.mkdir(xbmc.translatePath('special://home/userdata/addon_data'))
                fileManager.walkTree(self.remote_vfs.root_path + "userdata/addon_data")

            if(utils.getSetting('backup_database') == 'true'):
                self.xbmc_vfs.mkdir(xbmc.translatePath('special://home/userdata/Database'))
                fileManager.walkTree(self.remote_vfs.root_path + "userdata/Database")
        
            if(utils.getSetting("backup_playlists") == 'true'):
                self.xbmc_vfs.mkdir(xbmc.translatePath('special://home/userdata/playlists'))
                fileManager.walkTree(self.remote_vfs.root_path + "userdata/playlists")

            if(utils.getSetting('backup_profiles') == 'true'):
                self.xbmc_vfs.mkdir(xbmc.translatePath('special://home/userdata/profiles'))
                fileManager.walkTree(self.remote_vfs.root_path + "userdata/profiles")
                
            if(utils.getSetting("backup_thumbnails") == "true"):
                self.xbmc_vfs.mkdir(xbmc.translatePath('special://home/userdata/Thumbnails'))
                fileManager.walkTree(self.remote_vfs.root_path + "userdata/Thumbnails")
	  
            #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
            if(utils.getSetting('custom_dir_1_enable') == 'true' and utils.getSetting('backup_custom_dir_1') != ''):

                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))):
                    #index files to restore
                    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')))

            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))
                    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_2')))


            #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)

            #call update addons to refresh everything
            xbmc.executebuiltin('UpdateLocalAddons')

        self.progressBar.close()

        #reset the window setting
        window.setProperty(utils.__addon_id__ + ".running","")
Esempio n. 46
0
    def __init__(self):
        self.xbmc_vfs = XBMCFileSystem(xbmc.translatePath('special://home'))

        self.configureRemote()
        utils.log(utils.getString(30046))
Esempio n. 47
0
    def run(self,mode=-1,progressOverride=False):
        #set windows setting to true
        window = xbmcgui.Window(10000)
        window.setProperty(utils.__addon_id__ + ".running","true")
        
        #append backup folder name
        progressBarTitle = utils.getString(30010) + " - "
        if(mode == self.Backup and self.remote_vfs.root_path != ''):
            if(utils.getSetting("compress_backups") == 'true'):
                #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'))):
                        #we had some kind of error deleting the old file
                        xbmcgui.Dialog().ok(utils.getString(30010),utils.getString(30096),utils.getString(30097))
                        return
                    
                #save the remote file system and use the zip vfs
                self.saved_remote_vfs = self.remote_vfs
                self.remote_vfs = ZipFileSystem(xbmc.translatePath("special://temp/xbmc_backup_temp.zip"),"w")
                
            self.remote_vfs.set_root(self.remote_vfs.root_path + time.strftime("%Y%m%d%H%M") + "/")
            progressBarTitle = progressBarTitle + utils.getString(30023) + ": " + utils.getString(30016)
        elif(mode == self.Restore and self.restore_point != None and self.remote_vfs.root_path != ''):
            if(self.restore_point.split('.')[-1] != 'zip'):
                self.remote_vfs.set_root(self.remote_vfs.root_path + self.restore_point + "/")
            progressBarTitle = progressBarTitle + utils.getString(30023) + ": " + utils.getString(30017)
        else:
            #kill the program here
            self.remote_vfs = None
            return

        utils.log(utils.getString(30047) + ": " + self.xbmc_vfs.root_path)
        utils.log(utils.getString(30048) + ": " + self.remote_vfs.root_path)

        
        #setup the progress bar
        self.progressBar = BackupProgressBar(progressOverride)
        self.progressBar.create(progressBarTitle,utils.getString(30049) + "......")

        if(mode == self.Backup):
            utils.log(utils.getString(30023) + " - " + utils.getString(30016))
            #check if remote path exists
            if(self.remote_vfs.exists(self.remote_vfs.root_path)):
                #may be data in here already
                utils.log(utils.getString(30050))
            else:
                #make the remote directory
                self.remote_vfs.mkdir(self.remote_vfs.root_path)

            #create a validation file for backup rotation
            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

            utils.log(utils.getString(30051))
            allFiles = []
            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'):
                fileManager.addFile("-" + xbmc.translatePath('special://home/addons'))
                fileManager.walkTree(xbmc.translatePath('special://home/addons'))

            fileManager.addFile("-" + xbmc.translatePath('special://home/userdata'))

            if(utils.getSetting('backup_addon_data') == 'true'):
                fileManager.addFile("-" + xbmc.translatePath('special://home/userdata/addon_data'))
                fileManager.walkTree(xbmc.translatePath('special://home/userdata/addon_data'))

            if(utils.getSetting('backup_database') == 'true'):
                fileManager.addFile("-" + xbmc.translatePath('special://home/userdata/Database'))
                fileManager.walkTree(xbmc.translatePath('special://home/userdata/Database'))
        
            if(utils.getSetting("backup_playlists") == 'true'):
                fileManager.addFile("-" + xbmc.translatePath('special://home/userdata/playlists'))
                fileManager.walkTree(xbmc.translatePath('special://home/userdata/playlists'))

            if(utils.getSetting('backup_profiles') == 'true'):
                fileManager.addFile("-" + xbmc.translatePath('special://home/userdata/profiles'))
                fileManager.walkTree(xbmc.translatePath('special://home/userdata/profiles'))
            
            if(utils.getSetting("backup_thumbnails") == "true"):
                fileManager.addFile("-" + xbmc.translatePath('special://home/userdata/Thumbnails'))
                fileManager.walkTree(xbmc.translatePath('special://home/userdata/Thumbnails'))
 
            if(utils.getSetting("backup_config") == "true"):
                fileManager.addFile("-" + xbmc.translatePath('special://home/userdata/keymaps'))
                fileManager.walkTree(xbmc.translatePath('special://home/userdata/keymaps'))
                
                fileManager.addFile("-" + xbmc.translatePath('special://home/userdata/peripheral_data'))
                fileManager.walkTree(xbmc.translatePath('special://home/userdata/peripheral_data'))
            
                fileManager.addFile('-' + xbmc.translatePath('special://home/userdata/library'))
                fileManager.walkTree(xbmc.translatePath('special://home/userdata/library'))
            
                #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)

            #add to array
            self.filesTotal = fileManager.size()
            allFiles.append({"source":self.xbmc_vfs.root_path,"dest":self.remote_vfs.root_path,"files":fileManager.getFiles()})

            orig_base_path = self.remote_vfs.root_path
            
            #check if there are custom directories
            if(utils.getSetting('custom_dir_1_enable') == 'true' and utils.getSetting('backup_custom_dir_1') != ''):

                #create a special remote path with hash                
                self.xbmc_vfs.set_root(utils.getSetting('backup_custom_dir_1'))
                fileManager.addFile("-custom_" + self._createCRC(self.xbmc_vfs.root_path))

                #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()})

            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'))
                fileManager.addFile("-custom_" + self._createCRC(self.xbmc_vfs.root_path))

                #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()})


            #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'])
                filesCopied = self.backupFiles(fileGroup['files'],self.xbmc_vfs,self.remote_vfs)
                
                if(not filesCopied):
                    utils.showNotification(utils.getString(30092))
                    utils.log(utils.getString(30092))
            
            #reset remote and xbmc vfs
            self.xbmc_vfs.set_root("special://home/")
            self.remote_vfs.set_root(orig_base_path)

            if(utils.getSetting("compress_backups") == 'true'):
                #send the zip file to the real remote vfs
                zip_name = self.remote_vfs.root_path[:-1] + ".zip"
                self.remote_vfs.cleanup()
                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))
               
                #set root to data dir home 
                self.xbmc_vfs.set_root(xbmc.translatePath("special://temp/"))
               
                self.remote_vfs = self.saved_remote_vfs
                self.progressBar.updateProgress(98, utils.getString(30088))
                fileCopied = self.backupFiles(fileManager.getFiles(),self.xbmc_vfs, self.remote_vfs)
                
                if(not fileCopied):
                    #zip archive copy filed, inform the user
                    shouldContinue = xbmcgui.Dialog().ok(utils.getString(30089),utils.getString(30090), utils.getString(30091))
                    
                #delete the temp zip file
                self.xbmc_vfs.rmfile(xbmc.translatePath("special://temp/" + zip_name))

            #remove old backups
            self._rotateBackups()

        elif (mode == self.Restore):
            utils.log(utils.getString(30023) + " - " + utils.getString(30017))

            #catch for if the restore point is actually a zip file
            if(self.restore_point.split('.')[-1] == 'zip'):
                self.progressBar.updateProgress(2, utils.getString(30088))
                utils.log("copying zip file: " + self.restore_point)
                
                #set root to data dir home 
                self.xbmc_vfs.set_root(xbmc.translatePath("special://temp/"))
                
                if(not self.xbmc_vfs.exists(xbmc.translatePath("special://temp/" + self.restore_point))):
                    #copy just this file from the remote vfs
                    zipFile = []
                    zipFile.append(self.remote_base_path + self.restore_point)
               
                    self.backupFiles(zipFile,self.remote_vfs, self.xbmc_vfs)
                else:
                    utils.log("zip file exists already")
                
                #extract the zip file
                zip_vfs = ZipFileSystem(xbmc.translatePath("special://temp/"+ self.restore_point),'r')
                extractor = ZipExtractor()
                
                if(not extractor.extract(zip_vfs, xbmc.translatePath("special://temp/"), self.progressBar)):
                    #we had a problem extracting the archive, delete everything
                    zip_vfs.cleanup()
                    self.xbmc_vfs.rmfile(xbmc.translatePath("special://temp/" + self.restore_point))
                    
                    xbmcgui.Dialog.ok(utils.getSetting(30010),utils.getString(30101))
                    return
                    
                zip_vfs.cleanup()
                
                self.progressBar.updateProgress(0,utils.getString(30049) + "......")
                #set the new remote vfs and fix xbmc path
                self.remote_vfs = XBMCFileSystem(xbmc.translatePath("special://temp/" + self.restore_point.split(".")[0] + "/"))
                self.xbmc_vfs.set_root(xbmc.translatePath("special://home/"))
            
            #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

            if(not self._checkValidationFile(self.remote_vfs.root_path)):
                #don't continue
                return

            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

            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
                    restartXbmc = xbmcgui.Dialog().yesno(utils.getString(30038),utils.getString(30039),utils.getString(30040), utils.getString(30041))

                    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
                        xbmcgui.Dialog().ok(utils.getString(30077),utils.getString(30078))
                        
                        return
                
                fileManager.addFile('-' + self.remote_vfs.root_path + 'userdata/keymaps')
                fileManager.walkTree(self.remote_vfs.root_path + "userdata/keymaps")
                
                fileManager.addFile('-' + self.remote_vfs.root_path + "userdata/peripheral_data")
                fileManager.walkTree(self.remote_vfs.root_path + "userdata/peripheral_data")
            
                fileManager.addFile('-' + self.remote_vfs.root_path + "userdata/library")
                fileManager.walkTree(self.remote_vfs.root_path + "userdata/library")
            
                #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)

            if(utils.getSetting('backup_addons') == 'true'):
                fileManager.addFile('-' + self.remote_vfs.root_path + "addons")
                fileManager.walkTree(self.remote_vfs.root_path + "addons")

            self.xbmc_vfs.mkdir(xbmc.translatePath('special://home/userdata'))

            if(utils.getSetting('backup_addon_data') == 'true'):
                fileManager.addFile('-' + self.remote_vfs.root_path + "userdata/addon_data")
                fileManager.walkTree(self.remote_vfs.root_path + "userdata/addon_data")

            if(utils.getSetting('backup_database') == 'true'):
                fileManager.addFile('-' + self.remote_vfs.root_path + "userdata/Database")
                fileManager.walkTree(self.remote_vfs.root_path + "userdata/Database")
        
            if(utils.getSetting("backup_playlists") == 'true'):
                fileManager.addFile('-' + self.remote_vfs.root_path + "userdata/playlists")
                fileManager.walkTree(self.remote_vfs.root_path + "userdata/playlists")

            if(utils.getSetting('backup_profiles') == 'true'):
                fileManager.addFile('-' + self.remote_vfs.root_path + "userdata/profiles")
                fileManager.walkTree(self.remote_vfs.root_path + "userdata/profiles")
                
            if(utils.getSetting("backup_thumbnails") == "true"):
                fileManager.addFile('-' + self.remote_vfs.root_path + "userdata/Thumbnails")
                fileManager.walkTree(self.remote_vfs.root_path + "userdata/Thumbnails")

            #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
            if(utils.getSetting('custom_dir_1_enable') == 'true' and utils.getSetting('backup_custom_dir_1') != ''):

                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) + "/")):
                    #index files to restore
                    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:
                    utils.log("error path not found: " + self.remote_vfs.root_path + "custom_" + self._createCRC(self.xbmc_vfs.root_path))
                    xbmcgui.Dialog().ok(utils.getString(30010),utils.getString(30045),self.remote_vfs.root_path + "custom_" + self._createCRC(utils.getSetting('backup_custom_dir_1')))

            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))
                    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:
                    utils.log("error path not found: " + self.remote_vfs.root_path + "custom_" + self._createCRC(self.xbmc_vfs.root_path))
                    xbmcgui.Dialog().ok(utils.getString(30010),utils.getString(30045),self.remote_vfs.root_path + "custom_" + self._createCRC(utils.getSetting('backup_custom_dir_2')))


            #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)

            self.progressBar.updateProgress(99,"Clean up operations .....")

            if(self.restore_point.split('.')[-1] == 'zip'):
                #delete the zip file and the extracted directory
                self.xbmc_vfs.rmfile(xbmc.translatePath("special://temp/" + self.restore_point))
                self.xbmc_vfs.rmdir(self.remote_vfs.root_path)

            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()

            #call update addons to refresh everything
            xbmc.executebuiltin('UpdateLocalAddons')

        self.xbmc_vfs.cleanup()
        self.remote_vfs.cleanup()
        self.progressBar.close()

        #reset the window setting
        window.setProperty(utils.__addon_id__ + ".running","")