本文整理汇总了Python中resources.lib.utils.getSetting函数的典型用法代码示例。如果您正苦于以下问题:Python getSetting函数的具体用法?Python getSetting怎么用?Python getSetting使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getSetting函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: start
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
示例2: start
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)
示例3: __init__
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()
示例4: cleanLibrary
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()
示例5: runProgram
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
#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
示例6: onStart
def onStart(self):
#check if Xbian is upgrading
if os.path.isfile('/var/lock/.upgrades') :
if xbianConfig('updates','progress')[0] == '1':
dlg = dialogWait('XBian Update','Please wait while updating')
dlg.show()
while not self.StopRequested and xbianConfig('updates','progress')[0] == '1':
xbmc.sleep(2000)
dlg.close()
if self.StopRequested :
return
xbmc.executebuiltin("Notification(%s,%s)"%('XBian Upgrade','XBian was updated successfully'))
os.remove('/var/lock/.upgrades')
#check is packages is updating
if os.path.isfile('/var/lock/.packages') :
if xbianConfig('updates','progress')[0] == '1':
dlg = dialogWait('XBian Update','Please wait while updating')
dlg.show()
while not self.StopRequested and xbianConfig('updates','progress')[0] == '1':
xbmc.sleep(2000)
dlg.close()
if self.StopRequested :
return
xbmc.executebuiltin("Notification(%s,%s)"%('Package Update','Package was updated successfully'))
os.remove('/var/lock/.packages')
#for those one who deactivate its screensaver, force check every 10 days
if getSetting('lastupdatecheck') != None and getSetting('lastupdatecheck') < datetime.now() - timedelta(days=10):
self.onScreensaverActivated()
self.onScreensaverDeactivated()
while not self.StopRequested: #End if XBMC closes
xbmc.sleep(100) #Repeat (ms)
示例7: settingsChanged
def settingsChanged(self):
utils.log("Settings changed - update")
old_settings = utils.refreshAddon()
current_enabled = utils.getSetting("enable_scheduler")
install_keyboard_file = utils.getSetting("install_keyboard_file")
if install_keyboard_file == 'true':
self.installKeyboardFile()
utils.setSetting('install_keyboard_file', 'false')
# Return since this is going to be run immediately again
return
# Update m3u file if wanted groups has changed
old_groups = self.groups
self.updateGroups()
if self.groups != old_groups or old_settings.getSetting("username") != utils.getSetting("username") or old_settings.getSetting("password") != utils.getSetting("password") or old_settings.getSetting("mergem3u_fn") != utils.getSetting("merge3mu_fn") or old_settings.getSetting("mergem3u") != utils.getSetting("mergem3u"):
self.update_m3u = True
if old_settings.getSetting("timezone") != utils.getSetting("timezone"):
if self.pvriptvsimple_addon:
utils.log("Changing offset")
self.checkAndUpdatePVRIPTVSetting("epgTimeShift", utils.getSetting("timezone"))
if(self.enabled == "true"):
#always recheck the next run time after an update
utils.log('recalculate start time , after settings update')
self.findNextRun(time.time())
示例8: start
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)
示例9: parseSchedule
def parseSchedule(self):
schedule_type = int(utils.getSetting("schedule_interval"))
cron_exp = utils.getSetting("cron_schedule")
if self.schedule_time:
hour, minute = self.schedule_time.split(':')
hour = int(hour)
minute = int(minute)
cron_exp = str(minute) + ' ' + str(hour) + ' * * *'
return cron_exp
示例10: evalSchedules
def evalSchedules(self):
if not self.lock:
now = time.time()
count = 0
tempLastRun = self.last_run
while count < len(self.schedules):
cronJob = self.schedules[count]
if cronJob.next_run <= now:
if xbmc.Player().isPlaying() == False or utils.getSetting("run_during_playback") == "true":
if utils.getSetting("run_on_idle") == "false" or (
utils.getSetting("run_on_idle") == "true" and self.monitor.screensaver_running
):
# check for valid network connection
if self._networkUp():
# check if this scan was delayed due to playback
if cronJob.on_delay == True:
# add another minute to the delay
self.schedules[count].next_run = now + 60
self.schedules[count].on_delay = False
utils.log(cronJob.name + " paused due to playback")
elif self.scanRunning() == False:
# run the command for this job
utils.log(cronJob.name)
if cronJob.timer_type == "xbmc":
xbmc.executebuiltin(cronJob.command)
else:
self.cleanLibrary(cronJob.command)
# find the next run time
cronJob.next_run = self.calcNextRun(cronJob.expression, now)
self.schedules[count] = cronJob
elif self.scanRunning() == True:
self.schedules[count].on_delay = True
utils.log("Waiting for other scan to finish")
else:
utils.log("Network down, not running")
else:
utils.log("Skipping scan, only run when idle")
else:
self.schedules[count].on_delay = True
utils.log("Player is running, wait until finished")
count = count + 1
# write last run time
now = time.time()
self.last_run = now - (now % 60)
示例11: checkTimer
def checkTimer(self,settingName):
result = ''
#figure out if using standard or advanced timer
if(utils.getSetting(settingName + '_advanced_timer') == 'true'):
#copy the expression
result = utils.getSetting(settingName + "_cron_expression")
else:
result = '0 */' + str(self.timer_amounts[utils.getSetting(settingName + "_timer")]) + ' * * *'
return result
示例12: checkTimer
def checkTimer(self, settingName):
result = ""
# figure out if using standard or advanced timer
if utils.getSetting(settingName + "_advanced_timer") == "true":
# copy the expression
result = utils.getSetting(settingName + "_cron_expression")
else:
result = "0 */" + str(self.timer_amounts[utils.getSetting(settingName + "_timer")]) + " * * *"
return result
示例13: start
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
示例14: playStarted
def playStarted(self):
if(self.playerMonitor.isPlayingVideo() and utils.getSetting('monitor_video') == 'true'):
videoTag = self.playerMonitor.getVideoInfoTag()
utils.log("Logging: " + videoTag.getTitle(),xbmc.LOGDEBUG)
self.historyDB.insert(("video",videoTag.getTitle(),self.playerMonitor.getPlayingFile(),int(time.time())))
elif(self.playerMonitor.isPlayingAudio() and utils.getSetting('monitor_music') == 'true'):
audioTag = self.playerMonitor.getMusicInfoTag()
utils.log("Logging: " + audioTag.getTitle(),xbmc.LOGDEBUG)
self.historyDB.insert(('audio',audioTag.getTitle(),self.playerMonitor.getPlayingFile(),int(time.time())))
示例15: onScreensaverActivated
def onScreensaverActivated(self):
print 'screensaver activated'
if not xbmc.Player().isPlaying() and (getSetting('lastupdatecheck') == None or getSetting('lastupdatecheck') < datetime.now() - timedelta(days=1)):
print 'XBian : Checking for update'
#check if new upgrade avalaible
rc =xbianConfig('updates','list','upgrades')
if rc and rc[0] == '-3' :
rctmp = xbianConfig('updates','updatedb')
if rctmp and rctmp[0] == '1' :
rc =xbianConfig('updates','list','upgrades')
else :
rc[0]= '0'
if rc and rc[0] not in ('0','-2') :
retval = rc[0].split(';')
self.xbianUpdate = retval[3]
#check if new update package avalaible
rc =xbianConfig('updates','list','packages')
if rc and rc[0] == '-3' :
rctmp = xbianConfig('updates','updatedb')
if rctmp and rctmp[0] == '1' :
rc =xbianConfig('updates','list','packages')
else :
rc[0]= '0'
if rc and rc[0] not in ('0','-2') :
self.packageUpdate = True
setSetting('lastupdatecheck',datetime.now())