Esempio n. 1
0
def _checkAsset(bithorde, obj, now):
    ids = parseHashIds(obj.get('xt') or obj.id)
    if not ids:
        return obj, None

    with bithorde.open(ids) as bhAsset:
        status = bhAsset.status()
        status_ok = status and status.status == message.SUCCESS or False

    set_new_availability(obj, status_ok, now=now)

    if status and (status.size is not None):
        if status.size > 2**40:
            warn("Implausibly large asset-size: %r - %r" % (obj, status))
            return obj, None
        obj.set('filesize', unicode(status.size), t=now)

    return obj, status_ok
Esempio n. 2
0
File: util.py Progetto: zidz/bhindex
def _checkAsset(bithorde, obj, t):
    ids = parseHashIds(obj.get('xt', tuple()))
    if not ids:
        return obj, None

    with bithorde.open(ids) as bhAsset:
        status = bhAsset.status()
        status_ok = status and status.status == message.SUCCESS or False
    avail, time_since_check = _object_availability(obj, t)
    newAvail = calc_new_availability(status_ok, avail, time_since_check)

    del obj['bh_status']
    del obj['bh_status_confirmed']
    obj['bh_availability'] = ValueSet(unicode(newAvail), t=t)

    if status and (status.size is not None):
        if status.size > 2**40:
            warn("Implausibly large asset-size: %r - %r" % (obj, status))
            return obj, None
        obj['filesize'] = ValueSet((unicode(status.size),), t=t)

    return obj, status_ok
Esempio n. 3
0
 def ids(self):
     return parseHashIds(self.obj['xt'])