Пример #1
0
    def handle_response(self, flow):
        # we only care about URLs that are going to FFRK_HOST


        if FFRK_HOST in flow.request.host:
            # get_battle_init_data call
            if BATTLE_INFO_PATH in flow.request.path:
                print flow.request.path + " called"
                with decoded(flow.response):
                    json_data = json.loads(flow.response.content)
                    print get_drops_from_json(json_data)

                    if DUMP_CONTENT_TO_FILES:
                        dump_json_to_file(json_data, BATTLE_INFO_FILENAME + get_suffix_with_unix_time())

            # dff/party/list call
            elif EQUIPMENT_LIST_PATH in flow.request.path:
                print flow.request.path + " called"
                with decoded(flow.response):
                    json_data = json.loads(flow.response.content)
                    print get_equipment_id_from_json(json_data)

                    if DUMP_CONTENT_TO_FILES:
                        dump_json_to_file(json_data, EQUIPMENT_LIST_FILENAME + get_suffix_with_unix_time())

            else:
                print flow.request.path + " called; no processing done\n"

        # forward the reply so it gets passed on
        flow.reply()
Пример #2
0
def anonymize_file(filename, user_id):
    out_filename = clean_up_filename(filename + get_suffix_with_unix_time())

    outfile = open(out_filename, 'w')

    with open(filename, 'r+') as f:
        for line in f:
            if user_id in line:
                outfile.write(line.replace(user_id, ANONYMOUS_USER_ID))
            else:
                outfile.write(line)

        outfile.close()