def getElementStaus(self, element):
        """returns a Status and path"""
        # log("Checking for status of %s in Sabnzbd" % element)
        download = Download()
        download.status = common.UNKNOWN
        if not self._history:
            self._getHistory()
        if not self._queue:
            self._getQueue()
        for curListIdentifier, curList in (("filename", self._queue), ("name", self._history)):
            for i in curList:
                element_id = self._findElementID(i[curListIdentifier])
                download_id = self._findDownloadID(i[curListIdentifier])
                # log("Game ID: %s Download ID: %s" % (game_id, download_id))
                if element_id != element.id:
                    continue

                try:
                    download = Download.get(Download.id == download_id)
                except Download.DoesNotExist:
                    pass
                if curListIdentifier == "filename":  # if we found it in the queue we are downloading it !
                    return (common.DOWNLOADING, download, "")

                if i["status"] == "Completed":
                    return (common.DOWNLOADED, download, i["storage"])
                elif i["status"] == "Failed":
                    return (common.FAILED, download, "")
                else:
                    return (common.SNATCHED, download, "")
        else:
            return (common.UNKNOWN, download, "")
    def getElementStaus(self, element):
        """returns a Status and path"""
        # log("Checking for status of %s in Sabnzbd" % element)
        download = Download()
        download.status = common.UNKNOWN
        if not self._history:
            self._getHistory()
        if not self._queue:
            self._getQueue()
        for curListIdentifier, curList in (('filename', self._queue),
                                           ('name', self._history)):
            for i in curList:
                element_id = self._findElementID(i[curListIdentifier])
                download_id = self._findDownloadID(i[curListIdentifier])
                # log("Game ID: %s Download ID: %s" % (game_id, download_id))
                if element_id != element.id:
                    continue

                try:
                    download = Download.get(Download.id == download_id)
                except Download.DoesNotExist:
                    pass
                if curListIdentifier == 'filename':  # if we found it in the queue we are downloading it !
                    return (common.DOWNLOADING, download, '')

                if i['status'] == 'Completed':
                    return (common.DOWNLOADED, download, i['storage'])
                elif i['status'] == 'Failed':
                    return (common.FAILED, download, '')
                else:
                    return (common.SNATCHED, download, '')
        else:
            return (common.UNKNOWN, download, '')
    def _findIDs(self, s):
        """
        this returns the element/download ids based on the database, not the downloadName as before.
        leads to redundant DB calls until the whole usage of findIDs is fixed.
        """
        if not self._idCache.has_key(s):
            log("%s not found in IDCache, fetching ..." % s)
            try:
                d = Download.select().where(Download.name == s).get()
                log("found %s for %s" % (d.id, s))
                self._idCache[s] = (d.element.id, d.id)
            except Download.DoesNotExist:
                return (None, None)
        else:
            log("%s found in IDCache (%s)" % (s, self._idCache[s]))

        return self._idCache[s]
    def _findIDs(self, s):
        """
        this returns the element/download ids based on the database, not the downloadName as before.
        leads to redundant DB calls until the whole usage of findIDs is fixed.
        """
        if not self._idCache.has_key(s):
            log("%s not found in IDCache, fetching ..." % s)
            try:
                d = Download.select().where(Download.name == s).get()
                log("found %s for %s" % (d.id, s))
                self._idCache[s] = (d.element.id, d.id)
            except Download.DoesNotExist:
                return (None, None)
        else:
            log("%s found in IDCache (%s)" % (s, self._idCache[s]))

        return self._idCache[s]