Exemplo n.º 1
0
def assign_contract(agent_id, target_id, bounty):
    with connection.cursor() as cursor:
        cursor.execute(sql.ASSIGN_CONTRACT,
                       args={
                           'agent_id': agent_id,
                           'target_id': target_id,
                           'bounty': bounty
                       })
    connection.commit()
Exemplo n.º 2
0
def create_agents(bucket, key):
    logger.info('Loading player data from s3://%s/%s', bucket, key)
    obj = s3.Object(bucket_name=bucket, key=key)
    lines = obj.get()['Body'].read().split('\n')
    data = [line for line in DictReader(lines)]

    logger.info('Inserting %s players', len(data))

    with connection.cursor() as cursor:
        cursor.executemany(sql.ADD_PLAYERS, data)
    connection.commit()

    logger.info('Player load complete')
Exemplo n.º 3
0
def assign_codenames(agents_and_codenames):
    logger.info('Beginning codename assignment')
    case_clause_template = 'WHEN {agent_id} THEN "{codename}"'
    case_clauses = []
    agent_ids = []
    for agent, codename in agents_and_codenames:
        logger.info('Attempting to assign codename "%s" to agent %s', codename,
                    agent.id)
        agent_ids.append(agent.id)
        case_clauses.append(
            case_clause_template.format(agent_id=agent.id, codename=codename))

    case_clauses = ' '.join(case_clauses)

    update_sql = sql.ASSIGN_CODENAMES_TO_AGENTS.format(cases=case_clauses)
    with connection.cursor() as cursor:
        cursor.execute(update_sql, args={'agent_ids': agent_ids})
    connection.commit()

    logger.info('Codename assignment was successful')
Exemplo n.º 4
0
def assign_multiple_contracts(contract_params):
    with connection.cursor() as cursor:
        cursor.executemany(sql.ASSIGN_CONTRACT, args=contract_params)
    connection.commit()
Exemplo n.º 5
0
def revive_assassinated_agents():
    logger.info('Reviving all assassinated agents')
    with connection.cursor() as cursor:
        cursor.execute(sql.REVIVE_ASSASSINATED_AGENTS)
    connection.commit()
    logger.info('Player revival was successful')