def rabbit_with_log(papers, check_invalid_papers, log_comment, partial=False):
    from invenio.bibauthorid_rabbit import rabbit

    personids_to_update_extids = _get_personids_to_update_extids(papers)
    starting_time = get_sql_time()
    rabbit(papers, check_invalid_papers, personids_to_update_extids)
    if partial:
        action = 'PID_UPDATE_PARTIAL'
    else:
        action = 'PID_UPDATE'
    insert_user_log('daemon', '-1', action, 'bibsched', 'status', comment=log_comment, timestamp=starting_time)
def run_tortoise(from_scratch):
    from invenio.bibauthorid_tortoise import tortoise, tortoise_from_scratch

    if from_scratch:
        tortoise_from_scratch()
    else:
        start_time = get_sql_time()
        tortoise_db_name = 'tortoise'

        last_run = get_user_log(userinfo=tortoise_db_name, only_most_recent=True)
        if last_run:
            modified = get_recently_modified_record_ids(last_run[0][2])
        else:
            modified = []
        tortoise(modified)

    insert_user_log(tortoise_db_name, '-1', '', '', '', timestamp=start_time)