xbmcbackup/resources/lib/utils.py

49 lines
1.2 KiB
Python
Raw Normal View History

import xbmc
2014-01-20 19:48:23 +01:00
import xbmcgui
import xbmcaddon
__addon_id__= 'script.xbmcbackup'
__Addon = xbmcaddon.Addon(__addon_id__)
def data_dir():
return __Addon.getAddonInfo('profile')
2012-10-26 16:17:21 +02:00
def addon_dir():
return __Addon.getAddonInfo('path')
2013-12-05 21:26:35 +01:00
def openSettings():
__Addon.openSettings()
2017-11-08 20:32:07 +01:00
def log(message,loglevel=xbmc.LOGDEBUG):
2014-01-20 20:02:29 +01:00
xbmc.log(encode(__addon_id__ + "-" + __Addon.getAddonInfo('version') + ": " + message),level=loglevel)
def showNotification(message):
2019-08-20 18:32:07 +02:00
xbmcgui.Dialog().notification(encode(getString(30010)),encode(message),time=4000,icon=xbmc.translatePath(__Addon.getAddonInfo('path') + "/resources/images/icon.png"))
def getSetting(name):
return __Addon.getSetting(name)
def setSetting(name,value):
__Addon.setSetting(name,value)
def getString(string_id):
return __Addon.getLocalizedString(string_id)
def getRegionalTimestamp(date_time,dateformat=['dateshort']):
result = ''
for aFormat in dateformat:
result = result + ("%s " % date_time.strftime(xbmc.getRegion(aFormat)))
return result.strip()
def encode(string):
result = ''
try:
result = string.encode('UTF-8','replace')
except UnicodeDecodeError:
result = 'Unicode Error'
return result