Exemplo n.º 1
0
    def start(self):

        #check if a backup should be resumed
        resumeRestore = self._resumeCheck()

        if (resumeRestore):
            restore = XbmcBackup()
            restore.selectRestore(self.restore_point)
            #skip the advanced settings check
            restore.skipAdvanced()
            restore.run(XbmcBackup.Restore)

        while (not xbmc.abortRequested):

            if (self.enabled == "true"):
                #scheduler is still on
                now = time.time()

                if (self.next_run <= now):
                    progress_mode = int(utils.getSetting('progress_mode'))
                    if (progress_mode != 2):
                        utils.showNotification(utils.getString(30053))

                    backup = XbmcBackup()

                    if (backup.remoteConfigured()):

                        if (int(utils.getSetting('progress_mode')) in [0, 1]):
                            backup.run(XbmcBackup.Backup, True)
                        else:
                            backup.run(XbmcBackup.Backup, False)

                        #check if this is a "one-off"
                        if (int(utils.getSetting("schedule_interval")) == 0):
                            #disable the scheduler after this run
                            self.enabled = "false"
                            utils.setSetting('enable_scheduler', 'false')
                    else:
                        utils.showNotification(utils.getString(30045))

                    #check if we should shut the computer down
                    if (utils.getSetting("cron_shutdown") == 'true'):
                        #wait 10 seconds to make sure all backup processes and files are completed
                        time.sleep(10)
                        xbmc.executebuiltin('ShutDown()')
                    else:
                        #find the next run time like normal
                        self.findNextRun(now)

            xbmc.sleep(500)

        #delete monitor to free up memory
        del self.monitor
    def start(self):

        #check if a backup should be resumed
        resumeRestore = self._resumeCheck()

        if (resumeRestore):
            restore = XbmcBackup()
            restore.selectRestore(self.restore_point)
            #skip the advanced settings check
            restore.skipAdvanced()
            restore.run(XbmcBackup.Restore)

        while (not xbmc.abortRequested):

            if (self.enabled == "true"):
                #scheduler is still on
                now = time.time()

                if (self.next_run <= now):
                    progress_mode = int(utils.getSetting('progress_mode'))
                    self.doScheduledBackup(progress_mode)

                    #check if we should shut the computer down
                    if (utils.getSetting("cron_shutdown") == 'true'):
                        #wait 10 seconds to make sure all backup processes and files are completed
                        time.sleep(10)
                        xbmc.executebuiltin('ShutDown()')
                    else:
                        #find the next run time like normal
                        self.findNextRun(now)

            xbmc.sleep(500)

        #delete monitor to free up memory
        del self.monitor
    def doScheduledBackup(self, progress_mode):
        if (progress_mode != 2):
            utils.showNotification(utils.getString(30053))

        backup = XbmcBackup()

        if (backup.remoteConfigured()):

            if (int(utils.getSetting('progress_mode')) in [0, 1]):
                backup.run(XbmcBackup.Backup, True)
            else:
                backup.run(XbmcBackup.Backup, False)

            #check if this is a "one-off"
            if (int(utils.getSetting("schedule_interval")) == 0):
                #disable the scheduler after this run
                self.enabled = "false"
                utils.setSetting('enable_scheduler', 'false')
        else:
            utils.showNotification(utils.getString(30045))
Exemplo n.º 4
0
    def start(self):

        # display upgrade messages if they exist
        if (utils.getSettingInt('upgrade_notes') < UPGRADE_INT):
            xbmcgui.Dialog().ok(utils.getString(30010), utils.getString(30132))
            utils.setSetting('upgrade_notes', str(UPGRADE_INT))

        # check if a backup should be resumed
        resumeRestore = self._resumeCheck()

        if (resumeRestore):
            restore = XbmcBackup()
            restore.selectRestore(self.restore_point)
            # skip the advanced settings check
            restore.skipAdvanced()
            restore.restore()

        while (not self.monitor.abortRequested()):

            if (self.enabled):
                # scheduler is still on
                now = time.time()

                if (self.next_run <= now):
                    progress_mode = utils.getSettingInt('progress_mode')
                    self.doScheduledBackup(progress_mode)

                    # check if we should shut the computer down
                    if (utils.getSettingBool("cron_shutdown")):
                        # wait 10 seconds to make sure all backup processes and files are completed
                        time.sleep(10)
                        xbmc.executebuiltin('ShutDown()')
                    else:
                        # find the next run time like normal
                        self.findNextRun(now)

            xbmc.sleep(500)

        # delete monitor to free up memory
        del self.monitor
        mode = 1

#if mode wasn't passed in as arg, get from user
if (mode == -1):
    #figure out if this is a backup or a restore from the user
    mode = xbmcgui.Dialog().select(
        utils.getString(30010) + " - " + utils.getString(30023), [
            utils.getString(30016),
            utils.getString(30017),
            utils.getString(30099)
        ])

#check if program should be run
if (mode != -1):
    #run the profile backup
    backup = XbmcBackup()

    if (mode == 2):
        #open the settings dialog
        utils.openSettings()

    elif (backup.remoteConfigured()):

        if (mode == backup.Restore):
            #get list of valid restore points
            restorePoints = backup.listBackups()
            pointNames = []
            folderNames = []

            for aDir in restorePoints:
                pointNames.append(aDir[1])