Пример #1
0
def game_database_dumper_main():
    fsgs = FSGameSystemContext()
    game_database = fsgs.game_database(DATABASE_AMIGA)
    # cursor = game_database.cursor()
    # cursor.execute("")
    for uuid in game_database.get_all_uuids():
        values = game_database.get_game_values_for_uuid(uuid, recursive=False)
        for key in sorted(values.keys()):
            print("{} = {}".format(key, values[key]))
Пример #2
0
def get_games_handler(request):
    fsgs = FSGameSystemContext()
    # game_database = fsgs.get_game_database()
    # return {"platform:": request.params.platform}

    terms = []
    if request.params.platform:
        platform = request.params.platform
        # FIXME
        if platform == "snes":
            platform = "super-nintendo"
        elif platform == "gba":
            platform = "game-boy-advance"
        terms.append("platform:{}".format(platform))

    terms.append("t:thumb")

    database_items = fsgs.database().find_games_new(" ".join(terms))
    result = []
    for item in database_items:

        # query = "SELECT DISTINCT uuid, name, platform, year, publisher, " \
        #         "front_image, title_image, screen1_image, screen2_image, " \
        #         "screen3_image, screen4_image, screen5_image, have, path, " \
        #         "sort_key, subtitle FROM game"

        # backdrop = item[17].replace("sha1:", "")
        # if backdrop:
        #    # backdrop, hs, vs, ha, va = backdrop.split("/")

        result.append(
            {
                "uuid": item[0],
                "platform": item[2],
                "name": item[1],
                "subtitle": item[15],
                "year": item[3],
                "publisher": item[4],
                # "title_image": item[6].replace("sha1:", ""),
                # "screen1_image": item[7].replace("sha1:", ""),
                "thumb": item[16].replace("sha1:", ""),
                # "backdrop": backdrop,
                "backdrop": item[17],
            }
        )
    return json_list(result)
Пример #3
0
def create_application():

    fsgs = FSGameSystemContext()

    # A relatively simple WSGI application. It's going to print out the
    # environment dictionary after being updated by setup_testing_defaults
    def simple_app(environ, start_response):
        # FIXME: remove use of setup_testing_defaults
        setup_testing_defaults(environ)
        environ["fsgs"] = fsgs

        for mapping in url_map:
            kwargs = mapping.match(environ)
            if kwargs is not None:
                request = Request(environ)
                try:
                    result = mapping.run_handler(request, kwargs)
                    status = "200 OK"
                    if isinstance(result, dict):
                        headers = [("Content-type", "application/json")]
                        if "list_hack" in result:
                            result = result["list_hack"]
                        data = json.dumps(result, indent=4).encode("UTF-8")
                    else:
                        raise Exception("unknown result data type")
                    # headers = [("Content-type", "application/octet-stream")]
                    # data = json.dumps(result).encode("UTF-8")
                except Exception as e:
                    traceback.print_exc()
                    status = "500 Internal Server Error"
                    headers = [("Content-type", "text/plain")]
                    data = repr(e).encode("UTF-8")
                start_response(status, headers)
                return [data]

        start_response("404 Not Found", [("Content-type", "text/plain")])
        return [b"The resource was not found"]

    return simple_app
Пример #4
0
GET /sessions
{
    "id": "00000000-0000-0000-0000-000000000000"
}

"""


class ClientError(Exception):
    def __init__(self, message, code=400):
        Exception.__init__(self, message)
        self.code = code


default_fsgs = FSGameSystemContext()


def fsgs_from_session(session_id):
    assert session_id == "default"
    return default_fsgs


def configure_session(request, session_id):
    assert session_id == "default"
    request.session_id = session_id
    request.fsgs = fsgs_from_session(session_id)


# def get_sessions_handler(request):
#     return {}