コード例 #1
0
ファイル: launcher.py プロジェクト: oldium/xbmcbackup
def remove_auth():
    # triggered from settings.xml - asks if user wants to delete OAuth token information
    shouldDelete = xbmcgui.Dialog().yesno(utils.getString(30093), utils.getString(30094), utils.getString(30095), autoclose=7000)

    if(shouldDelete):
        # delete any of the known token file types
        xbmcvfs.delete(xbmc.translatePath(utils.data_dir() + "tokens.txt"))  # dropbox
        xbmcvfs.delete(xbmc.translatePath(utils.data_dir() + "google_drive.dat"))  # google drive
コード例 #2
0
    def _getToken(self):
        #get token, if it exists
        if(xbmcvfs.exists(xbmc.translatePath(utils.data_dir() + "tokens.txt"))):
            token_file = open(xbmc.translatePath(utils.data_dir() + "tokens.txt"))
            token = token_file.read()
            token_file.close()

            return token
        else:
            return ""
コード例 #3
0
ファイル: scheduler.py プロジェクト: NEOhidra/xbmcbackup
    def _resumeCheck(self):
        shouldContinue = False
        if(xbmcvfs.exists(xbmc.translatePath(utils.data_dir() + "resume.txt"))):
            rFile = xbmcvfs.File(xbmc.translatePath(utils.data_dir() + "resume.txt"),'r')
            self.restore_point = rFile.read()
            rFile.close()
            xbmcvfs.delete(xbmc.translatePath(utils.data_dir() + "resume.txt"))
            shouldContinue = xbmcgui.Dialog().yesno(utils.getString(30042),utils.getString(30043),utils.getString(30044))

        return shouldContinue
コード例 #4
0
    def _resumeCheck(self):
        shouldContinue = False
        if (xbmcvfs.exists(xbmc.translatePath(utils.data_dir() +
                                              "resume.txt"))):
            rFile = xbmcvfs.File(
                xbmc.translatePath(utils.data_dir() + "resume.txt"), 'r')
            self.restore_point = rFile.read()
            rFile.close()
            xbmcvfs.delete(xbmc.translatePath(utils.data_dir() + "resume.txt"))
            shouldContinue = xbmcgui.Dialog().yesno(utils.getString(30042),
                                                    utils.getString(30043),
                                                    utils.getString(30044))

        return shouldContinue
コード例 #5
0
ファイル: service.py プロジェクト: Lunatixz/repo-scripts
    def writeLastRun(self):
        runFile = xbmcvfs.File(
            xbmcvfs.translatePath(utils.data_dir() + "last_run.txt"), 'w')
        runFile.write(str(self.last_run))
        runFile.close()

        self.showNotify(True)
コード例 #6
0
    def readLastRun(self):
        if(self.last_run == 0):
            #read it in from the settings
            if(xbmcvfs.exists(xbmc.translatePath(utils.data_dir() + "last_run.txt"))):
                
                runFile = xbmcvfs.File(xbmc.translatePath(utils.data_dir() + "last_run.txt"))

                try:
                    #there may be an issue with this file, we'll get it the next time through
                    self.last_run = float(runFile.read())
                except ValueError:
                    self.last_run = 0 

                runFile.close()
            else:
               self.last_run = 0
コード例 #7
0
ファイル: scheduler.py プロジェクト: robweber/xbmcbackup
    def __init__(self):
        self.monitor = UpdateMonitor(update_method = self.settingsChanged)
        self.enabled = utils.getSetting("enable_scheduler")
        self.next_run_path = xbmc.translatePath(utils.data_dir()) + 'next_run.txt'

        if(self.enabled == "true"):

            nr = 0
            if(xbmcvfs.exists(self.next_run_path)):

                fh = xbmcvfs.File(self.next_run_path)
                try:
                    #check if we saved a run time from the last run
                    nr = float(fh.read())
                except ValueError:
                    nr = 0

                fh.close()

            #if we missed and the user wants to play catch-up
            if(0 < nr <= time.time() and utils.getSetting('schedule_miss') == 'true'):
                utils.log("scheduled backup was missed, doing it now...")
                progress_mode = int(utils.getSetting('progress_mode'))
                
                if(progress_mode == 0):
                    progress_mode = 1 # Kodi just started, don't block it with a foreground progress bar

                self.doScheduledBackup(progress_mode)
                
            self.setup()
コード例 #8
0
    def __init__(self):
        self.monitor = UpdateMonitor(update_method=self.settingsChanged)
        self.enabled = utils.getSetting("enable_scheduler")
        self.next_run_path = xbmc.translatePath(
            utils.data_dir()) + 'next_run.txt'

        if (self.enabled == "true"):

            nr = 0
            if (xbmcvfs.exists(self.next_run_path)):

                fh = xbmcvfs.File(self.next_run_path)
                try:
                    #check if we saved a run time from the last run
                    nr = float(fh.read())
                except ValueError:
                    nr = 0

                fh.close()

            #if we missed and the user wants to play catch-up
            if (0 < nr <= time.time()
                    and utils.getSetting('schedule_miss') == 'true'):
                utils.log("scheduled backup was missed, doing it now...")
                progress_mode = int(utils.getSetting('progress_mode'))

                if (progress_mode == 0):
                    progress_mode = 1  # Kodi just started, don't block it with a foreground progress bar

                self.doScheduledBackup(progress_mode)

            self.setup()
コード例 #9
0
ファイル: authorizers.py プロジェクト: gacj22/WizardGacj22
    def authorize(self):
        result = True

        if (not self.setup()):
            return False

        #create authorization helper and load default settings
        gauth = GoogleAuth(
            xbmc.validatePath(
                xbmc.translatePath(utils.addon_dir() +
                                   '/resources/lib/pydrive/settings.yaml')))
        gauth.LoadClientConfigSettings()

        settings = {
            "client_id": self.CLIENT_ID,
            'client_secret': self.CLIENT_SECRET
        }

        drive_url = gauth.GetAuthUrl(settings)

        utils.log("Google Drive Authorize URL: " + drive_url)

        xbmcgui.Dialog().ok(utils.getString(30010), utils.getString(30056),
                            utils.getString(30102), tinyurl.shorten(drive_url))
        code = xbmcgui.Dialog().input(
            utils.getString(30098) + ' ' + utils.getString(30103))

        gauth.Auth(code)
        gauth.SaveCredentialsFile(
            xbmc.validatePath(
                xbmc.translatePath(utils.data_dir() + 'google_drive.dat')))

        return result
コード例 #10
0
    def getClient(self):
        #create authorization helper and load default settings
        gauth = GoogleAuth(xbmc.validatePath(xbmc.translatePath(utils.addon_dir() + '/resources/lib/pydrive/settings.yaml')))
        gauth.LoadClientConfigSettings()

        gauth.LoadCredentialsFile(xbmc.validatePath(xbmc.translatePath(utils.data_dir() + 'google_drive.dat')))

        result = GoogleDrive(gauth)

        return result
コード例 #11
0
ファイル: scheduler.py プロジェクト: dersphere/xbmcbackup
    def findNextRun(self,now,forceUpdate = False):
        mod_time = self.settings_update_time
        
        #check if the schedule has been modified
        try:
            #get the last modified time of the file
            mod_time = os.path.getmtime(xbmc.translatePath(utils.data_dir()) + "settings.xml")
        except:
            #don't do anything here
            mod_time = self.settings_update_time

        if(mod_time > self.settings_update_time or forceUpdate):
            self.settings_update_time = mod_time
            
            #find the cron expression and get the next run time
            cron_exp = self.parseSchedule()

            cron_ob = croniter(cron_exp,datetime.datetime.fromtimestamp(now))
            new_run_time = cron_ob.get_next(float)

            if(new_run_time != self.next_run):
                self.next_run = new_run_time
                utils.log("scheduler will run again on " + datetime.datetime.fromtimestamp(self.next_run).strftime('%m-%d-%Y %H:%M'))
コード例 #12
0
ファイル: authorizers.py プロジェクト: robweber/xbmcbackup
    def authorize(self):
        result = True

        if(not self.setup()):
            return False

        #create authorization helper and load default settings
        gauth = GoogleAuth(xbmc.validatePath(xbmc.translatePath(utils.addon_dir() + '/resources/lib/pydrive/settings.yaml')))
        gauth.LoadClientConfigSettings()

        settings = {"client_id":self.CLIENT_ID,'client_secret':self.CLIENT_SECRET}
    
        drive_url = gauth.GetAuthUrl(settings)
    
        utils.log("Google Drive Authorize URL: " + drive_url)

        xbmcgui.Dialog().ok(utils.getString(30010),utils.getString(30056),utils.getString(30102),tinyurl.shorten(drive_url))
        code = xbmcgui.Dialog().input(utils.getString(30098) + ' ' + utils.getString(30103))

        gauth.Auth(code)
        gauth.SaveCredentialsFile(xbmc.validatePath(xbmc.translatePath(utils.data_dir() + 'google_drive.dat')))

        return result
コード例 #13
0
import xbmc
import xbmcgui
import xbmcvfs
import resources.lib.utils as utils

#triggered from settings.xml - asks if user wants to delete OAuth token information
shouldDelete = xbmcgui.Dialog().yesno(utils.getString(30093),
                                      utils.getString(30094),
                                      utils.getString(30095),
                                      autoclose=7000)

if (shouldDelete):
    #delete any of the known token file types
    xbmcvfs.delete(xbmc.translatePath(utils.data_dir() +
                                      "tokens.txt"))  #dropbox
    xbmcvfs.delete(xbmc.translatePath(utils.data_dir() +
                                      "google_drive.dat"))  #google drive
コード例 #14
0
ファイル: default.py プロジェクト: robweber/service.history
    def _settingsBackup(self):
        #make a backup of the settings file (in case pin is incorrect)
        settings_file = xbmc.translatePath(utils.data_dir() + "settings.xml")

        if(xbmcvfs.exists(settings_file)):
            xbmcvfs.copy(settings_file,settings_file + ".bak")
コード例 #15
0
    def writeLastRun(self):
        runFile = xbmcvfs.File(xbmc.translatePath(utils.data_dir() + "last_run.txt"),'w')
        runFile.write(str(self.last_run))
        runFile.close()

        self.showNotify(True)
コード例 #16
0
import xbmc
import xbmcgui
import xbmcvfs
import resources.lib.utils as utils

#triggered from settings.xml - asks if user wants to delete OAuth token information
shouldDelete = xbmcgui.Dialog().yesno(utils.getString(30093),utils.getString(30094),utils.getString(30095),autoclose=7000)

if(shouldDelete):
    #delete any of the known token file types
    xbmcvfs.delete(xbmc.translatePath(utils.data_dir() + "tokens.txt")) #dropbox
コード例 #17
0
 def _deleteToken(self):
     if(xbmcvfs.exists(xbmc.translatePath(utils.data_dir() + "tokens.txt"))):
         xbmcvfs.delete(xbmc.translatePath(utils.data_dir() + "tokens.txt"))
コード例 #18
0
 def isAuthorized(self):
     return xbmcvfs.exists(xbmc.translatePath(utils.data_dir() + "google_drive.dat"))
コード例 #19
0
import xbmc
import xbmcgui
import xbmcvfs
import resources.lib.utils as utils

#triggered from settings.xml - asks if user wants to delete OAuth token information
shouldDelete = xbmcgui.Dialog().yesno(utils.getString(30093),utils.getString(30094),utils.getString(30095),autoclose=7000)

if(shouldDelete):
    #delete any of the known token file types
    xbmcvfs.delete(xbmc.translatePath(utils.data_dir() + "tokens.txt")) #dropbox
    xbmcvfs.delete(xbmc.translatePath(utils.data_dir() + "google_drive.dat")) #google drive
    
コード例 #20
0
ファイル: default.py プロジェクト: robweber/service.history
    def _settingsRestore(self):
        #restore the settings file (in case pin is incorrect)
        settings_file = xbmc.translatePath(utils.data_dir() + "settings.xml")

        if(xbmcvfs.exists(settings_file)):
            xbmcvfs.copy(settings_file + ".bak",settings_file)
コード例 #21
0
 def _setToken(self,token):
     #write the token files
     token_file = open(xbmc.translatePath(utils.data_dir() + "tokens.txt"),'w')
     token_file.write(token)
     token_file.close()