当前位置: 首页>>代码示例>>Python>>正文


Python DatabaseManager.retrieve_perf_ref方法代码示例

本文整理汇总了Python中database.DatabaseManager.retrieve_perf_ref方法的典型用法代码示例。如果您正苦于以下问题:Python DatabaseManager.retrieve_perf_ref方法的具体用法?Python DatabaseManager.retrieve_perf_ref怎么用?Python DatabaseManager.retrieve_perf_ref使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在database.DatabaseManager的用法示例。


在下文中一共展示了DatabaseManager.retrieve_perf_ref方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: citation_page

# 需要导入模块: from database import DatabaseManager [as 别名]
# 或者: from database.DatabaseManager import retrieve_perf_ref [as 别名]
def citation_page(uuid):
    game_ref = dbm.retrieve_game_ref(uuid)
    perf_ref = dbm.retrieve_perf_ref(uuid)
    derived_performances = dbm.retrieve_derived_performances(uuid)
    previous_performances = dbm.retrieve_performance_chain(uuid)[:-1]
    save_states = dbm.retrieve_save_state(game_uuid=uuid)
    extra_files = dbm.retrieve_file_path(game_uuid=uuid)

    if game_ref:
        return render_template('citation.html',
                               citeref=game_ref,
                               is_game=True,
                               is_performance=False,
                               derived_performances=derived_performances,
                               extra_files=extra_files,
                               save_states=save_states)
    elif perf_ref:
        performance_video = "/cite_data/{}/{}".format(perf_ref['replay_source_file_ref'],
                                                      perf_ref['replay_source_file_name'])
        return render_template('citation.html',
                               citeref=perf_ref,
                               is_game=False,
                               is_performance=True,
                               previous_performances=previous_performances,
                               performance_video=performance_video)
    return "No record found, sorry."
开发者ID:gamecip,项目名称:citetool-editor,代码行数:28,代码来源:app.py

示例2: performance_info

# 需要导入模块: from database import DatabaseManager [as 别名]
# 或者: from database.DatabaseManager import retrieve_perf_ref [as 别名]
def performance_info(uuid):
    perf_info = {}
    perf_ref = dbm.retrieve_perf_ref(uuid)
    perf_info['record'] = perf_ref.elements
    perf_info['linkedStates'] = dbm.retrieve_all_state_perf_links(uuid)
    perf_info['availablePerformances'] = [dict(p.get_element_items()) for p in dbm.retrieve_derived_performances(perf_ref['game_uuid'])]
    return jsonify(perf_info)
开发者ID:gamecip,项目名称:citetool-editor,代码行数:9,代码来源:app.py

示例3: performance_update

# 需要导入模块: from database import DatabaseManager [as 别名]
# 或者: from database.DatabaseManager import retrieve_perf_ref [as 别名]
def performance_update(uuid):
    update_fields = json.loads(request.form.get('update_fields'))
    dbm.update_table(dbm.PERFORMANCE_CITATION_TABLE, update_fields.keys(), update_fields.values(), ["uuid"], [uuid])
    perf_ref = dbm.retrieve_perf_ref(uuid)
    #dbm.update_table(dbm.FTS_INDEX_TABLE, ['content'], [perf_ref.to_json_string()],["uuid"], [uuid])
    return perf_ref.to_json_string()
开发者ID:gamecip,项目名称:citetool-editor,代码行数:8,代码来源:app.py

示例4: delete

# 需要导入模块: from database import DatabaseManager [as 别名]
# 或者: from database.DatabaseManager import retrieve_perf_ref [as 别名]
def delete(ctx, uuid, keep_performances):
    no_prompts = ctx.obj['NO_PROMPTS']
    verbose = ctx.obj['VERBOSE']

    def check_delete(path):
        try:
            shutil.rmtree(path)
        except OSError as e:
            print e.message

    def delete_from_fts(uuid):
        ix = open_dir(LOCAL_FTS_INDEX)
        writer = ix.writer()
        writer.delete_by_term('id', uuid)
        writer.commit()

    game_ref = dbm.retrieve_game_ref(uuid)
    perf_ref = dbm.retrieve_perf_ref(uuid)
    state_ref = dbm.retrieve_save_state(uuid=uuid)
    if game_ref:
        perfs = dbm.retrieve_derived_performances(uuid)
        states = dbm.retrieve_save_state(game_uuid=uuid)
        files = dbm.retrieve_file_path(game_uuid=uuid)

        for f in files:
                check_delete(os.path.join(LOCAL_DATA_ROOT, LOCAL_GAME_DATA_STORE, f['source_data']))
        dbm.delete_from_table(dbm.GAME_FILE_PATH_TABLE, ['game_uuid'], [uuid])

        for s in states:
            if s['save_state_source_data']:
                check_delete(os.path.join(LOCAL_DATA_ROOT, LOCAL_CITATION_DATA_STORE, s['save_state_source_data']))
            else:
                if s['rl_starts_data']:
                    check_delete(os.path.join(LOCAL_DATA_ROOT, LOCAL_CITATION_DATA_STORE, s['rl_starts_data']))
                    check_delete(os.path.join(LOCAL_DATA_ROOT, LOCAL_CITATION_DATA_STORE, s['rl_lengths_data']))
            if s['has_screen']:
                check_delete(os.path.join(LOCAL_DATA_ROOT, LOCAL_CITATION_DATA_STORE, s['uuid']))
        dbm.delete_from_table(dbm.GAME_SAVE_TABLE, ['game_uuid'], [uuid])

        for p in perfs:
            if p['replay_source_file_ref']:
                check_delete(os.path.join(LOCAL_DATA_ROOT, LOCAL_CITATION_DATA_STORE, p['replay_source_file_ref']))
            dbm.delete_from_table(dbm.SAVE_STATE_PERFORMANCE_LINK_TABLE,['performance_uuid'], [p['uuid']])
        dbm.delete_from_table(dbm.PERFORMANCE_CITATION_TABLE, ['game_uuid'], [uuid])

        if game_ref['source_data']:
            check_delete(os.path.join(LOCAL_DATA_ROOT, LOCAL_GAME_DATA_STORE, game_ref['source_data']))

        dbm.delete_from_table(dbm.GAME_CITATION_TABLE, ['uuid'], [uuid])
        delete_from_fts(uuid)
    elif perf_ref:
        dbm.delete_from_table(dbm.SAVE_STATE_PERFORMANCE_LINK_TABLE,['performance_uuid'], [uuid])
        if perf_ref['replay_source_file_ref']:
            check_delete(os.path.join(LOCAL_DATA_ROOT, LOCAL_CITATION_DATA_STORE, perf_ref['replay_source_file_ref']))
        dbm.delete_from_table(dbm.PERFORMANCE_CITATION_TABLE, ['uuid'], [uuid])
        delete_from_fts(uuid)
    elif state_ref:
        state_ref = state_ref[0] # retrieve states returns lists
        files = dbm.retrieve_file_path(save_state_uuid=uuid)
        for f in files:
            check_delete(os.path.join(LOCAL_DATA_ROOT, LOCAL_GAME_DATA_STORE, f['source_data']))
        dbm.delete_from_table(dbm.SAVE_STATE_PERFORMANCE_LINK_TABLE,['save_state_uuid'], [uuid])
        if state_ref['has_screen']:
            check_delete(os.path.join(LOCAL_DATA_ROOT, LOCAL_CITATION_DATA_STORE, state_ref['uuid']))
        dbm.delete_from_table(dbm.GAME_SAVE_TABLE, ['uuid'], [uuid])
        delete_from_fts(uuid)
    else:
        click.echo('UUID {} not found.'.format(uuid))
        sys.exit(1)
开发者ID:gamecip,项目名称:citetool-editor,代码行数:71,代码来源:citetool_editor.py

示例5: gif_performance

# 需要导入模块: from database import DatabaseManager [as 别名]
# 或者: from database.DatabaseManager import retrieve_perf_ref [as 别名]
def gif_performance(ctx, uuid, start, end, regenerate):
    verbose = ctx.obj['VERBOSE']
    #   Peformance retrieval
    perf = dbm.retrieve_perf_ref(uuid)

    if not perf:
        click.echo('Invalid performance uuid: {}'.format(uuid))
        sys.exit(1)

    cond_print(verbose, "Found performance: {}, '{}'".format(uuid, perf['title']))

    #   GIF creation
    gif_source_path = "'{}/{}/{}'".format(os.path.abspath(LOCAL_CITATION_DATA_STORE),
                                          perf['replay_source_file_ref'],
                                          perf['replay_source_file_name'])
    gif_abs_path = "{}/{}".format(os.path.abspath(LOCAL_CITATION_DATA_STORE),
                                         perf['replay_source_file_ref'])
    gif_palette_name = "{}_{}_{}_palette.png".format(uuid, start, end)
    gif_file_name = "{}_{}_{}.gif".format(uuid, start, end)

    #   All commands are just straight defaults for now, basic settings are:
    #   FPS: 10
    #   Height: 320
    #   Width: Scale to height
    ffmpeg_palette = '/usr/local/bin/ffmpeg -y -ss {} -t {} -i {} -vf fps=10,scale=320:-1:flags=lanczos,palettegen {}'.format(
        start,
        end - start,
        gif_source_path,
        "'{}/{}'".format(gif_abs_path, gif_palette_name)
    )
    ffmpeg_gif = '/usr/local/bin/ffmpeg -ss {} -t {} -i {} -i {} -filter_complex "fps=10,scale=320:-1:flags=lanczos[x];[x][1:v]paletteuse" {}'.format(
        start,
        end - start,
        gif_source_path,
        "'{}/{}'".format(gif_abs_path, gif_palette_name),
        "'{}/{}'".format(gif_abs_path, gif_file_name)
    )

    #   Check if gif is already present, and remove if regenerate flag is set
    if os.path.isdir(gif_abs_path) and regenerate:
        cond_print(verbose, "--regenerate flag active, deleting previous gif information")
        shutil.rmtree(gif_abs_path)
    elif os.path.isdir(gif_abs_path):
        click.echo('Gif for that time index already present, please use --regenerate to override this message.')
        sys.exit(1)

    #   Create gif directory
    cond_print(verbose, "Creating gif directory at {}".format(gif_abs_path))
    os.makedirs(gif_abs_path)

    #   Run gif creation processes
    cond_print(verbose, "Running gif creation processes...")
    cond_print(verbose, "{}".format(ffmpeg_palette))
    try:
        subprocess.check_call(ffmpeg_palette, shell=True)
    except subprocess.CalledProcessError as e:
        click.echo(e.message)
        sys.exit(1)

    cond_print(verbose, "{}".format(ffmpeg_gif))
    try:
        subprocess.check_call(ffmpeg_gif, shell=True)
    except subprocess.CalledProcessError as e:
        click.echo(e.message)
        sys.exit(1)

    cond_print(verbose, "Success!")
开发者ID:gamecip,项目名称:citetool-editor,代码行数:69,代码来源:citetool_editor.py


注:本文中的database.DatabaseManager.retrieve_perf_ref方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。