当前位置: 首页>>代码示例>>Python>>正文


Python utils.logMsg函数代码示例

本文整理汇总了Python中utils.logMsg函数的典型用法代码示例。如果您正苦于以下问题:Python logMsg函数的具体用法?Python logMsg怎么用?Python logMsg使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了logMsg函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: GetPlexMetadata

def GetPlexMetadata(key):
    """
    Returns raw API metadata for key as an etree XML.

    Can be called with either Plex key '/library/metadata/xxxx'metadata
    OR with the digits 'xxxx' only.

    Returns None if something went wrong
    """
    key = str(key)
    if '/library/metadata/' in key:
        url = "{server}" + key
    else:
        url = "{server}/library/metadata/" + key
    arguments = {
        'checkFiles': 1,            # No idea
        'includeExtras': 1,         # Trailers and Extras => Extras
        # 'includeRelated': 1,        # Similar movies => Video -> Related
        # 'includeRelatedCount': 5,
        # 'includeOnDeck': 1,
        'includeChapters': 1,
        'includePopularLeaves': 1,
        'includeConcerts': 1
    }
    url = url + '?' + urlencode(arguments)
    xml = downloadutils.DownloadUtils().downloadUrl(url)
    # Did we receive a valid XML?
    try:
        xml.attrib
    # Nope we did not receive a valid XML
    except AttributeError:
        logMsg(title, "Error retrieving metadata for %s" % url, -1)
        xml = None
    return xml
开发者ID:gdachs,项目名称:PlexKodiConnect,代码行数:34,代码来源:PlexFunctions.py

示例2: refreshPlaylist

def refreshPlaylist():

    lib = librarysync.LibrarySync()
    dialog = xbmcgui.Dialog()
    try:
        # First remove playlists
        utils.deletePlaylists()
        # Remove video nodes
        utils.deleteNodes()
        # Refresh views
        lib.refreshViews()
        dialog.notification(
                heading="Emby for Kodi",
                message="Emby playlists/nodes refreshed",
                icon="special://home/addons/plugin.video.emby/icon.png",
                time=1000,
                sound=False)

    except Exception as e:
        utils.logMsg("EMBY", "Refresh playlists/nodes failed: %s" % e, 1)
        dialog.notification(
            heading="Emby for Kodi",
            message="Emby playlists/nodes refresh failed",
            icon=xbmcgui.NOTIFICATION_ERROR,
            time=1000,
            sound=False)
开发者ID:angelblue05,项目名称:Embytest.Kodi,代码行数:26,代码来源:entrypoint.py

示例3: GetPlexPlaylist

def GetPlexPlaylist(itemid, librarySectionUUID, mediatype='movie'):
    """
    Returns raw API metadata XML dump for a playlist with e.g. trailers.
   """
    trailerNumber = settings('trailerNumber')
    if not trailerNumber:
        trailerNumber = '3'
    url = "{server}/playQueues"
    args = {
        'type': mediatype,
        'uri': 'library://' + librarySectionUUID +
                    '/item/%2Flibrary%2Fmetadata%2F' + itemid,
        'includeChapters': '1',
        'extrasPrefixCount': trailerNumber,
        'shuffle': '0',
        'repeat': '0'
    }
    xml = downloadutils.DownloadUtils().downloadUrl(
        url + '?' + urlencode(args), action_type="POST")
    try:
        xml[0].tag
    except (IndexError, TypeError, AttributeError):
        logMsg(title, "Error retrieving metadata for %s" % url, -1)
        return None
    return xml
开发者ID:4everGhost,项目名称:PlexKodiConnect,代码行数:25,代码来源:PlexFunctions.py

示例4: PMSHttpsEnabled

def PMSHttpsEnabled(url):
    """
    Returns True if the PMS can talk https, False otherwise.
    None if error occured, e.g. the connection timed out

    Call with e.g. url='192.168.0.1:32400' (NO http/https)

    This is done by GET /identity (returns an error if https is enabled and we
    are trying to use http)

    Prefers HTTPS over HTTP
    """
    doUtils = downloadutils.DownloadUtils().downloadUrl
    res = doUtils('https://%s/identity' % url,
                  authenticate=False,
                  verifySSL=False)
    try:
        res.attrib
    except AttributeError:
        # Might have SSL deactivated. Try with http
        res = doUtils('http://%s/identity' % url,
                      authenticate=False,
                      verifySSL=False)
        try:
            res.attrib
        except AttributeError:
            logMsg(title, "Could not contact PMS %s" % url, -1)
            return None
        else:
            # Received a valid XML. Server wants to talk HTTP
            return False
    else:
        # Received a valid XML. Server wants to talk HTTPS
        return True
开发者ID:4everGhost,项目名称:PlexKodiConnect,代码行数:34,代码来源:PlexFunctions.py

示例5: getSongTags

def getSongTags(file):
    # Get the actual ID3 tags for music songs as the server is lacking that info
    rating = 0
    comment = ""
    hasEmbeddedCover = False
    
    isTemp,filename = getRealFileName(file)
    logMsg( "getting song ID3 tags for " + filename)
    
    try:
        ###### FLAC FILES #############
        if filename.lower().endswith(".flac"):
            audio = FLAC(filename)
            if audio.get("comment"):
                comment = audio.get("comment")[0]
            for pic in audio.pictures:
                if pic.type == 3 and pic.data:
                    #the file has an embedded cover
                    hasEmbeddedCover = True
                    break
            if audio.get("rating"):
                rating = float(audio.get("rating")[0])
                #flac rating is 0-100 and needs to be converted to 0-5 range
                if rating > 5: rating = (rating / 100) * 5
        
        ###### MP3 FILES #############
        elif filename.lower().endswith(".mp3"):
            audio = ID3(filename)
            
            if audio.get("APIC:Front Cover"):
                if audio.get("APIC:Front Cover").data:
                    hasEmbeddedCover = True
            
            if audio.get("comment"):
                comment = audio.get("comment")[0]
            if audio.get("POPM:Windows Media Player 9 Series"):
                if audio.get("POPM:Windows Media Player 9 Series").rating:
                    rating = float(audio.get("POPM:Windows Media Player 9 Series").rating)
                    #POPM rating is 0-255 and needs to be converted to 0-5 range
                    if rating > 5: rating = (rating / 255) * 5
        else:
            logMsg( "Not supported fileformat or unable to access file: %s" %(filename))
        
        #the rating must be a round value
        rating = int(round(rating,0))
    
    except Exception as e:
        #file in use ?
        utils.logMsg("Exception in getSongTags", str(e),0)
        rating = None
    
    #remove tempfile if needed....
    if isTemp: xbmcvfs.delete(filename)
        
    return (rating, comment, hasEmbeddedCover)
开发者ID:mattsch,项目名称:PlexKodiConnect,代码行数:55,代码来源:musicutils.py

示例6: resetAuth

def resetAuth():
    # User tried login and failed too many times
    resp = xbmcgui.Dialog().yesno(
                heading="Warning",
                line1=(
                    "Emby might lock your account if you fail to log in too many times. "
                    "Proceed anyway?"))
    if resp == 1:
        utils.logMsg("EMBY", "Reset login attempts.", 1)
        utils.window('emby_serverStatus', value="Auth")
    else:
        xbmc.executebuiltin('Addon.OpenSettings(plugin.video.emby)')
开发者ID:angelblue05,项目名称:Embytest.Kodi,代码行数:12,代码来源:entrypoint.py

示例7: __init__

    def __init__(self):

        self.enableTextureCache = utils.settings('enableTextureCache') == "true"
        self.imageCacheLimitThreads = int(utils.settings("imageCacheLimit"))
        self.imageCacheLimitThreads = int(self.imageCacheLimitThreads * 5);
        utils.logMsg("Using Image Cache Thread Count: " + str(self.imageCacheLimitThreads), 1)
        
        if not self.xbmc_port and self.enableTextureCache:
            self.setKodiWebServerDetails()

        self.userId = utils.window('currUserId')
        self.server = utils.window('pms_server')
开发者ID:aglv,项目名称:PlexKodiConnect,代码行数:12,代码来源:artwork.py

示例8: __init__

    def __init__(self):
        self.clientinfo = clientinfo.ClientInfo()
        self.addonName = self.clientinfo.getAddonName()

        self.enableTextureCache = utils.settings('enableTextureCache') == "true"
        self.imageCacheLimitThreads = int(utils.settings("imageCacheLimit"))
        self.imageCacheLimitThreads = int(self.imageCacheLimitThreads * 5);
        utils.logMsg("Using Image Cache Thread Count: " + str(self.imageCacheLimitThreads), 1)
        
        if not self.xbmc_port and self.enableTextureCache:
            self.setKodiWebServerDetails()

        self.userId = utils.window('emby_currUser')
        self.server = utils.window('emby_server%s' % self.userId)
开发者ID:fagensden,项目名称:plugin.video.emby,代码行数:14,代码来源:artwork.py

示例9: scrobble

def scrobble(ratingKey, state):
    """
    Tells the PMS to set an item's watched state to state="watched" or
    state="unwatched"
    """
    args = {
        'key': ratingKey,
        'identifier': 'com.plexapp.plugins.library'
    }
    if state == "watched":
        url = "{server}/:/scrobble?" + urlencode(args)
    elif state == "unwatched":
        url = "{server}/:/unscrobble?" + urlencode(args)
    else:
        return
    downloadutils.DownloadUtils().downloadUrl(url)
    logMsg(title, "Toggled watched state for Plex item %s" % ratingKey, 1)
开发者ID:4everGhost,项目名称:PlexKodiConnect,代码行数:17,代码来源:PlexFunctions.py

示例10: GetMachineIdentifier

def GetMachineIdentifier(url):
    """
    Returns the unique PMS machine identifier of url

    Returns None if something went wrong
    """
    xml = downloadutils.DownloadUtils().downloadUrl(url + '/identity')
    try:
        xml.attrib
    except:
        logMsg(title, 'Could not get the PMS machineIdentifier for %s'
               % url, -1)
        return None
    machineIdentifier = xml.attrib.get('machineIdentifier')
    logMsg(title, 'Found machineIdentifier %s for %s'
           % (machineIdentifier, url), 1)
    return machineIdentifier
开发者ID:mattsch,项目名称:PlexKodiConnect,代码行数:17,代码来源:PlexFunctions.py

示例11: GetMachineIdentifier

def GetMachineIdentifier(url):
    """
    Returns the unique PMS machine identifier of url

    Returns None if something went wrong
    """
    xml = downloadutils.DownloadUtils().downloadUrl('%s/identity' % url,
                                                    authenticate=False,
                                                    verifySSL=False,
                                                    timeout=4)
    try:
        machineIdentifier = xml.attrib['machineIdentifier']
    except (AttributeError, KeyError):
        logMsg(title, 'Could not get the PMS machineIdentifier for %s'
               % url, -1)
        return None
    logMsg(title, 'Found machineIdentifier %s for the PMS %s'
           % (machineIdentifier, url), 1)
    return machineIdentifier
开发者ID:4everGhost,项目名称:PlexKodiConnect,代码行数:19,代码来源:PlexFunctions.py

示例12: resetDeviceId

def resetDeviceId():

    dialog = xbmcgui.Dialog()
    language = utils.language

    deviceId_old = utils.window('emby_deviceId')
    try:
        utils.window('emby_deviceId', clear=True)
        deviceId = clientinfo.ClientInfo().getDeviceId(reset=True)
    except Exception as e:
        utils.logMsg("EMBY", "Failed to generate a new device Id: %s" % e, 1)
        dialog.ok(
            heading="Emby for Kodi",
            line1=language(33032))
    else:
        utils.logMsg("EMBY", "Successfully removed old deviceId: %s New deviceId: %s"
                    % (deviceId_old, deviceId), 1)
        dialog.ok(
            heading="Emby for Kodi",
            line1=language(33033))
        xbmc.executebuiltin('RestartApp')
开发者ID:angelblue05,项目名称:Embytest.Kodi,代码行数:21,代码来源:entrypoint.py

示例13: DownloadChunks

def DownloadChunks(url, containerSize):
    """
    Downloads PMS url in chunks of containerSize (int).
    If containerSize is None: ONE xml is fetched directly

    url MUST end with '?' (if no other url encoded args are present) or '&'

    Returns a stitched-together xml or None.
    """
    if containerSize is None:
        # Get rid of '?' or '&' at the end of url
        xml = downloadutils.DownloadUtils().downloadUrl(url[:-1])
        try:
            xml.attrib
        except AttributeError:
            # Nope, not an XML, abort
            logMsg(title, "Error getting url %s" % url[:-1], -1)
            return None
        else:
            return xml

    xml = None
    pos = 0
    errorCounter = 0
    while errorCounter < 10:
        args = {
            'X-Plex-Container-Size': containerSize,
            'X-Plex-Container-Start': pos
        }
        xmlpart = downloadutils.DownloadUtils().downloadUrl(
            url + urlencode(args))
        # If something went wrong - skip in the hope that it works next time
        try:
            xmlpart.attrib
        except AttributeError:
            logMsg(title, 'Error while downloading chunks: %s'
                   % (url + urlencode(args)), -1)
            pos += containerSize
            errorCounter += 1
            continue

        # Very first run: starting xml (to retain data in xml's root!)
        if xml is None:
            xml = deepcopy(xmlpart)
            if len(xmlpart) < containerSize:
                break
            else:
                pos += containerSize
                continue
        # Build answer xml - containing the entire library
        for child in xmlpart:
            xml.append(child)
        # Done as soon as we don't receive a full complement of items
        if len(xmlpart) < containerSize:
            break
        pos += containerSize
    if errorCounter == 10:
        logMsg(title, 'Fatal error while downloading chunks for %s' % url, -1)
        return None
    return xml
开发者ID:gdachs,项目名称:PlexKodiConnect,代码行数:60,代码来源:PlexFunctions.py

示例14: getExtraFanArt

def getExtraFanArt(embyId,embyPath):
    
    emby = embyserver.Read_EmbyServer()
    art = artwork.Artwork()
    
    # Get extrafanart for listitem 
    # will be called by skinhelper script to get the extrafanart
    try:
        # for tvshows we get the embyid just from the path
        if not embyId:
            if "plugin.video.emby" in embyPath:
                embyId = embyPath.split("/")[-2]
        
        if embyId:
            #only proceed if we actually have a emby id
            utils.logMsg("EMBY", "Requesting extrafanart for Id: %s" % embyId, 0)

            # We need to store the images locally for this to work
            # because of the caching system in xbmc
            fanartDir = xbmc.translatePath("special://thumbnails/emby/%s/" % embyId).decode('utf-8')
            
            if not xbmcvfs.exists(fanartDir):
                # Download the images to the cache directory
                xbmcvfs.mkdirs(fanartDir)
                item = emby.getItem(embyId)
                if item:
                    backdrops = art.getAllArtwork(item)['Backdrop']
                    tags = item['BackdropImageTags']
                    count = 0
                    for backdrop in backdrops:
                        # Same ordering as in artwork
                        tag = tags[count]
                        if os.path.supports_unicode_filenames:
                            fanartFile = os.path.join(fanartDir, "fanart%s.jpg" % tag)
                        else:
                            fanartFile = os.path.join(fanartDir.encode("utf-8"), "fanart%s.jpg" % tag.encode("utf-8"))
                        li = xbmcgui.ListItem(tag, path=fanartFile)
                        xbmcplugin.addDirectoryItem(
                                            handle=int(sys.argv[1]),
                                            url=fanartFile,
                                            listitem=li)
                        xbmcvfs.copy(backdrop, fanartFile) 
                        count += 1               
            else:
                utils.logMsg("EMBY", "Found cached backdrop.", 2)
                # Use existing cached images
                dirs, files = xbmcvfs.listdir(fanartDir)
                for file in files:
                    fanartFile = os.path.join(fanartDir, file.decode('utf-8'))
                    li = xbmcgui.ListItem(file, path=fanartFile)
                    xbmcplugin.addDirectoryItem(
                                            handle=int(sys.argv[1]),
                                            url=fanartFile,
                                            listitem=li)
    except Exception as e:
        utils.logMsg("EMBY", "Error getting extrafanart: %s" % e, 0)
    
    # Always do endofdirectory to prevent errors in the logs
    xbmcplugin.endOfDirectory(int(sys.argv[1]))
开发者ID:angelblue05,项目名称:Embytest.Kodi,代码行数:59,代码来源:entrypoint.py

示例15: deleteItem

def deleteItem():

    # Serves as a keymap action
    if xbmc.getInfoLabel('ListItem.Property(embyid)'): # If we already have the embyid
        embyid = xbmc.getInfoLabel('ListItem.Property(embyid)')
    else:
        dbid = xbmc.getInfoLabel('ListItem.DBID')
        itemtype = xbmc.getInfoLabel('ListItem.DBTYPE')

        if not itemtype:

            if xbmc.getCondVisibility('Container.Content(albums)'):
                itemtype = "album"
            elif xbmc.getCondVisibility('Container.Content(artists)'):
                itemtype = "artist"
            elif xbmc.getCondVisibility('Container.Content(songs)'):
                itemtype = "song"
            elif xbmc.getCondVisibility('Container.Content(pictures)'):
                itemtype = "picture"
            else:
                utils.logMsg("EMBY delete", "Unknown type, unable to proceed.", 1)
                return

        embyconn = utils.kodiSQL('emby')
        embycursor = embyconn.cursor()
        emby_db = embydb.Embydb_Functions(embycursor)
        item = emby_db.getItem_byKodiId(dbid, itemtype)
        embycursor.close()

        try:
            embyid = item[0]
        except TypeError:
            utils.logMsg("EMBY delete", "Unknown embyId, unable to proceed.", 1)
            return

    if utils.settings('skipContextMenu') != "true":
        resp = xbmcgui.Dialog().yesno(
                                heading="Confirm delete",
                                line1=("Delete file from Emby Server? This will "
                                        "also delete the file(s) from disk!"))
        if not resp:
            utils.logMsg("EMBY delete", "User skipped deletion for: %s." % embyid, 1)
            return
    
    doUtils = downloadutils.DownloadUtils()
    url = "{server}/emby/Items/%s?format=json" % embyid
    utils.logMsg("EMBY delete", "Deleting request: %s" % embyid, 0)
    doUtils.downloadUrl(url, type="DELETE")
开发者ID:angelblue05,项目名称:Embytest.Kodi,代码行数:48,代码来源:entrypoint.py


注:本文中的utils.logMsg函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。