Пример #1
0
    def getIconPathFromAAueue(self, item):
        printDBG("getIconPathFromAAueue item[%s]" % item)
        if item.startswith('file://'): return item[7:]

        hashAlg = MD5()
        name = hashAlg(item)
        filename = hexlify(name) + '.jpg'

        self.lockAA.acquire()
        file_path = self.queueAA.get(filename, '')
        if file_path != '':
            try:
                if os_path.normcase(self.currDownloadDir +
                                    '/') != os_path.normcase(file_path + '/'):
                    file_path = os_path.normcase(file_path + '/' + filename)
                    os_rename(
                        file_path,
                        os_path.normcase(self.currDownloadDir + '/' +
                                         filename))
                    self.queueAA[filename] = os_path.normcase(
                        self.currDownloadDir + '/')
                    file_path = os_path.normcase(self.currDownloadDir + '/' +
                                                 filename)
                else:
                    file_path = os_path.normcase(file_path + '/' + filename)
            except Exception:
                printExc()
        self.lockAA.release()

        printDBG("getIconPathFromAAueue A file_path[%s]" % file_path)
        return file_path
Пример #2
0
 def getItemHashData(self, index, displayItem):
     if self.host.isQuestMode(): 
         hostName = str(self.host.getCurrentGuestHostName())
     else:
         hostName = str(self.host.getHostNameFromItem(index))
     
     ret = None
     if hostName not in [None, '']:
         # prepare item hash
         hashAlg = MD5()
         hashData = ('%s_%s' % (str(displayItem.name), str(displayItem.type)))
         hashData = hexlify(hashAlg(hashData))
         return (hostName, hashData)
     return ret
Пример #3
0
    def isItemInAAueue(self, item, hashed=0):
        if hashed == 0:
            hashAlg = MD5()
            name = hashAlg(item)
            file = hexlify(name) + '.jpg'
        else:
            file = item
        ret = False
        #without locking. Is it safety?
        self.lockAA.acquire()
        if None != self.queueAA.get(file, None):
            ret = True
        self.lockAA.release()

        return ret
Пример #4
0
    def processDQ(self):
        printDBG("IconMenager.processDQ: Thread started")

        while True:
            die = 0
            url = ''

            #getFirstFromDQueue
            self.lockDQ.acquire()

            if False == self.stopThread:
                if len(self.queueDQ):
                    url = self.queueDQ.pop(0)
                else:
                    self.workThread = None
                    die = 1
            else:
                self.stopThread = False
                self.workThread = None
                die = 1

            self.lockDQ.release()

            if die:
                return

            printDBG("IconMenager.processDQ url: [%s]" % url)
            if url != '':
                hashAlg = MD5()
                name = hashAlg(url)
                file = hexlify(name) + '.jpg'

                #check if this image is not already available in cache AA list
                if self.isItemInAAueue(file, 1):
                    continue

                if self.download_img(url, file):
                    self.addItemToAAueue(self.currDownloadDir, file)
                    if self.updateFun:
                        self.updateFun(url)