Esempio n. 1
0
def getFit(lookfor, eager=None):
    if isinstance(lookfor, int):
        if eager is None:
            with sd_lock:
                fit = saveddata_session.query(Fit).get(lookfor)
        else:
            eager = processEager(eager)
            with sd_lock:
                fit = saveddata_session.query(Fit).options(*eager).filter(Fit.ID == fitID).first()
    else:
        raise TypeError("Need integer as argument")
    return fit
Esempio n. 2
0
def getSquad(squadID, eager=None):
    if isinstance(squadID, int):
        if eager is None:
            with sd_lock:
                squad = saveddata_session.query(Squad).get(squadID)
        else:
            eager = processEager(eager)
            with sd_lock:
                squad = saveddata_session.query(Squad).options(*eager).filter(Fleet.ID == squadID).first()
    else:
        raise TypeError("Need integer as argument")
    return squad
Esempio n. 3
0
def getWing(wingID, eager=None):
    if isinstance(wingID, int):
        if eager is None:
            with sd_lock:
                wing = saveddata_session.query(Wing).get(wingID)
        else:
            eager = processEager(eager)
            with sd_lock:
                wing = saveddata_session.query(Wing).options(*eager).filter(Wing.ID == wingID).first()
    else:
        raise TypeError("Need integer as argument")
    return wing
Esempio n. 4
0
def getImplantSet(lookfor, eager=None):
    if isinstance(lookfor, int):
        if eager is None:
            with sd_lock:
                pattern = saveddata_session.query(ImplantSet).get(lookfor)
        else:
            eager = processEager(eager)
            with sd_lock:
                pattern = saveddata_session.query(ImplantSet).options(*eager).filter(TargetResists.ID == lookfor).first()
    elif isinstance(lookfor, basestring):
        eager = processEager(eager)
        with sd_lock:
            pattern = saveddata_session.query(ImplantSet).options(*eager).filter(TargetResists.name == lookfor).first()
    else:
        raise TypeError("Improper argument")
    return pattern
Esempio n. 5
0
def countFitsWithShip(lookfor, ownerID=None, where=None, eager=None):
    """
    Get all the fits using a certain ship.
    If no user is passed, do this for all users.
    """
    if ownerID is not None and not isinstance(ownerID, int):
        raise TypeError("OwnerID must be integer")

    if isinstance(lookfor, int):
        filter = Fit.shipID == lookfor
    elif isinstance(lookfor, list):
        if len(lookfor) == 0:
            return 0
        filter = Fit.shipID.in_(lookfor)
    else:
        raise TypeError("You must supply either an integer or ShipID must be integer")

    if ownerID is not None:
        filter = and_(filter, Fit.ownerID == ownerID)

    filter = processWhere(filter, where)
    eager = processEager(eager)
    with sd_lock:
        count = saveddata_session.query(Fit).options(*eager).filter(filter).count()

    return count
Esempio n. 6
0
def getPrice(typeID):
    if isinstance(typeID, int):
        with sd_lock:
            price = saveddata_session.query(Price).get(typeID)
    else:
        raise TypeError("Need integer as argument")
    return price
Esempio n. 7
0
def getMiscData(field):
    if isinstance(field, basestring):
        with sd_lock:
            data = saveddata_session.query(MiscData).get(field)
    else:
        raise TypeError("Need string as argument")
    return data
Esempio n. 8
0
def getDamagePattern(lookfor, eager=None):
    if isinstance(lookfor, int):
        if eager is None:
            with sd_lock:
                pattern = saveddata_session.query(DamagePattern).get(lookfor)
        else:
            eager = processEager(eager)
            with sd_lock:
                pattern = saveddata_session.query(DamagePattern).options(*eager).filter(DamagePattern.ID == lookfor).first()
    elif isinstance(lookfor, basestring):
        eager = processEager(eager)
        with sd_lock:
            pattern = saveddata_session.query(DamagePattern).options(*eager).filter(DamagePattern.name == lookfor).first()
    else:
        raise TypeError("Need integer or string as argument")
    return pattern
Esempio n. 9
0
def getUser(lookfor, eager=None):
    if isinstance(lookfor, int):
        if eager is None:
            with sd_lock:
                user = saveddata_session.query(User).get(lookfor)
        else:
            eager = processEager(eager)
            with sd_lock:
                user = saveddata_session.query(User).options(*eager).filter(User.ID == lookfor).first()
    elif isinstance(lookfor, str):
        eager = processEager(eager)
        with sd_lock:
            user = saveddata_session.query(User).options(*eager).filter(User.username == lookfor).first()
    else:
        raise TypeError("Need integer or string as argument")
    return user
Esempio n. 10
0
def getCrestCharacter(lookfor, eager=None):
    if isinstance(lookfor, int):
        if eager is None:
            with sd_lock:
                character = saveddata_session.query(CrestChar).get(lookfor)
        else:
            eager = processEager(eager)
            with sd_lock:
                character = saveddata_session.query(CrestChar).options(*eager).filter(CrestChar.ID == lookfor).first()
    elif isinstance(lookfor, basestring):
        eager = processEager(eager)
        with sd_lock:
            character = saveddata_session.query(CrestChar).options(*eager).filter(CrestChar.name == lookfor).first()
    else:
        raise TypeError("Need integer or string as argument")
    return character
Esempio n. 11
0
def getSquadsIDsWithFitID(fitID):
    if isinstance(fitID, int):
        with sd_lock:
            squads = saveddata_session.query(squadmembers_table.c.squadID).filter(squadmembers_table.c.memberID == fitID).all()
            squads = tuple(entry[0] for entry in squads)
            return squads
    else:
        raise TypeError("Need integer as argument")
Esempio n. 12
0
def getProjectedFits(fitID):
    if isinstance(fitID, int):
        with sd_lock:
            filter = and_(projectedFits_table.c.sourceID == fitID, Fit.ID == projectedFits_table.c.victimID)
            fits = saveddata_session.query(Fit).filter(filter).all()
            return fits
    else:
        raise TypeError("Need integer as argument")
Esempio n. 13
0
def getCharactersForUser(lookfor, eager=None):
    if isinstance(lookfor, int):
        eager = processEager(eager)
        with sd_lock:
            characters = saveddata_session.query(Character).options(*eager).filter(Character.ownerID == lookfor).all()
    else:
        raise TypeError("Need integer as argument")
    return characters
Esempio n. 14
0
def searchFits(nameLike, where=None, eager=None):
    if not isinstance(nameLike, basestring):
        raise TypeError("Need string as argument")
    # Prepare our string for request
    nameLike = u"%{0}%".format(sqlizeString(nameLike))

    #Add any extra components to the search to our where clause
    filter = processWhere(Fit.name.like(nameLike, escape="\\"), where)
    eager = processEager(eager)
    with sd_lock:
        fits = saveddata_session.query(Fit).options(*eager).filter(filter).all()
    return fits
Esempio n. 15
0
def getFitsWithModules(typeIDs, eager=None):
    """
    Get all the fits that have typeIDs fitted to them
    """

    if not hasattr(typeIDs, "__iter__"):
        typeIDs = (typeIDs,)

    eager = processEager(eager)
    with sd_lock:
        fits = removeInvalid(saveddata_session.query(Fit).join(Module).options(*eager).filter(Module.itemID.in_(typeIDs)).all())

    return fits
Esempio n. 16
0
def getSsoCharacter(lookfor, clientHash, eager=None):
    filter = SsoCharacter.client == clientHash

    if isinstance(lookfor, int):
        filter = and_(filter, SsoCharacter.ID == lookfor)
    elif isinstance(lookfor, str):
        filter = and_(filter, SsoCharacter.characterName == lookfor)
    else:
        raise TypeError("Need integer or string as argument")

    eager = processEager(eager)
    with sd_lock:
        character = saveddata_session.query(SsoCharacter).options(*eager).filter(filter).first()

    return character
Esempio n. 17
0
def getBoosterFits(ownerID=None, where=None, eager=None):
    """
    Get all the fits that are flagged as a boosting ship
    If no user is passed, do this for all users.
    """

    if ownerID is not None and not isinstance(ownerID, int):
        raise TypeError("OwnerID must be integer")
    filter = Fit.booster == 1
    if ownerID is not None:
        filter = and_(filter, Fit.ownerID == ownerID)

    filter = processWhere(filter, where)
    eager = processEager(eager)
    with sd_lock:
        fits = saveddata_session.query(Fit).options(*eager).filter(filter).all()
    return fits
Esempio n. 18
0
def countFitsWithShip(shipID, ownerID=None, where=None, eager=None):
    """
    Get all the fits using a certain ship.
    If no user is passed, do this for all users.
    """
    if isinstance(shipID, int):
        if ownerID is not None and not isinstance(ownerID, int):
            raise TypeError("OwnerID must be integer")
        filter = Fit.shipID == shipID
        if ownerID is not None:
            filter = and_(filter, Fit.ownerID == ownerID)

        filter = processWhere(filter, where)
        eager = processEager(eager)
        with sd_lock:
            count = saveddata_session.query(Fit).options(*eager).filter(filter).count()
    else:
        raise TypeError("ShipID must be integer")
    return count
Esempio n. 19
0
def getDamagePatternList(eager=None):
    eager = processEager(eager)
    with sd_lock:
        patterns = saveddata_session.query(DamagePattern).options(*eager).all()
    return patterns
Esempio n. 20
0
def getSsoCharacters(clientHash, eager=None):
    eager = processEager(eager)
    with sd_lock:
        characters = saveddata_session.query(SsoCharacter).filter(SsoCharacter.client == clientHash).options(*eager).all()
    return characters
Esempio n. 21
0
def getDamagePatternList(eager=None):
    eager = processEager(eager)
    with sd_lock:
        patterns = saveddata_session.query(DamagePattern).options(*eager).all()
    return patterns
Esempio n. 22
0
def clearPrices():
    with sd_lock:
        deleted_rows = saveddata_session.query(Price).delete()
    commit()
    return deleted_rows
Esempio n. 23
0
def clearOverrides():
    with sd_lock:
        deleted_rows = saveddata_session.query(Override).delete()
    commit()
    return deleted_rows
Esempio n. 24
0
def getSsoCharacters(clientHash, eager=None):
    eager = processEager(eager)
    with sd_lock:
        characters = saveddata_session.query(SsoCharacter).filter(SsoCharacter.client == clientHash).options(*eager).all()
    return characters
Esempio n. 25
0
def getAllOverrides(eager=None):
    return saveddata_session.query(Override).all()
Esempio n. 26
0
def getFleetList(eager=None):
    eager = processEager(eager)
    with sd_lock:
        fleets = saveddata_session.query(Fleet).options(*eager).all()
    return fleets
Esempio n. 27
0
def countAllFits():
    with sd_lock:
        count = saveddata_session.query(Fit).count()
    return count
Esempio n. 28
0
def getOverrides(itemID, eager=None):
    if isinstance(itemID, int):
        return saveddata_session.query(Override).filter(
            Override.itemID == itemID).all()
    else:
        raise TypeError("Need integer as argument")
Esempio n. 29
0
def getTargetResistsList(eager=None):
    eager = processEager(eager)
    with sd_lock:
        patterns = saveddata_session.query(TargetResists).options(*eager).all()
    return patterns
Esempio n. 30
0
def getImplantSetList(eager=None):
    eager = processEager(eager)
    with sd_lock:
        sets = saveddata_session.query(ImplantSet).options(*eager).all()
    return sets
Esempio n. 31
0
def getCharacterList(eager=None):
    eager = processEager(eager)
    with sd_lock:
        characters = saveddata_session.query(Character).options(*eager).all()
    return characters
Esempio n. 32
0
def clearDamagePatterns():
    with sd_lock:
        deleted_rows = saveddata_session.query(DamagePattern).filter(DamagePattern.name != 'Uniform').delete()
    commit()
    return deleted_rows
Esempio n. 33
0
def getTargetResistsList(eager=None):
    eager = processEager(eager)
    with sd_lock:
        patterns = saveddata_session.query(TargetResists).options(*eager).all()
    return patterns
Esempio n. 34
0
def getOverrides(itemID, eager=None):
    if isinstance(itemID, int):
        return saveddata_session.query(Override).filter(Override.itemID == itemID).all()
    else:
        raise TypeError("Need integer as argument")
Esempio n. 35
0
def clearPrices():
    with sd_lock:
        deleted_rows = saveddata_session.query(Price).delete()
    commit()
    return deleted_rows
Esempio n. 36
0
def clearOverrides():
    with sd_lock:
        deleted_rows = saveddata_session.query(Override).delete()
    commit()
    return deleted_rows
Esempio n. 37
0
def getFleetList(eager=None):
    eager = processEager(eager)
    with sd_lock:
        fleets = saveddata_session.query(Fleet).options(*eager).all()
    return fleets
Esempio n. 38
0
def getAllOverrides(eager=None):
    return saveddata_session.query(Override).all()
Esempio n. 39
0
def getImplantSetList(eager=None):
    eager = processEager(eager)
    with sd_lock:
        sets = saveddata_session.query(ImplantSet).options(*eager).all()
    return sets
Esempio n. 40
0
def countAllFits():
    with sd_lock:
        count = saveddata_session.query(Fit).count()
    return count
Esempio n. 41
0
def clearTargetProfiles():
    with sd_lock:
        deleted_rows = saveddata_session.query(TargetProfile).delete()
    commit()
    return deleted_rows
Esempio n. 42
0
def getFitList(eager=None):
    eager = processEager(eager)
    with sd_lock:
        fits = removeInvalid(saveddata_session.query(Fit).options(*eager).all())

    return fits
Esempio n. 43
0
def getFitList(eager=None):
    eager = processEager(eager)
    with sd_lock:
        fits = removeInvalid(saveddata_session.query(Fit).options(*eager).all())

    return fits
Esempio n. 44
0
def getCharacterList(eager=None):
    eager = processEager(eager)
    with sd_lock:
        characters = saveddata_session.query(Character).options(*eager).all()
    return characters