コード例 #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
ファイル: upgrade17.py プロジェクト: PaulKPetersonCO/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
          """
    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
ファイル: queries.py プロジェクト: poettler-ric/Pyfa
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
ファイル: upgrade17.py プロジェクト: bsmr/pyfa-org-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
          """
    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()