python类LOGDEBUG的实例源码

simpleplugin.py 文件源码 项目:plugin.video.auvio 作者: rickybiscus 项目源码 文件源码 阅读 33 收藏 0 点赞 0 评论 0
def log_debug(self, message):
        """
        Add debug message to the Kodi log

        :param message: message to write to the Kodi log
        :type message: str
        """
        self.log(message, xbmc.LOGDEBUG)
tweets.py 文件源码 项目:script.matchcenter 作者: enen92 项目源码 文件源码 阅读 39 收藏 0 点赞 0 评论 0
def onInit(self):
        xbmc.log(msg="[Match Center] Twitter cycle started", level=xbmc.LOGDEBUG)
        self.getControl(32540).setImage(os.path.join(addon_path,"resources","img","goal.png"))
        xbmc.executebuiltin("SetProperty(loading-script-matchcenter-twitter,1,home)")
        self.getTweets()
        xbmc.executebuiltin("ClearProperty(loading-script-matchcenter-twitter,Home)")
        i=0
        while self.isRunning:
            if (float(i*200)/(twitter_update_time*60*1000)).is_integer() and ((i*200)/(3*60*1000)) != 0:
                self.getTweets()
            xbmc.sleep(200)
            i += 1
        xbmc.log(msg="[Match Center] Twitter cycle stopped", level=xbmc.LOGDEBUG)
log_utils.py 文件源码 项目:context.youtube.download 作者: anxdpanic 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def log(msg, level=LOGDEBUG):
    try:
        if isinstance(msg, unicode):
            msg = '%s (ENCODED)' % msg.encode('utf-8')

        kodi.__log('%s: %s' % (name, msg), level)
    except Exception as e:
        try:
            kodi.__log('Logging Failure: %s' % (e), level)
        except:
            pass
logging.py 文件源码 项目:script.module.python.twitch 作者: MrSprigster 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def debug(self, message):
        message = prep_log_message(message)
        if xbmc:
            self._log(message, xbmc.LOGDEBUG)
        else:
            self._log.debug(message)
simplecache.py 文件源码 项目:script.module.simplecache 作者: marcelveldt 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def _log_msg(msg, loglevel=xbmc.LOGDEBUG):
        '''helper to send a message to the kodi log'''
        if isinstance(msg, unicode):
            msg = msg.encode('utf-8')
        xbmc.log("Skin Helper Simplecache --> %s" % msg, level=loglevel)
thetvdb.py 文件源码 项目:script.module.thetvdb 作者: marcelveldt 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def _log_msg(msg, level=xbmc.LOGDEBUG):
        '''logger to kodi log'''
        if isinstance(msg, unicode):
            msg = msg.encode("utf-8")
        xbmc.log('{0} --> {1}'.format(ADDON_ID, msg), level=level)
kodilogging.py 文件源码 项目:plugin.kogumi 作者: XIAZY 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def emit(self, record):
        levels = {
            logging.CRITICAL: xbmc.LOGFATAL,
            logging.ERROR: xbmc.LOGERROR,
            logging.WARNING: xbmc.LOGWARNING,
            logging.INFO: xbmc.LOGINFO,
            logging.DEBUG: xbmc.LOGDEBUG,
            logging.NOTSET: xbmc.LOGNONE,
        }
        if get_setting_as_bool('debug'):
            try:
                xbmc.log(self.format(record), levels[record.levelno])
            except UnicodeEncodeError:
                xbmc.log(self.format(record).encode(
                    'utf-8', 'ignore'), levels[record.levelno])
KodiHelper.py 文件源码 项目:plugin.video.netflix 作者: asciidisco 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def log(self, msg, level=xbmc.LOGDEBUG):
        """Adds a log entry to the Kodi log

        Parameters
        ----------
        msg : :obj:`str`
            Entry that should be turned into a list item

        level : :obj:`int`
            Kodi log level
        """
        if isinstance(msg, unicode):
            msg = msg.encode('utf-8')
        xbmc.log('[%s] %s' % (self.plugin, msg.__str__()), level)
myPlayer.py 文件源码 项目:plugin.video.stream-cinema 作者: bbaronSVK 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def log(text):
        xbmc.log(str([text]), xbmc.LOGDEBUG)
simplecache.py 文件源码 项目:plugin.video.stream-cinema 作者: bbaronSVK 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def _log_msg(msg, loglevel=xbmc.LOGDEBUG):
        '''helper to send a message to the kodi log'''
        if isinstance(msg, unicode):
            msg = msg.encode('utf-8')
        xbmc.log("Skin Helper Simplecache --> %s" % msg, level=loglevel)
debug.py 文件源码 项目:plugin.audio.tidal2 作者: arnesongit 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def __init__(self, pluginName, detailLevel=0, enableTidalApiLog=False):
        ''' Initialize Error Logging with a given Log Level
            detailLevel = 0 : xbmc.LOGERROR and xbmc.LOGNOTICE
            detailLevel = 1 : as level 0 plus xbmc.LOGWARNING
            detailLevel = 2 : as level 1 plus xbmc.LOGDEBUG
            detailLevel = 3 : as level 2 plus xbmc.LOGSEVERE
        '''
        self.pluginName = pluginName
        self.detailLevel = detailLevel
        self.debugServer = 'localhost'
        # Set Log Handler for tidalapi
        self.addTidalapiLogger(pluginName, enableDebug=enableTidalApiLog)
loguploader.py 文件源码 项目:specto 作者: mrknow 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def log(txt):
    if isinstance (txt,str):
        txt = txt.decode('utf-8')
    message = u'%s: %s' % (ADDONID, txt)
    xbmc.log(msg=message.encode('utf-8'), level=xbmc.LOGDEBUG)

# Custom urlopener to set user-agent
vpnapi.py 文件源码 项目:script.tvguide.fullscreen 作者: primaeval 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def connectTo(self, connection_name, wait):
        # Given the ovpn filename of a connection, connect to it.  Return True when the connection has happened 
        # or False if there's a problem connecting (or there's not a VPN connection available for this connection 
        # number).  Return True without messing with the connection if the current VPN is the same as the VPN being
        # requested.  The wait parameter will determine if the function returns once the connection has been made, 
        # or if it's fire and forget (in which case True will be returned regardless)
        if not self.isVPNSetUp(): return False
        if connection_name == "": return False
        if self.getConnected() == connection_name: return True
        xbmc.log(msg="VPN Mgr API : Connecting to " + connection_name, level=xbmc.LOGDEBUG)
        self.setAPICommand(connection_name)
        if wait: return self.waitForConnection(connection_name)
        return True
vpnapi.py 文件源码 项目:script.tvguide.fullscreen 作者: primaeval 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def disconnect(self, wait):
        # Disconnect any active VPN connection.  Return True when the connection has disconnected.  If there's
        # not an active connection, return True anyway.  The wait parameter will determine if the function returns 
        # once the connection has been made, or if it's fire and forget (in which case True will be returned regardless)
        if not self.isVPNSetUp(): return False
        if self.getConnected() == "": return True
        xbmc.log(msg="VPN Mgr API : Disconnecting", level=xbmc.LOGDEBUG)
        self.setAPICommand("Disconnect")
        if wait: return self.waitForConnection("")
        return True
vpnapi.py 文件源码 项目:script.tvguide.fullscreen 作者: primaeval 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def filterAndSwitch(self, path, windowid, default, wait):
        # Given a path to an addon, and/or a window ID, determine if it's associated with a particular VPN and
        # switch to that VPN.  Return True when the switch has happened or False if there's a problem switching 
        # (or there's no VPN that's been set up).  If the connected VPN is the VPN that's been identifed as being 
        # required, or no filter is found, just return True without messing with the connection.  The default 
        # parameter is a boolean indicating if the default VPN should be connected to if no filter is found.
        # The wait parameter will determine if the function returns once the connection has been made, or if it's 
        # fire and forget (in which case True will be returned regardless).  
        if not self.isVPNSetUp():
            return False
        connection = self.isFiltered(path, windowid)
        # Switch to the default connection if there's no filter
        if connection == -1 and default : 
            xbmc.log(msg="VPN Mgr API : Reconnecting to the default", level=xbmc.LOGDEBUG)
            return self.defaultVPN(wait)
        if connection == 0:
            if self.getConnected() == "": return True
            xbmc.log(msg="VPN Mgr API : Disconnecting due to filter " + path + " or window ID " + str(windowid), level=xbmc.LOGDEBUG)
            self.setAPICommand("Disconnect")
            if wait: return self.waitForConnection("")
        if connection > 0:
            connection = connection - 1
            if self.primary_vpns[connection] == "": return False
            if self.getConnected() == self.primary_vpns[connection]: return True
            xbmc.log(msg="VPN Mgr API : Connecting to " + self.primary_vpns[connection] + " due to filter " + path + " or window ID " + str(windowid), level=xbmc.LOGDEBUG)
            self.setAPICommand(self.primary_vpns[connection])
            if wait: return self.waitForConnection(self.primary_vpns[connection])
        return True
utils.py 文件源码 项目:script.tvguide.fullscreen 作者: primaeval 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def save_setting(key, value, is_list=False):

    xbmc.log('[%s] Tyring to save setting: key "%s" / value "%s"' %
             (ADDON.getAddonInfo('id'), key, str(value)), xbmc.LOGDEBUG)

    file_path = xbmc.translatePath(
        os.path.join(ADDON.getAddonInfo('profile'), 'settings.xml'))
    if not os.path.exists(file_path):
        generate_settings_file(file_path)
    tree = eT.parse(file_path)
    root = tree.getroot()
    updated = False
    for item in root.findall('setting'):
        if item.attrib['id'] == key:
            if is_list:
                cur_values = item.attrib['value']
                if not cur_values:
                    cur_values = []
                else:
                    cur_values = json.loads(cur_values)
                if isinstance(value, list):
                    for val in value:
                        if val not in cur_values:
                            cur_values.append(val)
                else:
                    if value not in cur_values:
                        cur_values.append(value)
                item.attrib['value'] = json.dumps(cur_values)
                ADDON.setSetting(key, cur_values)
            else:
                item.attrib['value'] = value
                ADDON.setSetting(key, value)
            updated = True
    if updated:
        tree.write(file_path)
    return True
gui.py 文件源码 项目:script.tvguide.fullscreen 作者: primaeval 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def debug(s):
    if DEBUG: xbmc.log(str(s), xbmc.LOGDEBUG)
source.py 文件源码 项目:script.tvguide.fullscreen 作者: primaeval 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def _deleteLineup(self, lineup):
        c = self.conn.cursor()
        # delete channels associated with the lineup
        xbmc.log('[%s] Removing Channels for lineup: %s' % (
            ADDON.getAddonInfo('id'), str(lineup)), xbmc.LOGDEBUG)
        c.execute('DELETE FROM channels WHERE source=? AND lineup=?', [self.source.KEY, lineup])

        c.execute("UPDATE sources SET channels_updated=? WHERE id=?",
                  [datetime.datetime.now(), self.source.KEY])
        self.conn.commit()
source.py 文件源码 项目:script.tvguide.fullscreen 作者: primaeval 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def _saveLineup(self, channelList, lineup):
        c = self.conn.cursor()
        # delete removed channels
        c.execute('SELECT * FROM channels WHERE source=? AND lineup=?',
                  [self.source.KEY, lineup])
        to_delete = []
        for row in c:
            station_id = row['id']
            found = False
            for channel in channelList:
                if channel.id == station_id:
                    found = True
                    break
            if not found:
                xbmc.log('[%s] Removing Channel: %s from lineup: %s' % (
                    ADDON.getAddonInfo('id'), str(station_id), str(lineup)), xbmc.LOGDEBUG)
                to_delete.append(station_id)

        if to_delete:
            c.execute('DELETE FROM channels WHERE id IN (%s)' %
                      ','.join('?' * len(to_delete)), to_delete)

        # Add new channels
        for channel in channelList:
            xbmc.log('[%s] Adding Channel: %s from lineup: %s' % (
                ADDON.getAddonInfo('id'), str(channel.id), str(lineup)), xbmc.LOGDEBUG)

            logo = get_logo(channel)
            c.execute(
                'INSERT OR IGNORE INTO channels(id, title, logo, stream_url, visible, weight, source, lineup) VALUES(?, ?, ?, ?, ?, (CASE ? WHEN -1 THEN (SELECT COALESCE(MAX(weight)+1, 0) FROM channels WHERE source=?) ELSE ? END), ?, ?)',
                [channel.id, channel.title, logo, '', True, -1, self.source.KEY, -1, self.source.KEY, lineup])

        c.execute("UPDATE sources SET channels_updated=? WHERE id=?",
                  [datetime.datetime.now(), self.source.KEY])
        self.conn.commit()
source.py 文件源码 项目:script.tvguide.fullscreen 作者: primaeval 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def updateSchedules(self, ch_list, progress_callback):
        sd = SdAPI()

        station_ids = []
        for ch in ch_list:
            station_ids.append(ch.id)

        # make sure date is in UTC!
        date_local = datetime.datetime.now()
        is_dst = time.daylight and time.localtime().tm_isdst > 0
        utc_offset = time.altzone if is_dst else time.timezone
        td_utc = datetime.timedelta(seconds=utc_offset)
        date = date_local + td_utc
        xbmc.log("[%s] Local date '%s' converted to UTC '%s'" %
                 (ADDON.getAddonInfo('id'), str(date_local), str(date)), xbmc.LOGDEBUG)

        # [{'station_id': station_id, 'p_id': p_id, 'start': start,
        #   'dur': dur, 'title': 'abc', 'desc': 'abc', 'logo': ''}, ... ]
        elements_parsed = 0
        schedules = sd.get_schedules(station_ids, date, progress_callback)
        for prg in schedules:
            start = self.to_local(prg['start'])
            end = start + datetime.timedelta(seconds=int(prg['dur']))
            result = Program(prg['station_id'], prg['title'], '', start, end, prg['desc'],'',
                             imageSmall=prg['logo'])

            elements_parsed += 1
            if result:
                if progress_callback and elements_parsed % 100 == 0:
                    percent = 100.0 / len(schedules) * elements_parsed
                    if not progress_callback(percent):
                        raise SourceUpdateCanceledException()
                yield result


问题


面经


文章

微信
公众号

扫码关注公众号