예제 #1
0
파일: upgrade17.py 프로젝트: Ebag333/Pyfa
def upgrade(saveddata_engine):
    from eos.db import saveddata_session
    from eos.db.saveddata.fit import commandFits_table

    sql = """
          SELECT sm.memberID as boostedFit, s.leaderID AS squadBoost, w.leaderID AS wingBoost, g.leaderID AS gangBoost
          FROM squadmembers sm
          JOIN squads s ON s.ID = sm.squadID
          JOIN wings w on w.ID = s.wingID
          JOIN gangs g on g.ID = w.gangID
          """

    results = saveddata_session.execute(sql)

    inserts = []

    for row in results:
        boosted = row["boostedFit"]
        types = ("squad", "wing", "gang")
        for x in types:
            value = row["{}Boost".format(x)]
            if value is None:
                continue

            inserts.append({"boosterID": value, "boostedID": boosted, "active": 1})
            try:
                saveddata_session.execute(commandFits_table.insert(),
                                          {"boosterID": value, "boostedID": boosted, "active": 1})
            except Exception:
                pass
    saveddata_session.commit()
예제 #2
0
def upgrade(saveddata_engine):
    from eos.db import saveddata_session
    from eos.db.saveddata.fit import commandFits_table

    sql = """
          SELECT sm.memberID as boostedFit, s.leaderID AS squadBoost, w.leaderID AS wingBoost, g.leaderID AS gangBoost
          FROM squadmembers sm
          JOIN squads s ON s.ID = sm.squadID
          JOIN wings w on w.ID = s.wingID
          JOIN gangs g on g.ID = w.gangID
          """
    try:
        results = saveddata_session.execute(sql)

        inserts = []

        for row in results:
            boosted = row["boostedFit"]
            types = ("squad", "wing", "gang")
            for x in types:
                value = row["{}Boost".format(x)]
                if value is None:
                    continue

                inserts.append({"boosterID": value, "boostedID": boosted, "active": 1})
                try:
                    saveddata_session.execute(commandFits_table.insert(),
                                              {"boosterID": value, "boostedID": boosted, "active": 1})
                except Exception:
                    pass
        saveddata_session.commit()
    except:
        # Shouldn't fail unless you have updated database without the old fleet schema and manually modify the database version
        # If it does, simply fail. Fleet data migration isn't critically important here
        pass
예제 #3
0
파일: queries.py 프로젝트: tigeryi1998/Pyfa
def commit():
    with sd_lock:
        try:
            saveddata_session.commit()
        except Exception:
            saveddata_session.rollback()
            exc_info = sys.exc_info()
            raise exc_info[0](exc_info[1]).with_traceback(exc_info[2])
예제 #4
0
파일: queries.py 프로젝트: blitzmann/Pyfa
def commit():
    with sd_lock:
        try:
            saveddata_session.commit()
        except Exception:
            saveddata_session.rollback()
            exc_info = sys.exc_info()
            raise exc_info[0](exc_info[1]).with_traceback(exc_info[2])
예제 #5
0
def removeInvalid(fits):
    invalids = [f for f in fits if f.isInvalid]

    if invalids:
        map(fits.remove, invalids)
        map(saveddata_session.delete, invalids)
        saveddata_session.commit()

    return fits
예제 #6
0
파일: queries.py 프로젝트: tigeryi1998/Pyfa
def removeInvalid(fits):
    invalids = [f for f in fits if f.isInvalid]

    if invalids:
        list(map(fits.remove, invalids))
        list(map(saveddata_session.delete, invalids))
        saveddata_session.commit()

    return fits
예제 #7
0
파일: queries.py 프로젝트: webba/Pyfa
def commit():
    with sd_lock:
        try:
            saveddata_session.commit()
            saveddata_session.flush()
        except Exception:
            saveddata_session.rollback()
            exc_info = sys.exc_info()
            raise exc_info[0], exc_info[1], exc_info[2]
예제 #8
0
파일: queries.py 프로젝트: xmb666/Pyfa
def commit():
    with sd_lock:
        try:
            saveddata_session.commit()
        except (KeyboardInterrupt, SystemExit):
            raise
        except Exception:
            saveddata_session.rollback()
            exc_info = sys.exc_info()
            raise exc_info[0](exc_info[1]).with_traceback(exc_info[2])
예제 #9
0
def upgrade(saveddata_engine):
    from eos.db import saveddata_session

    sql = """
        DELETE FROM commandFits
        WHERE boosterID NOT IN (select ID from fits)
        OR boostedID NOT IN (select ID from fits)
        """

    saveddata_session.execute(sql)
    saveddata_session.commit()
예제 #10
0
def upgrade(saveddata_engine):
    from eos.db import saveddata_session
    from eos.db.saveddata.fit import commandFits_table

    sql = """
          SELECT sm.memberID as boostedFit, s.leaderID AS squadBoost, w.leaderID AS wingBoost, g.leaderID AS gangBoost
          FROM squadmembers sm
          JOIN squads s ON s.ID = sm.squadID
          JOIN wings w on w.ID = s.wingID
          JOIN gangs g on g.ID = w.gangID
          """
    try:
        results = saveddata_session.execute(sql)

        inserts = []

        for row in results:
            boosted = row["boostedFit"]
            types = ("squad", "wing", "gang")
            for x in types:
                value = row["{}Boost".format(x)]
                if value is None:
                    continue

                inserts.append({
                    "boosterID": value,
                    "boostedID": boosted,
                    "active": 1
                })
                try:
                    saveddata_session.execute(commandFits_table.insert(), {
                        "boosterID": value,
                        "boostedID": boosted,
                        "active": 1
                    })
                except (KeyboardInterrupt, SystemExit):
                    raise
                except Exception:
                    pass
        saveddata_session.commit()
    except (KeyboardInterrupt, SystemExit):
        raise
    except:
        # Shouldn't fail unless you have updated database without the old fleet schema and manually modify the database version
        # If it does, simply fail. Fleet data migration isn't critically important here
        pass
예제 #11
0
def upgrade(saveddata_engine):
    from eos.db import saveddata_session
    from eos.db.saveddata.fit import commandFits_table

    sql = """
          SELECT sm.memberID as boostedFit, s.leaderID AS squadBoost, w.leaderID AS wingBoost, g.leaderID AS gangBoost
          FROM squadmembers sm
          JOIN squads s ON s.ID = sm.squadID
          JOIN wings w on w.ID = s.wingID
          JOIN gangs g on g.ID = w.gangID
          """

    results = saveddata_session.execute(sql)

    inserts = []

    for row in results:
        boosted = row["boostedFit"]
        types = ("squad", "wing", "gang")
        for x in types:
            value = row["{}Boost".format(x)]
            if value is None:
                continue

            inserts.append({
                "boosterID": value,
                "boostedID": boosted,
                "active": 1
            })
            try:
                saveddata_session.execute(commandFits_table.insert(), {
                    "boosterID": value,
                    "boostedID": boosted,
                    "active": 1
                })
            except Exception:
                pass
    saveddata_session.commit()
예제 #12
0
def commit():
    with sd_lock:
        saveddata_session.commit()
        saveddata_session.flush()
예제 #13
0
파일: queries.py 프로젝트: Dennovin/Pyfa
def commit():
    with sd_lock:
        saveddata_session.commit()
        saveddata_session.flush()
예제 #14
0
def upgrade(saveddata_engine):
    from eos.db import saveddata_session
    from eos.db.saveddata.fit import commandFits_table

    sql = """
          SELECT sm.memberID as boostedFit, s.leaderID AS squadBoost, w.leaderID AS wingBoost, g.leaderID AS gangBoost
          FROM squadmembers sm
          JOIN squads s ON s.ID = sm.squadID
          JOIN wings w on w.ID = s.wingID
          JOIN gangs g on g.ID = w.gangID
          """

    results = saveddata_session.execute(sql)

    inserts = []

    for row in results:
        boosted = row["boostedFit"]
        types = ("squad", "wing", "gang")
        for x in types:
            value = row["{}Boost".format(x)]
            if value is None:
                continue

            inserts.append({"boosterID": value, "boostedID": boosted, "active": 1})
            try:
                saveddata_session.execute(commandFits_table.insert(), {"boosterID": value, "boostedID": boosted, "active": 1})
            except Exception, e:
                pass
    saveddata_session.commit()
예제 #15
0
          JOIN wings w on w.ID = s.wingID
          JOIN gangs g on g.ID = w.gangID
          """

    results = saveddata_session.execute(sql)

    inserts = []

    for row in results:
        boosted = row["boostedFit"]
        types = ("squad", "wing", "gang")
        for x in types:
            value = row["{}Boost".format(x)]
            if value is None:
                continue

            inserts.append({
                "boosterID": value,
                "boostedID": boosted,
                "active": 1
            })
            try:
                saveddata_session.execute(commandFits_table.insert(), {
                    "boosterID": value,
                    "boostedID": boosted,
                    "active": 1
                })
            except Exception, e:
                pass
    saveddata_session.commit()