本文整理汇总了Python中resources.lib.settings.Settings.getUserViewingLimit方法的典型用法代码示例。如果您正苦于以下问题:Python Settings.getUserViewingLimit方法的具体用法?Python Settings.getUserViewingLimit怎么用?Python Settings.getUserViewingLimit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类resources.lib.settings.Settings
的用法示例。
在下文中一共展示了Settings.getUserViewingLimit方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: check
# 需要导入模块: from resources.lib.settings import Settings [as 别名]
# 或者: from resources.lib.settings.Settings import getUserViewingLimit [as 别名]
def check(self):
# If we have found the correct user, then we need to ensure we are
# in the valid time duration and have not exceeded the limit
if not self.isEnabled:
return True
# Check for the case where we didn't get the user ID - this means we are
# already shutting down
if self.userId in [None, ""]:
return False
log("UserPinControl: Performing check for user %s" % self.userId)
# First check that the current time is within the allowed boundaries
localTime = time.localtime()
currentTime = (localTime.tm_hour * 60) + localTime.tm_min
if self.allowedStartTime > currentTime or self.allowedEndTime < currentTime:
log("UserPinControl: User not allowed access until %d to %d currently %d" % (self.allowedStartTime, self.allowedEndTime, currentTime))
self.shutdown(32130)
return False
# Check if the screensaver is running, if so we need to make sure we do not
# class that as time used by the user
if xbmc.getCondVisibility("System.ScreenSaverActive"):
if self.screensaverStart < 1:
self.screensaverStart = currentTime
else:
# Not the screensaver, check to see if this is the first check
# after the screensaver stopped
if self.screensaverStart > 0:
screensaverDuration = currentTime - self.screensaverStart
self.screensaverStart = 0
log("UserPinControl: Updating duration for screensaver, %d minutes" % screensaverDuration)
# Now we roll the time forward that we started viewing so that
# we are not counting the screensaver
self.startedViewing = self.startedViewing + screensaverDuration
# Check to see if we need to update the record for how long the user has already been viewing
viewingLimit = Settings.getUserViewingLimit(self.userId)
self.usedViewingLimit = currentTime - self.startedViewing
log("UserPinControl: Time used by user is %d" % self.usedViewingLimit)
# Update the settings record for how much this user has viewed so far
Settings.setUserViewingUsedTime(self.userId, self.usedViewingLimit)
# Now check to see if the user has exceeded their limit
if self.usedViewingLimit >= viewingLimit:
self.shutdown(32133)
return False
# Check if we need to warn the user that the time is running out
warningTime = Settings.getWarnExpiringTime()
if (not self.warningDisplayed) and ((self.usedViewingLimit + warningTime) >= viewingLimit):
self.warningDisplayed = True
# Calculate the time left
remainingTime = viewingLimit - self.usedViewingLimit
msg = "%d %s" % (remainingTime, ADDON.getLocalizedString(32134))
xbmcgui.Dialog().notification(ADDON.getLocalizedString(32001).encode('utf-8'), msg, ICON, 3000, False)
return True
示例2: displaySummary
# 需要导入模块: from resources.lib.settings import Settings [as 别名]
# 或者: from resources.lib.settings.Settings import getUserViewingLimit [as 别名]
def displaySummary(self):
# Load the settings for this user
allowedStartTime, displayStartTime = Settings.getUserStartTime(self.userId)
allowedEndTime, displayEndTime = Settings.getUserEndTime(self.userId)
viewingLimit = Settings.getUserViewingLimit(self.userId)
usersName = Settings.getUserName(self.userId)
# Work out how much time is remaining
displayRemainingTime = viewingLimit - self.usedViewingLimit
if displayRemainingTime < 0:
displayRemainingTime = 0
# Do a notification to let the user know how long they have left today
summaryUserName = "%s: %s" % (ADDON.getLocalizedString(32035), usersName)
summaryLimit = "%s: %d" % (ADDON.getLocalizedString(32033), viewingLimit)
summaryLimitRemaining = "%s: %d" % (ADDON.getLocalizedString(32131), displayRemainingTime)
summaryAccess = "%s: %s - %s" % (ADDON.getLocalizedString(32132), displayStartTime, displayEndTime)
fullSummary = "%s\n%s\n%s\n%s" % (summaryUserName, summaryLimit, summaryLimitRemaining, summaryAccess)
xbmcgui.Dialog().ok(ADDON.getLocalizedString(32001).encode('utf-8'), fullSummary)