本文整理汇总了Python中xbmc.getGlobalIdleTime函数的典型用法代码示例。如果您正苦于以下问题:Python getGlobalIdleTime函数的具体用法?Python getGlobalIdleTime怎么用?Python getGlobalIdleTime使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getGlobalIdleTime函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: check_update_conditions
def check_update_conditions(self, connection_only=False):
''' Checks the users update conditions are met.
Checks for:
- active player
- idle time
- internet connectivity
connection_only, limits the check to just the internet connection
'''
if not connection_only:
result_raw = xbmc.executeJSONRPC('{ "jsonrpc": "2.0", "method": "Player.GetActivePlayers", "id": 1 }')
result = json.loads(result_raw)
log(result, 'result of Player.GetActivePlayers')
players = result.get('result', False)
if players:
log('Update CONDITION : player playing')
return False, 'Update CONDITION : player playing'
idle = xbmc.getGlobalIdleTime()
if self.s['update_on_idle'] and idle < 60:
msg = 'Update CONDITION : idle time = %s' % idle
return False, 'Update CONDITION : idle time = %s' % idle
return True, ''
示例2: main
def main():
# xbmc.log('3D> main()', xbmc.LOGNOTICE)
global dialog, dialogprogress, responseMap, settings, monitor
dialog = xbmcgui.Dialog()
dialogprogress = xbmcgui.DialogProgress()
settings = Settings()
monitor = MyMonitor()
# xbmc.log('3D> opening serial port', xbmc.LOGNOTICE)
# def get_port_ensured(self):
# ser = None
# while ser == None:
# try:
# ser = self.get_port()
# except serial.serialutil.SerialException:
# time.sleep(0.07)
# return ser
#settings.TVport = serial.Serial(0, 9600, timeout=1) # open first serial port
settings.TVport = serial.Serial(settings.TVserialport, 9600, timeout=1) # open first serial port
# xbmc.log('3D> ' + settings.TVport.portstr, xbmc.LOGNOTICE) # check which port was really used
while not xbmc.abortRequested:
if not settings.inScreensaver:
settings.pollCount += 1
if xbmc.getGlobalIdleTime() <= settings.idlesec:
if settings.pollCount > settings.pollsec:
mainTrigger()
settings.pollCount = 0
continue
xbmc.sleep(1000)
onAbort()
# xbmc.log('3D> closing serial port', xbmc.LOGNOTICE)
settings.TVport.close() # close port
示例3: CheckIdle
def CheckIdle(maxIdle):
if maxIdle == 0:
return
idle = xbmc.getGlobalIdleTime()
if idle < maxIdle:
return
delay = 60
count = delay
dp = xbmcgui.DialogProgress()
dp.create("OnTappTV","Streaming will automatically quit in %d seconds" % count, "Press Cancel to contine viewing")
dp.update(0)
while xbmc.Player().isPlaying() and count > 0 and not dp.iscanceled():
xbmc.sleep(1000)
count -= 1
perc = int(((delay - count) / float(delay)) * 100)
if count > 1:
dp.update(perc,"Streaming will automatically quit in %d seconds" % count, "Press Cancel to contine viewing")
else:
dp.update(perc,"Streaming will automatically quit in %d second" % count, "Press Cancel to contine viewing")
if not dp.iscanceled():
xbmc.Player().stop()
示例4: check_update_conditions
def check_update_conditions(self, media_only=False):
''' Checks the users update conditions are met. The media-only flag restricts the condition check to
only the media playing condition. '''
result_raw = xbmc.executeJSONRPC('{ "jsonrpc": "2.0", "method": "Player.GetActivePlayers", "id": 1 }')
result = json.loads(result_raw)
log(result, 'result of Player.GetActivePlayers')
players = result.get('result', False)
if players:
log('Update CONDITION : player playing')
return False, 'Update CONDITION : player playing'
idle = xbmc.getGlobalIdleTime()
if self.s['update_on_idle'] and idle < 60 and not media_only:
msg = 'Update CONDITION : idle time = %s' % idle
return False, 'Update CONDITION : idle time = %s' % idle
return True, ''
示例5: _checkIdle
def _checkIdle(self):
if self.doidle is False:
return
XBMCit = xbmc.getGlobalIdleTime()
if self.player.isPlaying():
self._playeridle = False
self._startidle = XBMCit
else: # player is not playing
if self._playeridle is False: # if the first pass with player idle, start timing here
self._playeridle = True
self._startidle = XBMCit
myit = XBMCit - self._startidle # amount of time idle and not playing
for it in self.idleTs:
if myit > it[0]: # if time exceeded idle timer
if it[2] is False: # idle task has NOT been executed
msg = Message(Topic("onIdle", it[1]))
self.publish(msg)
it[2] = True
else: # if time has not exceeded timer
it[2] = False # reset task executed flag
for it in self.afterIdles:
if myit > it[0]: # time has exceeded timer
it[2] = True # set flag that task needs to be executed when exiting idle
else: # time has not exceeded idle timer
if it[2] is True: # if flag to execute has been set
msg = Message(Topic("afterIdle", it[1]))
self.publish(msg)
it[2] = False # reset flag to execute
示例6: isIdle
def isIdle(self, since=1):
try:
if xbmc.getGlobalIdleTime() >= since:
return True
return False
except:
return False
示例7: check_run_conditions
def check_run_conditions(self):
# Update in case things have changed since last check
self.gamerTag = ADDON.getSetting("gamertag")
self.idle_timeout = ADDON.getSetting("idle_timeout")
# Is monitoring enabled?
if ADDON.getSetting("enable") == "false":
xbmc.log("XBLFriends: Monitoring disabled")
return False
# Do we have a gamerTag set?
if not self.gamerTag:
xbmc.log("XBLFriends: No gamerTag set")
return False
# Are we still under the rate limit?
if int(self.current_rate) > int(self.rate_limit):
xbmc.log("XBLFriends: Rate limit exceeded. Limit: %s Current: %s" % (self.rate_limit, self.current_rate))
return False
if xbmc.getGlobalIdleTime() > self.idle_timeout:
xbmc.log(
"XBLFriends: XBMC is idle. Not fetching data. idle_timeout: %s" % self.idle_timeout, level=xbmc.LOGDEBUG
)
return False
return True
示例8: conditions_met
def conditions_met(self):
curr_time = datetime.datetime.now()
current_idle = divmod(int(xbmc.getGlobalIdleTime()), 60)[0]
threshold = int(float(__addon__.getSetting('threshold')))
# Have we been idle long enough?
if current_idle < threshold:
return False
# Are we already playing something?
if self.isPlaying():
return False
# Has it been long enough since something stopped playing?
time_since_stop = curr_time - self.last_stopped
if time_since_stop < datetime.timedelta(minutes=threshold):
return False
# Are we supposed to always play?
if __addon__.getSetting('always_active') == 'true':
return True
# Are we supposed to play at this time of day?
start_hr = int(__addon__.getSetting('start_hr'))
start_min = int(__addon__.getSetting('start_min'))
if curr_time.time() > datetime.time(start_hr, start_min):
stop_hr = int(__addon__.getSetting('stop_hr'))
stop_min = int(__addon__.getSetting('stop_min'))
if curr_time.time() < datetime.time(stop_hr, stop_min):
return True
return False
示例9: process
def process(self):
if not self.use_idle_timer:
# skip all, go to sleep
pass
elif xbmc.Player().isPlaying():
# while playing media we reset the check_time to prevent that we're being
# logged out immediately after playing stops
self.check_time = time.time()
elif xbmc.getGlobalIdleTime() == 0:
# user activity so we reset the check_time to 'now'
self.check_time = time.time()
elif (time.time() - self.check_time) > self.max_idle_time and xbmc.getInfoLabel('System.ProfileName') != self.autologin_profile:
idle_time = time.time() - self.check_time
# set check_time to 1/1/2030 so we only swap profiles / perform logout once
# until the user comes back
self.check_time = CHECK_TIME_DISABLED
# Activate window to disable the screensaver
if self.screensaverActivated:
xbmc.executebuiltin("XBMC.ActivateWindow(home)")
active_profile = xbmc.getInfoLabel('System.ProfileName')
if self.use_login_screen:
log("System idle for %d seconds; logging %s out." % (idle_time, active_profile))
xbmc.executebuiltin('System.LogOff')
elif xbmc.getInfoLabel('System.ProfileName') != self.autologin_profile:
log("System idle for %d seconds; switching from %s to auto login profile %s" % (idle_time, active_profile, self.autologin_profile))
xbmc.executebuiltin("XBMC.LoadProfile(" + self.autologin_profile + ", prompt)")
示例10: __init__
def __init__(self):
idleTime = 0
isIdle = False
while (not xbmc.abortRequested):
timeout = int(addon.getSetting('on__idle_time_min')) * 60
# check for user activity and reset timer
if xbmc.getGlobalIdleTime() <= 5: # returns the elapsed idle time in seconds as an integer
idleTime = 0
IdleActions.OneAfterTimeout = False
if isIdle:
# reset random/repeat for onidle
if addon.getSetting('on__action') == 'PlayMedia':
if addon.getSetting('on__random_playmedia') == 'true':
xbmc.executebuiltin('PlayerControl(RandomOff)')
if addon.getSetting('on__repeatall_playmedia') == 'true':
xbmc.executebuiltin('PlayerControl(RepeatOff)')
if addon.getSetting('after__after_idle_action_enabled') == 'true':
self.afterIdle()
isIdle = False
if idleTime > timeout:
if addon.getSetting('on__service_enabled') == 'true':
if not xbmc.Player().isPlaying():
isIdle = True
actiontype = addon.getSetting('on__action_type')
if actiontype == 'one per startup':
if not IdleActions.OnePerStartup:
IdleActions.OnePerStartup = True
self.onIdle()
if actiontype == 'one after timeout':
if not IdleActions.OneAfterTimeout:
IdleActions.OneAfterTimeout = True
self.onIdle()
if actiontype == 'repeat with timeout':
idleTime = 0
self.onIdle()
if actiontype == 'one per second after timeout':
self.onIdle()
# reset idleTime if something is played by the user
if xbmc.Player().isPlaying():
idleTime = 0
else:
idleTime = idleTime + 1
xbmc.sleep(1000)
示例11: isTimout
def isTimout():
screensaverTime = Settings.loadScreensaverSettings()
if screensaverTime == -1:
return False
# It is a timeout if the idle time is larger that the time stored
# for when the screensaver is due to kick in
if (xbmc.getGlobalIdleTime() > screensaverTime):
log("Settings: Stopping due to screensaver")
return True
else:
return False
示例12: _is_idle
def _is_idle(self):
if self.nx_common.get_setting('wait_idle') != 'true':
return True
lastidle = xbmc.getGlobalIdleTime()
if xbmc.Player().isPlaying():
self.startidle = lastidle
if lastidle < self.startidle:
self.startidle = 0
idletime = lastidle - self.startidle
return idletime >= 300
示例13: postAddVideo
def postAddVideo(self, values=''):
# prevent go Kodi to suspend
if xbmc.getGlobalIdleTime() > 120:
xbmc.executeJSONRPC('{ "jsonrpc": "2.0", "method": "Input.ExecuteAction", "params": { "action": "noop" }, "id": 1 }')
url = self.setXBMC['RootURL'] + 'sync/movies'
debug.debug('[REQUEST]: ' + url)
debug.debug('[REQUEST]: ' + str(values))
# try send data
data = urllib.urlencode(values, True)
data_len = len(data)
debug.debug('[REQUEST DATA SIZE]: ' + str(data_len) + ' bytes')
for l in range(1, 4):
try:
request = urllib2.Request(url, data, headers = { 'token' : self.setXBMC['Token']})
result = urllib2.urlopen(request)
output = result.read()
except Exception as Error:
conn = False
debug.debug('Can\'t connect to: ' + url)
debug.debug('[REQUEST ERROR]: ' + str(Error))
if l < 3:
debug.debug('[REQUEST]: Wait 5 secs and retring ' + str(l))
time.sleep(15)
else:
conn = True
break;
if conn != True:
debug.notify(__lang__(32100).encode('utf-8'))
return False
debug.debug('[RESPONSE]: ' + str(output))
# if no values return json
if values == '':
try:
output = unicode(output, 'utf-8', errors='ignore')
output = json.loads(output)
except Exception as Error:
debug.debug('[GET JSON ERROR]: ' + str(Error))
return False
else:
#get errors
if len(output) > 0 and 'ERROR:' in output:
debug.notify(__lang__(32102).encode('utf-8'))
return False
return output
示例14: __init__
def __init__(self):
global ONE_PER_STARTUP_DONE
global ONE_AFTER_TIMEOUT_DONE
IDLE_TIME = 0
IS_IDLE = False
while (not xbmc.abortRequested):
TIMEOUT = int(addon.getSetting('on__idle_time_min'))*60
if xbmc.getGlobalIdleTime() <= 5:
IDLE_TIME = 0
ONE_AFTER_TIMEOUT_DONE = False
if IS_IDLE:
if addon.getSetting('after__after_idle_action_enabled') == 'true':
self.afterIDLE()
IS_IDLE = False
if IDLE_TIME > TIMEOUT:
if addon.getSetting('on__service_enabled') == 'true':
if not xbmc.Player().isPlaying():
IS_IDLE = True
actiontype = addon.getSetting('on__action_type')
if actiontype == 'one per startup':
if not ONE_PER_STARTUP_DONE:
ONE_PER_STARTUP_DONE = True
self.onIDLE()
if actiontype == 'one after timeout':
if not ONE_AFTER_TIMEOUT_DONE:
ONE_AFTER_TIMEOUT_DONE = True
self.onIDLE()
if actiontype == 'repeat with timeout':
IDLE_TIME = 0
self.onIDLE()
if actiontype == 'one per second after timeout':
self.onIDLE()
if xbmc.Player().isPlaying():
IDLE_TIME = 0
else:
IDLE_TIME = IDLE_TIME + 1
xbmc.sleep(1000)
示例15: _daemon
def _daemon(self):
while (not xbmc.abortRequested):
# Do nothing
global script_idle
if script_idle:
if xbmc.getGlobalIdleTime() > 60 * __addon__.getSetting("idle_time"):
log('XBMC is idle')
log('Going to execute script = "' + script_idle + '"')
try:
subprocess.call([script_idle, 'KODI_IDLE'])
except:
log('ERROR executing script when xbmc goes idle')
xbmc.sleep(4000)
log('abort requested')