本文整理汇总了Python中resources.lib.settings.log函数的典型用法代码示例。如果您正苦于以下问题:Python log函数的具体用法?Python log怎么用?Python log使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了log函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _updatePlaylistForSettings
def _updatePlaylistForSettings(self, playlist):
if playlist.size() < 1:
return playlist
filename = playlist[0].getfilename()
duration = self._getVideoDuration(filename)
log("Duration is %d for file %s" % (duration, filename))
startTime = 0
# Check if we have a random start time
if Settings.isRandomStart():
startTime = random.randint(0, int(duration * 0.75))
clockStart = Settings.getTimeForClock(filename, duration)
if clockStart > 0:
startTime = clockStart
# Set the random start
if (startTime > 0) and (duration > 10):
listitem = xbmcgui.ListItem()
# Record if the theme should start playing part-way through
listitem.setProperty('StartOffset', str(startTime))
log("Setting start of %d for %s" % (startTime, filename))
# Remove the old item from the playlist
playlist.remove(filename)
# Add the new item at the start of the list
playlist.add(filename, listitem, 0)
return playlist
示例2: check
def check(self):
# Check to see if we should be changing the video for the schedule
scheduleEntry = self.scheduler.getScheduleEntry()
# There is an item scheduled, so check to see if the item has actually changed
if scheduleEntry == self.currentScheduleItem:
return None
log("Old Schedule %d different from new: %d" % (self.currentScheduleItem, scheduleEntry))
# Check to see if there needs to be a change in what is playing
# This will also update the schedule item so we know what has been selected
newPlaylist = self._getPlaylist()
# If we reach here, there is a change of some sort
if newPlaylist is not None:
# Update the playlist with any settings such as random start time
self._updatePlaylistForSettings(newPlaylist)
# Start playing the new file, just override the existing one that is playing
self.player.play(newPlaylist)
# Also update the overlay
self._setOverlayImage()
# Now set the repeat option
self._setRepeat()
# Update any settings that need to be done after the video is playing
self._updatePostPlayingForSettings(newPlaylist)
示例3: _moveToThemeFolder
def _moveToThemeFolder(self, directory):
log("moveToThemeFolder: path = %s" % directory)
# Handle the case where we have a disk image
if (os_path_split(directory)[1] == 'VIDEO_TS') or (os_path_split(directory)[1] == 'BDMV'):
directory = os_path_split(directory)[0]
dirs, files = list_dir(directory)
for aFile in files:
m = re.search(Settings.getThemeFileRegEx(directory), aFile, re.IGNORECASE)
if m:
srcpath = os_path_join(directory, aFile)
log("fetchAllMissingThemes: Found match: %s" % srcpath)
targetpath = os_path_join(directory, Settings.getThemeDirectory())
# Make sure the theme directory exists
if not dir_exists(targetpath):
try:
xbmcvfs.mkdir(targetpath)
except:
log("fetchAllMissingThemes: Failed to create directory: %s" % targetpath, True, xbmc.LOGERROR)
break
else:
log("moveToThemeFolder: directory already exists %s" % targetpath)
# Add the filename to the path
targetpath = os_path_join(targetpath, aFile)
if not xbmcvfs.rename(srcpath, targetpath):
log("moveToThemeFolder: Failed to move file from %s to %s" % (srcpath, targetpath))
示例4: onInit
def onInit(self):
# Need to clear the list of the default items
self.clearList()
# Start by adding an option to Play All
if len(self.files) > 0:
anItem = xbmcgui.ListItem(ADDON.getLocalizedString(32101), path=SourceDetails.getFilenameAndPath())
# Get the first items fanart for the play all option
anItem.setProperty("Fanart_Image", self.files[0].getFanArt())
if SourceDetails.getTvShowTitle() != "":
anItem.setInfo('video', {'TvShowTitle': SourceDetails.getTvShowTitle()})
if SourceDetails.getTitle() != "":
anItem.setInfo('video', {'Title': SourceDetails.getTitle()})
self.addItem(anItem)
# Check if we want to have YouTube Extra Support
if Settings.isYouTubeSearchSupportEnabled():
# Create the message to the YouTube Plugin
li = xbmcgui.ListItem(ADDON.getLocalizedString(32116))
# Need to set the title to get it in the header
if SourceDetails.getTvShowTitle() != "":
li.setInfo('video', {'TvShowTitle': SourceDetails.getTvShowTitle()})
if SourceDetails.getTitle() != "":
li.setInfo('video', {'Title': SourceDetails.getTitle()})
li.setProperty("Fanart_Image", SourceDetails.getFanArt())
li.setProperty("search", "/search/?q=%s+Extras" % urllib.quote_plus(SourceDetails.getTitle().encode('utf8')))
self.addItem(li)
# Check if we want to have Vimeo Extra Support
if Settings.isVimeoSearchSupportEnabled():
# Create the message to the Vimeo Plugin
li = xbmcgui.ListItem(ADDON.getLocalizedString(32122))
# Need to set the title to get it in the header
if SourceDetails.getTvShowTitle() != "":
li.setInfo('video', {'TvShowTitle': SourceDetails.getTvShowTitle()})
if SourceDetails.getTitle() != "":
li.setInfo('video', {'Title': SourceDetails.getTitle()})
li.setProperty("Fanart_Image", SourceDetails.getFanArt())
li.setProperty("search", "/search/?q=%s+Extras" % urllib.quote_plus(SourceDetails.getTitle().encode('utf8')))
self.addItem(li)
for anExtra in self.files:
log("VideoExtrasWindow: filename: %s" % anExtra.getFilename())
# Create the list item
anItem = anExtra.createListItem(path=SourceDetails.getFilenameAndPath(), parentTitle=SourceDetails.getTitle(), tvShowTitle=SourceDetails.getTvShowTitle())
self.addItem(anItem)
# Before we return, set back the selected on screen item to the one just watched
# This is in the case of a reload
if self.lastRecordedListPosition > 0:
self.setCurrentListPosition(self.lastRecordedListPosition)
xbmcgui.WindowXML.onInit(self)
示例5: _setPluginList
def _setPluginList(self):
# Make the call to find out all the addons that are installed
json_query = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "Addons.GetAddons", "params": { "type": "xbmc.python.pluginsource", "enabled": true, "properties": ["name", "thumbnail", "fanart"] }, "id": 1}')
json_query = unicode(json_query, 'utf-8', errors='ignore')
json_response = simplejson.loads(json_query)
log(json_response)
plugins = []
if ("result" in json_response) and ('addons' in json_response['result']):
# Check each of the plugins that are installed on the system
for addonItem in json_response['result']['addons']:
addonId = addonItem['addonid']
# Need to skip ourselves
if addonId in ['script.pinsentry']:
log("setPluginList: Skipping PinSentry Plugin")
continue
pluginDetails = {}
pluginDetails['title'] = addonItem['name']
pluginDetails['dbid'] = addonId
if addonItem['thumbnail'] in [None, ""]:
pluginDetails['thumbnail'] = 'DefaultAddon.png'
else:
pluginDetails['thumbnail'] = addonItem['thumbnail']
if addonItem['fanart'] in [None, ""]:
pluginDetails['fanart'] = FANART
else:
pluginDetails['fanart'] = addonItem['fanart']
plugins.append(pluginDetails)
return plugins
示例6: _setRepositoryList
def _setRepositoryList(self):
# Make the call to find out all the addons that are installed
json_query = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "Addons.GetAddons", "params": { "type": "xbmc.addon.repository", "properties": ["name", "thumbnail", "fanart"] }, "id": 1}')
json_query = unicode(json_query, 'utf-8', errors='ignore')
json_response = simplejson.loads(json_query)
log(json_response)
repos = []
if ("result" in json_response) and ('addons' in json_response['result']):
# Check each of the repos that are installed on the system
for addonItem in json_response['result']['addons']:
addonId = addonItem['addonid']
pluginDetails = {}
pluginDetails['title'] = addonItem['name']
pluginDetails['dbid'] = addonId
if addonItem['thumbnail'] in [None, ""]:
pluginDetails['thumbnail'] = 'DefaultAddon.png'
else:
pluginDetails['thumbnail'] = addonItem['thumbnail']
if addonItem['fanart'] in [None, ""]:
pluginDetails['fanart'] = FANART
else:
pluginDetails['fanart'] = addonItem['fanart']
repos.append(pluginDetails)
return repos
示例7: _enableKeymap
def _enableKeymap(self):
try:
xbmcvfs.copy(self.KEYMAPSOURCEFILE, self.KEYMAPDESTFILE)
xbmc.executebuiltin('Action(reloadkeymaps)')
log("SonosVolumeRedirect: Installed custom keymap")
except:
log("SonosVolumeRedirect: Failed to copy & load custom keymap: %s" % traceback.format_exc(), xbmc.LOGERROR)
示例8: _addSecurityFlags
def _addSecurityFlags(self, type, items):
# Make sure we have some items to append the details to
if len(items) < 1:
return items
# Make the call to the DB to get all the specific security settings
pinDB = PinSentryDB()
securityDetails = {}
if type == MenuNavigator.TVSHOWS:
securityDetails = pinDB.getAllTvShowsSecurity()
elif type == MenuNavigator.MOVIES:
securityDetails = pinDB.getAllMoviesSecurity()
elif type == MenuNavigator.MOVIESETS:
securityDetails = pinDB.getAllMovieSetsSecurity()
elif type == MenuNavigator.MUSICVIDEOS:
securityDetails = pinDB.getAllMusicVideosSecurity()
elif type == MenuNavigator.PLUGINS:
securityDetails = pinDB.getAllPluginsSecurity()
elif type == MenuNavigator.FILESOURCE:
securityDetails = pinDB.getAllFileSourcesSecurity()
for item in items:
# Default security to 0 (Not Set)
securityLevel = 0
if item['title'] in securityDetails:
title = item['title']
securityLevel = securityDetails[title]
log("PinSentryPlugin: %s has security level %d" % (title, securityLevel))
item['securityLevel'] = securityLevel
del pinDB
return items
示例9: runArtistSlideshow
def runArtistSlideshow(self):
log("SonosArtistSlideshow: runArtistSlideshow")
# startup artistslideshow
xbmcgui.Window(self.windowId).setProperty("ArtistSlideshow.ExternalCall", "True")
# assumes addon is using suggested infolabel name of CURRENTARTIST and CURRENTTITLE
artistslideshow = "RunScript(script.artistslideshow,windowid=%s&artistfield=%s&titlefield=%s&albumfield=%s&mbidfield=%s)" % (xbmcgui.getCurrentWindowId(), "CURRENTARTIST", "CURRENTTITLE", "CURRENTALBUM", "CURRENTMBID")
xbmc.executebuiltin(artistslideshow)
示例10: _getAllFilesInDirectory
def _getAllFilesInDirectory(self, baseDir, includeSubDirs=True):
videoFiles = []
dirs, files = list_dir(baseDir)
# Get the list of files that are to be excluded
collectionCtrl = CollectSets()
disabledVideos = collectionCtrl.getDisabledVideos()
del collectionCtrl
# Get all the files in the current directory
for vidFile in files:
# Check if this file is excluded
if vidFile in disabledVideos:
log("Ignoring disabled screensaver video %s" % vidFile)
continue
fullPath = os_path_join(baseDir, vidFile)
videoFiles.append(fullPath)
# Now check each directory
if includeSubDirs and Settings.isFolderNested():
for aDir in dirs:
fullPath = os_path_join(baseDir, aDir)
dirContents = self._getAllFilesInDirectory(fullPath)
videoFiles = videoFiles + dirContents
return videoFiles
示例11: isClose
def isClose(self):
# Check if the base class has detected a need to close
needToClose = SonosControllerWindow.isClose(self)
# There are cases where the user could have changed the screen being
# displayed, for example, if they have the following in their keymap:
# <keymap>
# <global>
# <keyboard>
# <f5>ActivateWindow(0)</f5>
# </keyboard>
# </global>
# </keymap>
# This could cause a change in window, such as loading the home screen
# however we do not get a call to close - as the Sonos window will be
# still running in the back-ground - just not showing on the screen
# If the user then exits, the keymap file will be left, so we will
# automatically close the window in this case
# Note: This is not an issue with the normal controller - as it is a
# dialog window, so will always remain in view
if (not needToClose) and (self.windowId != -1):
# Get the current window
showingWindowId = xbmcgui.getCurrentWindowId()
# Check if the window is no longer showing
if showingWindowId != self.windowId:
log("SonosArtistSlideshow: Detected change in window, sonos window = %d, new window = %d" % (self.windowId, showingWindowId))
return True
return needToClose
示例12: removeCollection
def removeCollection(self, name, link):
if name in [None, ""]:
return
collectionCtrl = CollectSets()
collectionDetails = collectionCtrl.loadCollection(link)
filesToDelete = []
# If the file was not processed just don't display anything
if collectionDetails not in [None, ""]:
screensaverFolder = Settings.getScreensaverFolder()
for videoItem in collectionDetails['videos']:
# If theme exists we need to check if we want to delete it
if screensaverFolder not in [None, ""]:
videoLocation = os_path_join(screensaverFolder, videoItem['filename'])
log("VideoScreensaverPlugin: Checking if %s already downloaded to %s" % (videoItem['filename'], videoLocation))
if xbmcvfs.exists(videoLocation):
filesToDelete.append(videoLocation)
# If there are possible files to delete, then prompt the user to see if we should
if len(filesToDelete) > 0:
needDelete = xbmcgui.Dialog().yesno(ADDON.getLocalizedString(32005), ADDON.getLocalizedString(32086))
if needDelete:
for vidFile in filesToDelete:
xbmcvfs.delete(vidFile)
# Now remove the actual collection
collectionCtrl.removeCustomCollection(name)
del collectionCtrl
# Now reload the screen to reflect the change
xbmc.executebuiltin("Container.Refresh")
示例13: _getSecondsInTimeString
def _getSecondsInTimeString(self, fullTimeString):
# Some services do not support duration
if fullTimeString == 'NOT_IMPLEMENTED':
return -1
# Start by splitting the time into sections
hours = 0
minutes = 0
seconds = 0
try:
hours = int(fullTimeString.split(':', 1)[0])
minutes = int(fullTimeString.split(':')[1])
seconds = int(fullTimeString.split(':')[2])
except:
# time sections are not numbers
log("SonosControllerWindow: Exception Details: %s" % traceback.format_exc())
hours = 0
minutes = 0
seconds = 0
totalInSeconds = (((hours * 60) + minutes) * 60) + seconds
log("SonosControllerWindow: Time %s, splits into hours=%d, minutes=%d, seconds=%d, total=%d" % (fullTimeString, hours, minutes, seconds, totalInSeconds))
# Return the total time in seconds
return totalInSeconds
示例14: fetchTheme
def fetchTheme(self, title, path, originaltitle=None, isTvShow=None, year=None, imdb=None):
# If there is already a theme then start playing it
self._startPlayingExistingTheme(path)
if Settings.isThemeDirEnabled() and self._doesThemeExist(path, True):
# Prompt user if we should move themes in the parent
# directory into the theme directory
moveExistingThemes = xbmcgui.Dialog().yesno(ADDON.getLocalizedString(32105), ADDON.getLocalizedString(32206), ADDON.getLocalizedString(32207))
# Check if we need to move a theme file
if moveExistingThemes:
log("fetchAllMissingThemes: Moving theme for %s" % title)
self._moveToThemeFolder(path)
# Stop playing any theme that started
self._stopPlayingTheme()
# Now reload the screen to reflect the change
xbmc.executebuiltin("Container.Refresh")
return
if originaltitle is not None:
originaltitle = normalize_string(originaltitle)
# Perform the fetch
videoList = []
normtitle = normalize_string(title)
videoItem = {'title': normtitle, 'path': path, 'originalTitle': originaltitle, 'isTvShow': isTvShow, 'year': year, 'imdb': imdb}
videoList.append(videoItem)
TvTunesFetcher(videoList)
# Stop playing any theme that started
self._stopPlayingTheme()
# Now reload the screen to reflect the change
xbmc.executebuiltin("Container.Refresh")
示例15: editPlot
def editPlot(self, target, path, filename):
# Create the extras class that will be used to process the extras
videoExtras = VideoExtrasBase(path, target)
# Perform the search command
# We are only updating the NFO for an entry already shown, no need for fanart
files = videoExtras.findExtras()
del videoExtras
for anExtra in files:
if anExtra.isFilenameMatch(filename):
log("MenuNavigator: Found = %s" % filename)
# Prompt the user for the new name
keyboard = xbmc.Keyboard()
keyboard.setDefault(anExtra.getPlot())
keyboard.doModal()
if keyboard.isConfirmed():
try:
newplot = keyboard.getText().decode("utf-8")
except:
newplot = keyboard.getText()
# Only set the title if it has changed
if (newplot != anExtra.getPlot()) and ((len(newplot) > 0) or (anExtra.getPlot() is not None)):
isTv = (target == MenuNavigator.TVSHOWS)
result = anExtra.setPlot(newplot, isTV=isTv)
if not result:
xbmcgui.Dialog().ok(ADDON.getLocalizedString(32102), ADDON.getLocalizedString(32115))
else:
# Update the display
xbmc.executebuiltin("Container.Refresh")