def __init__(self, updateFun=None, downloadNew=True): printDBG("IconMenager.__init__") self.DOWNLOADED_IMAGE_PATH_BASE = config.plugins.iptvplayer.SciezkaCache.value self.cm = common() # download queue self.queueDQ = [] self.lockDQ = threading.Lock() self.workThread = None # already available self.queueAA = {} self.lockAA = threading.Lock() #this function will be called after a new icon will be available self.updateFun = None #new icons dir for each run self.currDownloadDir = self.DOWNLOADED_IMAGE_PATH_BASE + '/' + GetNewIconsDirName( ) if not os_path.exists(self.currDownloadDir): mkdirs(self.currDownloadDir) #load available icon from disk #will be runned in separeted thread to speed UP start plugin AsyncMethod(self.loadHistoryFromDisk)(self.currDownloadDir) # this is called to remove icons which are stored in old version AsyncMethod(RemoveAllFilesIconsFromPath)( self.DOWNLOADED_IMAGE_PATH_BASE) self.stopThread = False self.checkSpace = 0 # if 0 the left space on disk will be checked self.downloadNew = downloadNew
def __del__(self): printDBG( "IconMenager.__del__ -------------------------------") self.clearDQueue() self.clearAAueue() if config.plugins.iptvplayer.SciezkaCache.value == self.DOWNLOADED_IMAGE_PATH_BASE and config.plugins.iptvplayer.showcover.value: AsyncMethod(RemoveOldDirsIcons)(self.DOWNLOADED_IMAGE_PATH_BASE, config.plugins.iptvplayer.deleteIcons.value) else: # remove all icons as they are not more needed due to config changes AsyncMethod(RemoveAllDirsIconsFromPath)(self.DOWNLOADED_IMAGE_PATH_BASE) printDBG( "IconMenager.__del__ end" )
def decodeCover(self, filename, callBackFun, ident): #checki if decoding is needed if filename != self.currIconPath and filename != self.waitIconPath: self.waitIconPath = filename #run new thread AsyncMethod(self.decode, self.decodeCallBack)(filename, callBackFun, ident, self.instance.size().width(), self.instance.size().height()) else: print "Cover: Not Neeed 1" callBackFun( {"Changed": False, "FileName": filename, "Ident": ident} ) return
def runWorkThread(self): if self.workThread == None or not self.workThread.Thread.isAlive(): self.workThread = AsyncMethod(self.processDQ)()