本文整理匯總了Python中xbmc.LOGDEBUG屬性的典型用法代碼示例。如果您正苦於以下問題:Python xbmc.LOGDEBUG屬性的具體用法?Python xbmc.LOGDEBUG怎麽用?Python xbmc.LOGDEBUG使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類xbmc
的用法示例。
在下文中一共展示了xbmc.LOGDEBUG屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: deleteDB
# 需要導入模塊: import xbmc [as 別名]
# 或者: from xbmc import LOGDEBUG [as 別名]
def deleteDB():
try:
xbmc.log("[script.tvguide.fullscreen] Deleting database...", xbmc.LOGDEBUG)
dbPath = xbmc.translatePath(xbmcaddon.Addon(id = 'script.tvguide.fullscreen').getAddonInfo('profile'))
dbPath = os.path.join(dbPath, 'source.db')
delete_file(dbPath)
passed = not os.path.exists(dbPath)
if passed:
xbmc.log("[script.tvguide.fullscreen] Deleting database...PASSED", xbmc.LOGDEBUG)
else:
xbmc.log("[script.tvguide.fullscreen] Deleting database...FAILED", xbmc.LOGDEBUG)
return passed
except Exception, e:
xbmc.log('[script.tvguide.fullscreen] Deleting database...EXCEPTION', xbmc.LOGDEBUG)
return False
示例2: __init__
# 需要導入模塊: import xbmc [as 別名]
# 或者: from xbmc import LOGDEBUG [as 別名]
def __init__(self, addon, force):
self.needReset = False
self.fetchError = False
self.start = True
self.force = force
'''
self.xmltvInterval = int(addon.getSetting('sd.interval'))
self.logoSource = int(addon.getSetting('logos.source'))
self.addonsType = int(addon.getSetting('addons.ini.type'))
# make sure the folder in the user's profile exists or create it!
if not os.path.exists(self.PLUGIN_DATA):
os.makedirs(self.PLUGIN_DATA)
# make sure the ini file is fetched as well if necessary
if self.addonsType != self.INI_TYPE_DEFAULT:
customFile = str(addon.getSetting('addons.ini.file'))
if os.path.exists(customFile):
# uses local file provided by user!
xbmc.log('[%s] Use local file: %s' % (ADDON.getAddonInfo('id'), customFile), xbmc.LOGDEBUG)
else:
# Probably a remote file
xbmc.log('[%s] Use remote file: %s' % (ADDON.getAddonInfo('id'), customFile), xbmc.LOGDEBUG)
self.updateLocalFile(customFile, addon, True, force=force)
'''
示例3: __init__
# 需要導入模塊: import xbmc [as 別名]
# 或者: from xbmc import LOGDEBUG [as 別名]
def __init__(self):
# Class initialisation. Fails with a RuntimeError exception if VPN Manager add-on is not available, or too old
self.filtered_addons = []
self.filtered_windows = []
self.primary_vpns = []
self.last_updated = 0
self.refreshLists()
self.default = self.getConnected()
xbmc.log("VPN Mgr API : Default is " + self.default, level=xbmc.LOGDEBUG)
self.timeout = 30
if not xbmc.getCondVisibility("System.HasAddon(service.vpn.manager)"):
xbmc.log("VPN Mgr API : VPN Manager is not installed, cannot use filtering", level=xbmc.LOGERROR)
raise RuntimeError("VPN Manager is not installed")
else:
v = int((xbmcaddon.Addon("service.vpn.manager").getAddonInfo("version").strip()).replace(".",""))
if v < 310:
raise RuntimeError("VPN Manager " + str(v) + " installed, but needs to be v3.1.0 or later")
示例4: connectToValidated
# 需要導入模塊: import xbmc [as 別名]
# 或者: from xbmc import LOGDEBUG [as 別名]
def connectToValidated(self, connection, wait):
# Given the number of a validated 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 < 1 or connection > 10: return False
connection = connection - 1
self.refreshLists()
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], level=xbmc.LOGDEBUG)
self.setAPICommand(self.primary_vpns[connection])
if wait: return self.waitForConnection(self.primary_vpns[connection])
return True
示例5: __init__
# 需要導入模塊: import xbmc [as 別名]
# 或者: from xbmc import LOGDEBUG [as 別名]
def __init__(self):
# Class initialisation. Fails with a RuntimeError exception if add-on is not available, or too old
self.filtered_addons = []
self.filtered_windows = []
self.primary_vpns = []
self.last_updated = 0
self.addon_name = ""
self.timeout = 30
if xbmc.getCondVisibility("System.HasAddon(service.vpn.manager)"):
self.addon_name = "service.vpn.manager"
elif xbmc.getCondVisibility("System.HasAddon(service.nord.vpn)"):
self.addon_name = "service.nord.vpn"
if self.addon_name == "":
xbmc.log("VPN API : A VPN add-on is not installed, cannot use filtering", level=xbmc.LOGERROR)
raise RuntimeError("VPN add-on is not installed")
else:
v = int((xbmcaddon.Addon(self.addon_name).getAddonInfo("version").strip()).replace(".",""))
if v < 310:
raise RuntimeError("VPN add-on version " + str(v) + " installed, but needs to be v3.1.0 or later")
self.refreshLists()
self.default = self.getConnected()
xbmc.log("VPN API : Default is " + self.default, level=xbmc.LOGDEBUG)
示例6: connectToValidated
# 需要導入模塊: import xbmc [as 別名]
# 或者: from xbmc import LOGDEBUG [as 別名]
def connectToValidated(self, connection, wait):
# Given the number of a validated 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 < 1 or connection > 10: return False
connection = connection - 1
self.refreshLists()
if self.primary_vpns[connection] == "": return False
if self.getConnected() == self.primary_vpns[connection]: return True
xbmc.log(msg="VPN API : Connecting to " + self.primary_vpns[connection], level=xbmc.LOGDEBUG)
self.setAPICommand(self.primary_vpns[connection])
if wait: return self.waitForConnection(self.primary_vpns[connection])
return True
示例7: log
# 需要導入模塊: import xbmc [as 別名]
# 或者: from xbmc import LOGDEBUG [as 別名]
def log(self, msg, level=LOGDEBUG):
# if debug isn't on, skip disabled loggers unless addon_debug is on
if not self.__debug_on:
if self in self.__disabled:
return
elif level == LOGDEBUG:
if self.__addon_debug:
level = LOGNOTICE
else:
return
try:
if isinstance(msg, six.text_type) and six.PY2:
msg = '%s (ENCODED)' % (msg.encode('utf-8'))
xbmc.log('%s: %s' % (self.__name, msg), level)
except Exception as e:
try:
xbmc.log('Logging Failure: %s' % (e), level)
except:
pass # just give up
示例8: log
# 需要導入模塊: import xbmc [as 別名]
# 或者: from xbmc import LOGDEBUG [as 別名]
def log(msg, level=xbmc.LOGDEBUG):
if CONFIG.DEBUGLEVEL == '0': # No Logging
return False
if CONFIG.DEBUGLEVEL == '1': # Normal Logging
pass
if CONFIG.DEBUGLEVEL == '2': # Full Logging
level = xbmc.LOGNOTICE
xbmc.log('{0}: {1}'.format(CONFIG.ADDONTITLE, msg), level)
if CONFIG.ENABLEWIZLOG == 'true':
if not os.path.exists(CONFIG.WIZLOG):
with open(CONFIG.WIZLOG, 'w+') as f:
f.close()
lastcheck = CONFIG.NEXTCLEANDATE if not CONFIG.NEXTCLEANDATE == 0 else tools.get_date()
if CONFIG.CLEANWIZLOG == 'true' and time.mktime(time.strptime(lastcheck, "%Y-%m-%d %H:%M:%S")) <= tools.get_date():
check_log()
line = "[{0}] {1}".format(tools.get_date(formatted=True), msg)
line = line.rstrip('\r\n') + '\n'
tools.write_to_file(CONFIG.WIZLOG, line, mode='a')
示例9: log
# 需要導入模塊: import xbmc [as 別名]
# 或者: from xbmc import LOGDEBUG [as 別名]
def log(message, level=xbmc.LOGDEBUG, tag=None):
if is_addon_watched() and level < xbmc.LOGNOTICE:
# Messages from this add-on are being watched, elevate to NOTICE so Kodi logs it
level_tag = _log_level_tag_lookup[level] + ': ' if level in _log_level_tag_lookup else ''
level = xbmc.LOGNOTICE
else:
level_tag = ''
if isinstance(message, (dict, list)) and len(message) > 300:
message = str(message)
elif isinstance(message, unicode):
message = message.encode('utf-8')
elif not isinstance(message, str):
message = json.dumps(message, cls=UTF8PrettyJSONEncoder)
addontag = ADDONID if not tag else ADDONID + ':' + tag
file_message = '%s[%s] %s' % (level_tag, addontag, scrub_message(message))
xbmc.log(file_message, level)
示例10: save_setting
# 需要導入模塊: import xbmc [as 別名]
# 或者: from xbmc import LOGDEBUG [as 別名]
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
示例11: _deleteLineup
# 需要導入模塊: import xbmc [as 別名]
# 或者: from xbmc import LOGDEBUG [as 別名]
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()
示例12: _saveLineup
# 需要導入模塊: import xbmc [as 別名]
# 或者: from xbmc import LOGDEBUG [as 別名]
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()
示例13: updateSchedules
# 需要導入模塊: import xbmc [as 別名]
# 或者: from xbmc import LOGDEBUG [as 別名]
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
示例14: connectTo
# 需要導入模塊: import xbmc [as 別名]
# 或者: from xbmc import LOGDEBUG [as 別名]
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
示例15: filterAndSwitch
# 需要導入模塊: import xbmc [as 別名]
# 或者: from xbmc import LOGDEBUG [as 別名]
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