def set_iter_properties(self, dictionary, keys): if not isinstance(dictionary, dict): dictionary = {} for k in keys: try: v = dictionary.get(k, None) if isinstance(v, list): try: v = ' / '.join(v) except Exception as exc: kodi_traceback(exc, u'\nlib.monitor.common set_iter_properties\nk: {} v: {}'.format(k, v)) self.properties.add(k) self.set_property(k, v) except Exception as exc: kodi_traceback(exc, u'\nlib.monitor.common set_iter_properties\nk: {}'.format(k))
def set_indexed_properties(self, dictionary): if not isinstance(dictionary, dict): return index_properties = set() for k, v in dictionary.items(): if k in self.properties or k in SETPROP_RATINGS or k in SETMAIN_ARTWORK: continue try: v = v or '' self.set_property(k, v) index_properties.add(k) except Exception as exc: kodi_traceback(exc, u'\nlib.monitor.common set_indexed_properties\nk: {} v: {}'.format(k, v)) for k in (self.index_properties - index_properties): self.clear_property(k) self.index_properties = index_properties.copy()
import os import xbmc import xbmcvfs import colorsys from resources.lib.addon.window import get_property from resources.lib.addon.plugin import kodi_log, kodi_traceback, md5hash from resources.lib.addon.parser import try_int, try_float from resources.lib.files.utils import make_path from threading import Thread try: # Try import PIL due to some systems using incompatible local versions of numpy from PIL import ImageFilter, Image except Exception as exc: kodi_log('lib.monitor.images - PIL import error!', 1) kodi_traceback(exc, 'lib.monitor.images - PIL import error!', notification=False, log_level=2) ImageFilter, Image = None, None try: # Try import urllib for PY2/3 compatibility import urllib2 as urllib except ImportError: import urllib.request as urllib def _openimage(image, targetpath, filename): """ Open image helper with thanks to sualfred """ # some paths require unquoting to get a valid cached thumb hash cached_image_path = urllib.unquote(image.replace('image://', '')) if cached_image_path.endswith('/'): cached_image_path = cached_image_path[:-1]
def wrapper(*args, **kwargs): try: return func(*args, **kwargs) except Exception as exc: kodi_traceback(exc, log_msg, notification)