コード例 #1
0
def showMainScreen(contentType):
    exitCondition = ""
    customPaths = CustomPathFile(contentType)

    while (exitCondition != -1):
        # load the custom paths
        options = ['Add']

        for aPath in customPaths.getPaths():
            options.append(aPath['path'] + ' - ' + aPath['expression'])

        # show the gui
        exitCondition = dialog.select(utils.getString(30020), options)

        if (exitCondition >= 0):
            if (exitCondition == 0):
                path = selectPath(contentType)

                # could return None if dialog canceled
                if (path is not None):
                    customPaths.addPath(path)
            else:
                # delete?
                if (dialog.yesno(heading=utils.getString(30021),
                                 line1=utils.getString(30022))):
                    # get the id of the selected item
                    aPath = customPaths.getPaths()[exitCondition - 1]
                    # delete that id
                    customPaths.deletePath(aPath['id'])
コード例 #2
0
    def cleanLibrary(self,media_type):
        #check if we should verify paths
        if(utils.getSetting("verify_paths") == 'true'):
            response = eval(xbmc.executeJSONRPC('{ "jsonrpc" : "2.0", "method" : "Files.GetSources", "params":{"media":"' + media_type + '"}, "id": 1}'))

            if(response.has_key('error')):
                utils.log("Error " + response['error']['data']['method'] + " - " + response['error']['message'],xbmc.LOGDEBUG)
                return
            
            for source in response['result']['sources']:
                if not self._sourceExists(source['file']):
                    #let the user know this failed, if they subscribe to notifications
                    if(utils.getSetting('notify_next_run') == 'true'):
                        utils.showNotification(utils.getString(30050),"Source " + source['label'] + " does not exist")

                    utils.log("Path " + source['file'] + " does not exist")
                    return

        #also check if we should verify with user first
        if(utils.getSetting('user_confirm_clean') == 'true'):
            #user can decide 'no' here and exit this
            runClean = xbmcgui.Dialog().yesno(utils.getString(30000),utils.getString(30052),utils.getString(30053))
            if(not runClean):
                return
                
        #run the clean operation
        utils.log("Cleaning Database")
        xbmc.executebuiltin("CleanLibrary(" + media_type + ")")

        #write last run time, will trigger notifications
        self.writeLastRun()
コード例 #3
0
ファイル: default.py プロジェクト: jasherai/script.sendto
    def hostInfo(self):
        #get some information about this host
        selectedHost = self.host_manager.getHost(int(params['host']))

        isPlaying = selectedHost.isPlaying()
        
        if(isPlaying == -2):
            item = xbmcgui.ListItem(utils.getString(30024))
            ok = xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),url="%s?%s" % (sys.argv[0],"mode=0"),listitem=item,isFolder=False)
        elif(isPlaying == -1):
            item = xbmcgui.ListItem(utils.getString(30025))
            ok = xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),url="%s?%s" % (sys.argv[0],"mode=0"),listitem=item,isFolder=False)
        else:
            #get properties on the currently playing file
            fileProps = selectedHost.playingProperties()
            
            #get the playlist of playing items
            playingItems = selectedHost.getPlaylist()

            index = 0
            for aItem in playingItems:
                itemLabel = aItem['label']

                if(index == fileProps['position']):
                    itemLabel = "*" + utils.getString(30026) + "* " + itemLabel
                    
                item = xbmcgui.ListItem(itemLabel)
                ok = xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),url="%s?%s" % (sys.argv[0],"mode=1004&host=" + params['host'] + "&item=" + str(index)),listitem=item,isFolder=False)
                index = index + 1
        
        xbmcplugin.endOfDirectory(int(sys.argv[1]),cacheToDisc=False)
コード例 #4
0
    def listHosts(self):
        context_url = "%s?%s"

        if (len(self.host_manager.hosts) > 0):
            #lists all hosts
            index = 0
            for aHost in self.host_manager.hosts:
                item = xbmcgui.ListItem(aHost.name, aHost.address)
                item.addContextMenuItems([
                    (utils.getString(30020), "Xbmc.RunPlugin(%s?%s)" %
                     (sys.argv[0], "mode=1005&host=" + str(index))),
                    (utils.getString(30021),
                     "Xbmc.RunPlugin(%s?%s)" % (sys.argv[0], "mode=1002")),
                    (utils.getString(30022), "Xbmc.RunPlugin(%s?%s)" %
                     (sys.argv[0], 'mode=1003&host=' + str(index)))
                ])
                ok = xbmcplugin.addDirectoryItem(
                    handle=int(sys.argv[1]),
                    url=context_url %
                    (sys.argv[0], "mode=1001&host=" + str(index)),
                    listitem=item,
                    isFolder=True)
                index = index + 1
        else:
            #just list the 'add' button
            item = xbmcgui.ListItem(utils.getString(30021))
            ok = xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),
                                             url="%s?%s" %
                                             (sys.argv[0], "mode=1002"),
                                             listitem=item,
                                             isFolder=False)

        xbmcplugin.endOfDirectory(int(sys.argv[1]), cacheToDisc=False)
コード例 #5
0
    def _createJob(self):
        newJob = CronJob()
        
        #get the name, command, expression and notification setting
        name = xbmcgui.Dialog().input(heading=utils.getString(30002))

        if(name == ""):
            return
        else:
            newJob.name = name

        command = xbmcgui.Dialog().input(heading=utils.getString(30003))

        if(command == ""):
            return
        else:
            newJob.command = command

        expression = xbmcgui.Dialog().input(utils.getString(30004),"0 0 * * *")

        if(expression == ""):
            return
        else:
            newJob.expression = expression

        if(xbmcgui.Dialog().yesno(utils.getString(30005), utils.getString(30010))):
            newJob.show_notification = "true"
        else:
            newJob.show_notification = "false"

        self.cron.addJob(newJob)
コード例 #6
0
ファイル: default.py プロジェクト: bstrdsmkr/script.sendto
    def pullMedia(self):
        host = int(params['host'])
        selectedItem = int(params['item'])
        
        action = xbmcgui.Dialog().select(utils.getString(30030),(utils.getString(30031),utils.getString(30032),utils.getString(30033),utils.getString(30034)))

        remote_host = self.host_manager.getHost(host)
        if(action == 0):
            #do a reverse SendTo
            SendTo().reverse(remote_host)
            xbmc.executebuiltin('Container.Refresh')
        elif(action == 1):
            #start playing only this file
            playingFiles = remote_host.getPlaylist()
            local_host = XbmcHost('Local','127.0.0.1','80')
            local_host.playFile(playingFiles[selectedItem]['file'])
        elif(action == 2):
            #pull the whole list but start at this index
            playerid = remote_host.isPlaying()
            playingFiles = remote_host.getPlaylist()
            
            local_host = XbmcHost('Local','127.0.0.1','80')

            #send the playerid so we add to the right playlist
            local_host.addItems(playingFiles,playerid)
            local_host.playPosition(selectedItem,playerid)
            
        elif(action == 3):
            #just stop the playing media on this machine
            remote_host.stop()
            xbmc.executebuiltin('Container.Refresh')
コード例 #7
0
    def runProgram(self):
        #a one-time catch for the startup delay
        if (int(utils.getSetting("startup_delay")) != 0):
            count = 0
            while count < len(self.schedules):
                if (time.time() > self.schedules[count].next_run):
                    #we missed at least one update, fix this
                    self.schedules[count].next_run = time.time() + int(
                        utils.getSetting("startup_delay")) * 60
                count = count + 1

        #display upgrade messages if they exist
        if (int(utils.getSetting('upgrade_notes')) < UPGRADE_INT):
            xbmcgui.Dialog().ok(utils.getString(30000), utils.getString(30030))
            utils.setSetting('upgrade_notes', str(UPGRADE_INT))

        #program has started, check if we should show a notification
        self.showNotify()

        while (not xbmc.abortRequested):

            #don't check unless new minute
            if (time.time() > self.last_run + 60):
                self.readLastRun()

                self.evalSchedules()

            xbmc.sleep(self.sleep_time)

        #clean up monitor on exit
        del self.monitor
コード例 #8
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
コード例 #9
0
    def authorize(self):
        result = True

        if(not self.setup()):
            return False
        
        if(self.isAuthorized()):
            #delete the token to start over
            self._deleteToken()

        #copied flow from http://dropbox-sdk-python.readthedocs.io/en/latest/moduledoc.html#dropbox.oauth.DropboxOAuth2FlowNoRedirect
        flow = dropbox.oauth.DropboxOAuth2FlowNoRedirect(self.APP_KEY,self.APP_SECRET)

        url = flow.start()

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

        #get the auth code
        code = xbmcgui.Dialog().input(utils.getString(30027) + ' ' + utils.getString(30103))
        
        #if user authorized this will work

        try:
            user_token = flow.finish(code)
            self._setToken(user_token.access_token)
        except Exception,e:
            utils.log("Error: %s" % (e,))
            result = False
コード例 #10
0
    def cleanLibrary(self,media_type):
        #check if we should verify paths
        if(utils.getSetting("verify_paths") == 'true'):
            response = eval(xbmc.executeJSONRPC('{ "jsonrpc" : "2.0", "method" : "Files.GetSources", "params":{"media":"' + media_type + '"}, "id": 1}'))

            if(response.has_key('error')):
                utils.log("Error " + response['error']['data']['method'] + " - " + response['error']['message'],xbmc.LOGDEBUG)
                return
            
            for source in response['result']['sources']:
                if not self._sourceExists(source['file']):
                    #let the user know this failed, if they subscribe to notifications
                    if(utils.getSetting('notify_next_run') == 'true'):
                        utils.showNotification(utils.getString(30050),"Source " + source['label'] + " does not exist")

                    utils.log("Path " + source['file'] + " does not exist")
                    return

        #also check if we should verify with user first
        if(utils.getSetting('user_confirm_clean') == 'true'):
            #user can decide 'no' here and exit this
            runClean = xbmcgui.Dialog().yesno(utils.getString(30000),utils.getString(30052),utils.getString(30053))
            if(not runClean):
                return
                
        #run the clean operation
        utils.log("Cleaning Database")
        xbmc.executebuiltin("CleanLibrary(" + media_type + ")")

        #write last run time, will trigger notifications
        self.writeLastRun()
コード例 #11
0
def showMainScreen():
    exitCondition = ""
    customPaths = CustomPathFile()

    while (exitCondition != -1):
        #load the custom paths
        options = ['Add']

        for aPath in customPaths.getPaths():
            options.append(aPath['path'] + ' - ' + aPath['expression'])

        #show the gui
        exitCondition = dialog.select(utils.getString(30020), options)

        if (exitCondition >= 0):
            if (exitCondition == 0):
                path = selectPath()

                #could return None if dialog canceled
                if (path != None):
                    customPaths.addPath(path)
            else:
                #delete?
                if (dialog.yesno(heading=utils.getString(30021),
                                 line1=utils.getString(30022))):
                    #delete this path - subtract one because of "add" item
                    customPaths.deletePath(exitCondition - 1)
コード例 #12
0
ファイル: service.py プロジェクト: Lunatixz/repo-scripts
    def runProgram(self):
        # a one-time catch for the startup delay
        if (utils.getSettingInt("startup_delay") != 0):
            count = 0
            while count < len(self.schedules):
                if (time.time() > self.schedules[count].next_run):
                    # we missed at least one update, fix this
                    self.schedules[count].next_run = time.time(
                    ) + utils.getSettingInt("startup_delay") * 60
                count = count + 1

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

        # program has started, check if we should show a notification
        self.showNotify()

        while (True):

            # don't check unless new minute
            if (time.time() > self.last_run + 60):
                self.readLastRun()

                self.evalSchedules()

            # calculate the sleep time (next minute)
            now = datetime.now()
            if (self.monitor.waitForAbort(60 - now.second)):
                break

        # clean up monitor on exit
        del self.monitor
コード例 #13
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
コード例 #14
0
ファイル: launcher.py プロジェクト: oldium/xbmcbackup
def authorize_cloud(cloudProvider):
    # drobpox
    if(cloudProvider == 'dropbox'):
        authorizer = DropboxAuthorizer()

        if(authorizer.authorize()):
            xbmcgui.Dialog().ok(utils.getString(30010), utils.getString(30027) + ' ' + utils.getString(30106))
        else:
            xbmcgui.Dialog().ok(utils.getString(30010), utils.getString(30107) + ' ' + utils.getString(30027))
コード例 #15
0
    def setup(self):
        result = True
        
        if(self.CLIENT_ID == '' and self.CLIENT_SECRET == ''):
            #we can't go any farther, need these for sure
            xbmcgui.Dialog().ok(utils.getString(30010),utils.getString(30098) + ' ' + utils.getString(30058),utils.getString(30108))
            result = False

        return result
コード例 #16
0
def selectPath():
    path = {'expression':'0 */2 * * *'}
    
    #select path to scan
    path['path'] = dialog.browse(0,utils.getString(30023),'video')

    #create expression
    path['expression'] = dialog.input(utils.getString(30056),path['expression'])
    
    return path
コード例 #17
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
コード例 #18
0
ファイル: scheduler.py プロジェクト: EDUARDO1122/Halowrepo
    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
コード例 #19
0
ファイル: scheduler.py プロジェクト: elephunk84/KodiRepo
    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
コード例 #20
0
    def setup(self):
        result = True

        if (self.APP_KEY == '' and self.APP_SECRET == ''):
            # we can't go any farther, need these for sure
            xbmcgui.Dialog().ok(
                utils.getString(30010),
                '%s %s\n%s' % (utils.getString(30027), utils.getString(30058),
                               utils.getString(30059)))

            result = False

        return result
コード例 #21
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
コード例 #22
0
    def cleanLibrary(self,media_type):
        #check if we should verify with user first
        if(utils.getSetting('user_confirm_clean') == 'true'):
            #user can decide 'no' here and exit this
            runClean = xbmcgui.Dialog().yesno(utils.getString(30000),utils.getString(30052),line2=utils.getString(30053),autoclose=15000)
            if(not runClean):
                return
                
        #run the clean operation
        utils.log("Cleaning Database")
        xbmc.executebuiltin("CleanLibrary(" + media_type + ")")

        #write last run time, will trigger notifications
        self.writeLastRun()
コード例 #23
0
ファイル: default.py プロジェクト: bstrdsmkr/script.sendto
    def addHost(self):
        name = None
        address = None
        port = None
        
        #get the name, address, and port
        name = self._getInput(utils.getString(30027))
        address = self._getInput(utils.getString(30028))
        port = self._getInput(utils.getString(30029))

        if(name != None and address != None and port != None):
            aHost = XbmcHost(name,address,int(port))
            self.host_manager.addHost(aHost)
            xbmc.executebuiltin('Container.Refresh')
コード例 #24
0
    def cleanLibrary(self,media_type):
        #check if we should verify with user first
        if(utils.getSetting('user_confirm_clean') == 'true'):
            #user can decide 'no' here and exit this
            runClean = xbmcgui.Dialog().yesno(utils.getString(30000),utils.getString(30052),line2=utils.getString(30053),autoclose=15000)
            if(not runClean):
                return
                
        #run the clean operation
        utils.log("Cleaning Database")
        xbmc.executebuiltin("CleanLibrary(" + media_type + ")")

        #write last run time, will trigger notifications
        self.writeLastRun()
コード例 #25
0
def selectPath():
    path = {'expression': '0 */2 * * *'}

    #select path to scan
    path['path'] = dialog.browse(0, utils.getString(30023), 'video')

    #create expression
    if (path['path'] != ''):
        path['expression'] = dialog.input(utils.getString(30056),
                                          path['expression'])
    else:
        #return nothing if dialog closed
        return None

    return path
コード例 #26
0
ファイル: scheduler.py プロジェクト: khaledlfc/xbmcbackup
    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):
                    if(utils.getSetting('run_silent') == 'false'):
                        utils.showNotification(utils.getString(30053))
                    #run the job in backup mode, hiding the dialog box
                    backup = XbmcBackup()
                    backup.run(XbmcBackup.Backup,True)

                    #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)
コード例 #27
0
    def sendNotification(self):
        remote_host = self.host_manager.getHost(int(params['host']))

        message = xbmcgui.Dialog().input(
            utils.getString(30035) + " " + remote_host.name, '',
            xbmcgui.INPUT_ALPHANUM)
        remote_host.sendNotification(message)
コード例 #28
0
    def findNextRun(self, now):
        progress_mode = int(utils.getSetting('progress_mode'))

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

            #write the next time to a file
            fh = xbmcvfs.File(self.next_run_path, 'w')
            fh.write(str(self.next_run))
            fh.close()

            #only show when not in silent mode
            if (progress_mode != 2):
                utils.showNotification(
                    utils.getString(30081) + " " +
                    datetime.datetime.fromtimestamp(self.next_run).strftime(
                        '%m-%d-%Y %H:%M'))
コード例 #29
0
    def run(self):
        mode = xbmcgui.Dialog().select(utils.getString(30010),[utils.getString(30011),utils.getString(30012)])

        copyComplete = False
        if(mode == self.REMOTE_MODE):
            copyComplete = self._copyFile(utils.getSetting('remote_filename'))
        elif(mode == self.LOCAL_MODE):
            copyComplete = self._copyFile(utils.getSetting('local_filename'))

        
        if(copyComplete):
            #prompt the user to restart xbmc
            restartXbmc = xbmcgui.Dialog().yesno(utils.getString(30010),"",utils.getString(30013))

            if(restartXbmc):
                xbmc.restart();
コード例 #30
0
ファイル: scheduler.py プロジェクト: dersphere/xbmcbackup
    def start(self):
        while(not xbmc.abortRequested):
            current_enabled = utils.getSetting("enable_scheduler")
            
            if(current_enabled == "true" and self.enabled == "false"):
                #scheduler was just turned on
                self.enabled = current_enabled
                self.setup()
            elif (current_enabled == "false" and self.enabled == "true"):
                #schedule was turn off
                self.enabled = current_enabled
            elif(self.enabled == "true"):
                #scheduler is still on
                now = time.time()

                if(self.next_run <= now):
                    if(utils.getSetting('run_silent') == 'false'):
                        utils.showNotification(utils.getString(30053))
                    #run the job in backup mode, hiding the dialog box
                    backup = XbmcBackup()
                    backup.run(XbmcBackup.Backup,True)
                    
                self.findNextRun(now)

            time.sleep(10)
コード例 #31
0
ファイル: default.py プロジェクト: jasherai/script.sendto
    def listHosts(self):
        context_url = "%s?%s"

        if(len(self.host_manager.hosts) > 0):
            #lists all hosts
            index = 0
            for aHost in self.host_manager.hosts:
                item = xbmcgui.ListItem(aHost.name,aHost.address)
                item.addContextMenuItems([(utils.getString(30020),"Xbmc.RunPlugin(%s?%s)" % (sys.argv[0],"mode=1005&host=" + str(index))),(utils.getString(30021), "Xbmc.RunPlugin(%s?%s)" % (sys.argv[0],"mode=1002")),(utils.getString(30022), "Xbmc.RunPlugin(%s?%s)" % (sys.argv[0],'mode=1003&host=' + str(index)))])
                ok = xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),url=context_url % (sys.argv[0],"mode=1001&host=" + str(index)),listitem=item,isFolder=True)
                index = index + 1
        else:
            #just list the 'add' button
            item = xbmcgui.ListItem(utils.getString(30021))
            ok = xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),url="%s?%s" % (sys.argv[0],"mode=1002"),listitem=item,isFolder=False)
            
        xbmcplugin.endOfDirectory(int(sys.argv[1]),cacheToDisc=False)
コード例 #32
0
ファイル: service.py プロジェクト: Lunatixz/repo-scripts
    def calcNextRun(self, cronExp, startTime):
        nextRun = -1

        try:
            # create croniter for this expression
            cron = croniter(cronExp, startTime)
            nextRun = cron.get_next(float)
        except ValueError:
            # error in syntax
            xbmcgui.Dialog().ok(utils.getString(30000),
                                utils.getString(30016) % cronExp)
            utils.log('Cron syntax error %s' % cronExp, xbmc.LOGDEBUG)

            # rerun with a valid syntax
            nextRun = self.calcNextRun('0 */2 * * *', startTime)

        return nextRun
コード例 #33
0
ファイル: service.py プロジェクト: Lunatixz/repo-scripts
    def cleanLibrary(self, cronJob):
        # check if we should verify with user first unless we're on 'clean after update'
        if (utils.getSettingBool('user_confirm_clean')
                and utils.getSettingInt('clean_timer') != 0):
            # user can decide 'no' here and exit this
            runClean = xbmcgui.Dialog().yesno(utils.getString(30000),
                                              utils.getString(30052),
                                              line2=utils.getString(30053),
                                              autoclose=15000)
            if (not runClean):
                return

        # run the clean operation
        utils.log("Cleaning Database")
        cronJob.executeCommand()

        # write last run time, will trigger notifications
        self.writeLastRun()
コード例 #34
0
ファイル: default.py プロジェクト: robweber/script.sendto
    def addHost(self):
        name = None
        address = None
        port = None
        user = None
        password = None
        
        #get the name, address, and port
        name = xbmcgui.Dialog().input(utils.getString(30027),'',xbmcgui.INPUT_ALPHANUM)
        address = xbmcgui.Dialog().input(utils.getString(30028),'',xbmcgui.INPUT_IPADDRESS)
        port = xbmcgui.Dialog().input(utils.getString(30029),'',xbmcgui.INPUT_NUMERIC)
        user = xbmcgui.Dialog().input(utils.getString(30042),'',xbmcgui.INPUT_ALPHANUM)
        password = xbmcgui.Dialog().input(utils.getString(30043),'',xbmcgui.INPUT_ALPHANUM)

        if(name != None and address != None and port != None):
            aHost = XbmcHost(name,address,int(port),user,password)
            self.host_manager.addHost(aHost)
            xbmc.executebuiltin('Container.Refresh')
コード例 #35
0
    def _copyFile(self,filename):
        utils.log("copying " + filename + " to advancedsettings.xml")

        if(xbmcvfs.exists(xbmc.translatePath(filename))):
            advanced_settings = xbmc.translatePath('special://profile/advancedsettings.xml')

            #if advancedsettings already exists, delete it
            if(xbmcvfs.exists(advanced_settings)):
                xbmcvfs.delete(advanced_settings)

            #copy the new file
            xbmcvfs.copy(xbmc.translatePath(filename),advanced_settings)
            
            return True
        else:
            xbmcgui.Dialog().ok(utils.getString(30010),utils.getString(30014))
            
            return False
コード例 #36
0
    def hostInfo(self):
        #get some information about this host
        selectedHost = self.host_manager.getHost(int(params['host']))

        isPlaying = selectedHost.isPlaying()

        if (isPlaying == -2):
            item = xbmcgui.ListItem(utils.getString(30024))
            ok = xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),
                                             url="%s?%s" %
                                             (sys.argv[0], "mode=0"),
                                             listitem=item,
                                             isFolder=False)
        elif (isPlaying == -1):
            item = xbmcgui.ListItem(utils.getString(30025))
            ok = xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),
                                             url="%s?%s" %
                                             (sys.argv[0], "mode=0"),
                                             listitem=item,
                                             isFolder=False)
        else:
            #get properties on the currently playing file
            fileProps = selectedHost.playingProperties()

            #get the playlist of playing items
            playingItems = selectedHost.getPlaylist()

            index = 0
            for aItem in playingItems:
                itemLabel = aItem['label']

                if (index == fileProps['position']):
                    itemLabel = "*" + utils.getString(30026) + "* " + itemLabel

                item = xbmcgui.ListItem(itemLabel)
                ok = xbmcplugin.addDirectoryItem(
                    handle=int(sys.argv[1]),
                    url="%s?%s" % (sys.argv[0], "mode=1004&host=" +
                                   params['host'] + "&item=" + str(index)),
                    listitem=item,
                    isFolder=False)
                index = index + 1

        xbmcplugin.endOfDirectory(int(sys.argv[1]), cacheToDisc=False)
コード例 #37
0
   def shouldRun(self):
      result = True
      
      #check if file exists
      if(not self.as_file.exists()):

         #as if the user would like to create one
         confirm = xbmcgui.Dialog().yesno(utils.getString(30023),utils.getString(30024))

         if(confirm):
            self.as_file.createFile()
         else:
            #don't continue
            result = False
      else:
         #try and load the file
         result = self.as_file.readFile()

      return result
コード例 #38
0
ファイル: scheduler.py プロジェクト: robweber/xbmcbackup
 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))
コード例 #39
0
    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))
コード例 #40
0
ファイル: scheduler.py プロジェクト: NEOhidra/xbmcbackup
    def findNextRun(self,now):
        #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.showNotification(utils.getString(30081) + " " + datetime.datetime.fromtimestamp(self.next_run).strftime('%m-%d-%Y %H:%M'))
            utils.log("scheduler will run again on " + datetime.datetime.fromtimestamp(self.next_run).strftime('%m-%d-%Y %H:%M'))
コード例 #41
0
ファイル: scheduler.py プロジェクト: MediaBrasil/xbmcbackup
    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
コード例 #42
0
ファイル: gui.py プロジェクト: robweber/cronxbmc
    def _createJob(self):
        newJob = CronJob()
        
        #get the name, command, expression and notification setting
        name = xbmcgui.Dialog().input(heading=utils.getString(30002))

        if(name == ""):
            return
        else:
            newJob.name = name

        command = xbmcgui.Dialog().input(heading=utils.getString(30003))

        if(command == ""):
            return
        else:
            newJob.command = command

        expression = xbmcgui.Dialog().input(utils.getString(30004),"0 0 * * *")

        if(expression == ""):
            return
        else:
            newJob.expression = expression

        if(xbmcgui.Dialog().yesno(utils.getString(30005), utils.getString(30010))):
            newJob.show_notification = "true"
        else:
            newJob.show_notification = "false"

        if(not self.cron.addJob(newJob)):
            xbmcgui.Dialog().ok(utils.getString(30000),'Job not added, cron expression error')
コード例 #43
0
    def pullMedia(self):
        host = int(params['host'])
        selectedItem = int(params['item'])

        action = xbmcgui.Dialog().select(
            utils.getString(30030),
            (utils.getString(30031), utils.getString(30032),
             utils.getString(30033), utils.getString(30034)))

        remote_host = self.host_manager.getHost(host)
        if (action == 0):
            #do a reverse SendTo
            SendTo().reverse(remote_host)
            xbmc.executebuiltin('Container.Refresh')
        elif (action == 1):
            #start playing only this file
            playingFiles = remote_host.getPlaylist()
            local_host = XbmcHost('Local', '127.0.0.1', '80', '', '')
            local_host.playFile(playingFiles[selectedItem]['file'])
        elif (action == 2):
            #pull the whole list but start at this index
            playerid = remote_host.isPlaying()
            playingFiles = remote_host.getPlaylist()
            player_props = remote_host.playingProperties(playerid)

            local_host = XbmcHost('Local', '127.0.0.1', '80', '', '')

            #send the playerid so we add to the right playlist
            local_host.addItems(playingFiles, playerid)
            local_host.playPosition(selectedItem, playerid)

            #give it a second to catch up
            xbmc.sleep(1000)
            local_host.seekFile(player_props['percentage'], playerid)

        elif (action == 3):
            #just stop the playing media on this machine
            remote_host.stop()
            xbmc.executebuiltin('Container.Refresh')
コード例 #44
0
    def showNotify(self,displayToScreen = True):
        #go through and find the next schedule to run
        next_run_time = CronSchedule()
        for cronJob in self.schedules:
            if(cronJob.next_run < next_run_time.next_run or next_run_time.next_run == 0):
                next_run_time = cronJob

        inWords = self.nextRunCountdown(next_run_time.next_run)
        #show the notification (if applicable)
        if(next_run_time.next_run > time.time() and utils.getSetting('notify_next_run') == 'true' and displayToScreen == True):
            utils.showNotification(utils.getString(30000),next_run_time.name + " - " + inWords)
                                   
        return inWords    
コード例 #45
0
    def showNotify(self,displayToScreen = True):
        #go through and find the next schedule to run
        next_run_time = CronSchedule()
        for cronJob in self.schedules:
            if(cronJob.next_run < next_run_time.next_run or next_run_time.next_run == 0):
                next_run_time = cronJob

        inWords = self.nextRunCountdown(next_run_time.next_run)
        #show the notification (if applicable)
        if(next_run_time.next_run > time.time() and utils.getSetting('notify_next_run') == 'true' and displayToScreen == True):
            utils.showNotification(utils.getString(30000),next_run_time.name + " - " + inWords)
                                   
        return inWords    
コード例 #46
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
コード例 #47
0
    def addHost(self):
        name = None
        address = None
        port = None
        user = None
        password = None

        #get the name, address, and port
        name = xbmcgui.Dialog().input(utils.getString(30027), '',
                                      xbmcgui.INPUT_ALPHANUM)
        address = xbmcgui.Dialog().input(utils.getString(30028), '',
                                         xbmcgui.INPUT_IPADDRESS)
        port = xbmcgui.Dialog().input(utils.getString(30029), '',
                                      xbmcgui.INPUT_NUMERIC)
        user = xbmcgui.Dialog().input(utils.getString(30042), '',
                                      xbmcgui.INPUT_ALPHANUM)
        password = xbmcgui.Dialog().input(utils.getString(30043), '',
                                          xbmcgui.INPUT_ALPHANUM)

        if (name != None and address != None and port != None):
            aHost = XbmcHost(name, address, int(port), user, password)
            self.host_manager.addHost(aHost)
            xbmc.executebuiltin('Container.Refresh')
コード例 #48
0
def buildMakeMKVConCommand(profiledict):
    niceness = ''
    # 30013 == High, 30015 == Low
    if (profiledict['niceness'] == utils.getString(30013).lower() or
            profiledict['niceness'] == utils.getString(30015).lower()):
        if (platform.system() == 'Windows'):
            if (profiledict['niceness'] == utils.getStringLow(30013)):
                # If you pass quoted text to the Windows "start" command
                # as the first argument, it treats this as the name of the
                # program you want to run, not the command you want to run,
                # so I just add an empty set of double-quotes to prevent
                # issues.
                niceness = 'start /wait /b /high "" '
            else:
                niceness = 'start /wait /b /low "" '
        else:
            if (profiledict['niceness'] == utils.getStringLow(30013)):
                niceness = 'nice -n -19 '
            else:
                niceness = 'nice -n 19 '
    if profiledict['enablecustomripcommand'] == 'true':
        command = '{niceness} {customripcommand}'.format(niceness = niceness,
                customripcommand = profiledict['customripcommand'])
    else:
        mintitlelength = str(int(profiledict['mintitlelength']) * 60)

        command = ('{niceness} "{makemkvpath}" mkv --decrypt disc:{driveid} '
                'all --minlength={mintitlelength} "{tempfolder}"'.format(
                niceness = niceness,
                makemkvpath = profiledict['makemkvpath'],
                driveid = profiledict['driveid'],
                mintitlelength = mintitlelength,
                # MakeMKV will add a forward slash at the end of a folder if it
                # has a backslash. This is bad for Windows, so we strip the
                # trailing slash.
                tempfolder = profiledict['tempfolder'].rstrip('\\')))
    return command
コード例 #49
0
def buildMakeMKVConCommand(profiledict):
    niceness = ''
    # 30013 == High, 30015 == Low
    if (profiledict['niceness'] == utils.getString(30013).lower() or
            profiledict['niceness'] == utils.getString(30015).lower()):
        if (platform.system() == 'Windows'):
            if (profiledict['niceness'] == utils.getStringLow(30013)):
                # If you pass quoted text to the Windows "start" command
                # as the first argument, it treats this as the name of the
                # program you want to run, not the command you want to run,
                # so I just add an empty set of double-quotes to prevent
                # issues.
                niceness = 'start /wait /b /high "" '
            else:
                niceness = 'start /wait /b /low "" '
        else:
            if (profiledict['niceness'] == utils.getStringLow(30013)):
                niceness = 'nice -n -19 '
            else:
                niceness = 'nice -n 19 '
    if profiledict['enablecustomripcommand'] == 'true':
        command = '{niceness} {customripcommand}'.format(niceness = niceness,
                customripcommand = profiledict['customripcommand'])
    else:
        mintitlelength = str(int(profiledict['mintitlelength']) * 60)

        command = ('{niceness} "{makemkvpath}" mkv --decrypt disc:{driveid} '
                'all --minlength={mintitlelength} "{tempfolder}"'.format(
                niceness = niceness,
                makemkvpath = profiledict['makemkvpath'],
                driveid = profiledict['driveid'],
                mintitlelength = mintitlelength,
                # MakeMKV will add a forward slash at the end of a folder if it
                # has a backslash. This is bad for Windows, so we strip the
                # trailing slash.
                tempfolder = profiledict['tempfolder'].rstrip('\\')))
    return command
コード例 #50
0
ファイル: scheduler.py プロジェクト: elephunk84/KodiRepo
    def findNextRun(self, now):
        #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.showNotification(
                utils.getString(30081) + " " + datetime.datetime.fromtimestamp(
                    self.next_run).strftime('%m-%d-%Y %H:%M'))
            utils.log("scheduler will run again on " +
                      datetime.datetime.fromtimestamp(self.next_run).strftime(
                          '%m-%d-%Y %H:%M'))
コード例 #51
0
ファイル: scheduler.py プロジェクト: robweber/xbmcbackup
    def findNextRun(self,now):
        progress_mode = int(utils.getSetting('progress_mode'))
        
        #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'))

            #write the next time to a file
            fh = xbmcvfs.File(self.next_run_path, 'w')
            fh.write(str(self.next_run))
            fh.close()

            #only show when not in silent mode
            if(progress_mode != 2):                        
                utils.showNotification(utils.getString(30081) + " " + datetime.datetime.fromtimestamp(self.next_run).strftime('%m-%d-%Y %H:%M'))
コード例 #52
0
ファイル: default.py プロジェクト: NEOhidra/xbmcbackup
import resources.lib.utils as utils
from resources.lib.backup import XbmcBackup

#the program mode
mode = -1

#check if mode was passed in as an argument
if(len(sys.argv) > 1):
    if(sys.argv[1].lower() == 'backup'):
        mode = 0
    elif(sys.argv[1].lower() == 'restore'):
        mode = 1

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

if(mode != -1):
    #run the profile backup
    backup = XbmcBackup()

    if(backup.remoteConfigured()):

        if(mode == backup.Restore):
            #allow user to select the backup to restore from
            restorePoints = backup.listBackups()
            pointNames = []

            for aDir in restorePoints:
                pointNames.append(aDir[1])
                
コード例 #53
0
ファイル: default.py プロジェクト: mmogul/mediamogul.co.uk
            pointNames = []
            folderNames = []
            
            for aDir in restorePoints:
                pointNames.append(aDir[1])
                folderNames.append(aDir[0])

            selectedRestore = -1

            if("archive" in params):
                #check that the user give archive exists
                if(params['archive'] in folderNames):
                    #set the index
                    selectedRestore = folderNames.index(params['archive'])
                    utils.log(str(selectedRestore) + " : " + params['archive'])
                else:
                    utils.showNotification(utils.getString(30045))
                    utils.log(params['archive'] + ' is not a valid restore point')
            else:
                #allow user to select the backup to restore from
                selectedRestore = xbmcgui.Dialog().select(utils.getString(30010) + " - " + utils.getString(30021),pointNames)

            if(selectedRestore != -1):
                backup.selectRestore(restorePoints[selectedRestore][0])
                    
        backup.run(mode)
    else:
        #can't go any further
        xbmcgui.Dialog().ok(utils.getString(30010),utils.getString(30045))
        utils.openSettings()
コード例 #54
0
ファイル: manual.py プロジェクト: noba3/KoTos
import xbmcgui
import resources.lib.utils as utils
from service import AutoUpdater

autoUpdate = AutoUpdater()
runUpdate = False

if(utils.getSetting('disable_manual_prompt') == 'false'):
    nextRun = autoUpdate.showNotify(False)
    #check if we should run updates
    runUpdate = xbmcgui.Dialog().yesno(utils.getString(30000),utils.getString(30060) + nextRun,line2=utils.getString(30061),autoclose=6000)
else:
    #the user has elected to skip the prompt
    runUpdate = True

if(runUpdate):
    #run the program
    utils.log("Update Library Manual Run...")

    #trick the auto updater into resetting the last_run time
    autoUpdate.last_run = 0
    autoUpdate.writeLastRun()

    #update the schedules and evaluate them
    autoUpdate.createSchedules(True)
    autoUpdate.evalSchedules()

    #delete the monitor before exiting
    del autoUpdate.monitor
コード例 #55
0
ファイル: disclaimer.py プロジェクト: noba3/KoTos
import xbmcgui
import resources.lib.utils as utils

# show the disclaimer
xbmcgui.Dialog().ok(utils.getString(30031), "", utils.getString(30032), utils.getString(30033))
コード例 #56
0
    def createSchedules(self,forceUpdate = False):
        utils.log("update timers")
        self.lock = True   #lock so the eval portion does not run
        self.schedules = []
            
        if(utils.getSetting('clean_libraries') == 'true'):
            #create clean schedule (if needed)
            if(int(utils.getSetting("clean_timer")) != 0):
                    
                if(utils.getSetting('library_to_clean') == '0' or utils.getSetting('library_to_clean') == '1'):
                    #video clean schedule starts at 12am by default
                    aSchedule = CronSchedule()
                    aSchedule.name = utils.getString(30048)
                    aSchedule.timer_type = utils.__addon_id__
                    aSchedule.command = 'video'
                    if(int(utils.getSetting("clean_timer")) == 4):
                        aSchedule.expression = utils.getSetting("clean_video_cron_expression")
                    else:
                        aSchedule.expression = "0 0 " + aSchedule.cleanLibrarySchedule(int(utils.getSetting("clean_timer")))
                    aSchedule.next_run = self.calcNextRun(aSchedule.expression,time.time())

                    self.schedules.append(aSchedule)
                        
                if(utils.getSetting('library_to_clean') == '2' or utils.getSetting('library_to_clean') == '0'):
                    #music clean schedule starts at 2am by default
                    aSchedule = CronSchedule()
                    aSchedule.name = utils.getString(30049)
                    aSchedule.timer_type = utils.__addon_id__
                    aSchedule.command = 'music'
                    if(int(utils.getSetting("clean_timer")) == 4):
                        aSchedule.expression = utils.getSetting("clean_music_cron_expression")
                    else:
                        aSchedule.expression = "0 2 " + aSchedule.cleanLibrarySchedule(int(utils.getSetting("clean_timer")))
                    aSchedule.next_run = self.calcNextRun(aSchedule.expression,time.time())
    
                    self.schedules.append(aSchedule)
                                                                                

        if(utils.getSetting('update_video') == 'true'):
            utils.log("Creating timer for Video Library");
            #create the video schedule
            aSchedule = CronSchedule()
            aSchedule.name = utils.getString(30012)
            aSchedule.command = 'UpdateLibrary(video)'
            aSchedule.expression = self.checkTimer('video')
            aSchedule.next_run = self.calcNextRun(aSchedule.expression,self.last_run)
                
            self.schedules.append(aSchedule)

        if(utils.getSetting('update_music') == 'true'):
            utils.log("Creating timer for Music Library");
            #create the music schedule
            aSchedule = CronSchedule()
            aSchedule.name = utils.getString(30013)
            aSchedule.command = 'UpdateLibrary(music)'
            aSchedule.expression = self.checkTimer('music')
            aSchedule.next_run = self.calcNextRun(aSchedule.expression,self.last_run)
                
            self.schedules.append(aSchedule)

        if(utils.getSetting('use_custom_1_path') == 'true'):
            utils.log("Creating timer for Custom Path 1");
            #create a custom video path schedule
            aSchedule = CronSchedule()
            aSchedule.name = utils.getString(30020)
            aSchedule.command = 'UpdateLibrary(video,' + utils.getSetting('custom_1_scan_path') + ')'
            aSchedule.expression = self.checkTimer('custom_1')
            aSchedule.next_run = self.calcNextRun(aSchedule.expression,self.last_run)
                
            self.schedules.append(aSchedule)

        if(utils.getSetting('use_custom_2_path') == 'true'):
            utils.log("Creating timer for Custom Path 2");
            #create a custom video path schedule
            aSchedule = CronSchedule()
            aSchedule.name = utils.getString(30021)
            aSchedule.command = 'UpdateLibrary(video,' + utils.getSetting('custom_2_scan_path') + ')'
            aSchedule.expression = self.checkTimer('custom_2')
            aSchedule.next_run = self.calcNextRun(aSchedule.expression,self.last_run)
                
            self.schedules.append(aSchedule)

        if(utils.getSetting('use_custom_3_path') == 'true'):
            utils.log("Creating timer for Custom Path 3");
            #create a custom video path schedule
            aSchedule = CronSchedule()
            aSchedule.name = utils.getString(30022)
            aSchedule.command = 'UpdateLibrary(video,' + utils.getSetting('custom_3_scan_path') + ')'
            aSchedule.expression = self.checkTimer('custom_3')
            aSchedule.next_run = self.calcNextRun(aSchedule.expression,self.last_run)
                
            self.schedules.append(aSchedule)

        #release the lock
        self.lock = False
        
        #show any notifications
        self.showNotify(not forceUpdate)
コード例 #57
0
ファイル: manual.py プロジェクト: 1c0n/xbmclibraryautoupdate
import xbmcgui
import resources.lib.utils as utils
from service import AutoUpdater

autoUpdate = AutoUpdater()

nextRun = autoUpdate.showNotify(False)
#check if we should run updates
runUpdate = xbmcgui.Dialog().yesno(utils.getString(30000),utils.getString(30060) + nextRun,utils.getString(30061))

if(runUpdate):
    #run the program
    utils.log("Update Library Manual Run...")

    #trick the auto updater into resetting the last_run time
    autoUpdate.last_run = 0
    autoUpdate.writeLastRun()

    #update the schedules and evaluate them
    autoUpdate.createSchedules(True)
    autoUpdate.evalSchedules()
コード例 #58
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