Esempio n. 1
0
    def __init__(self, dbPath, dbName):
        self.database = dbPath + dbName
        self.dataPath = dbPath
        self.visits = Visits()
        self.guests = Guests()
        self.reports = Reports(self)
        self.teams = Teams()
        self.accounts = Accounts()
        self.devices = Devices()
        self.unlocks = Unlocks()
        # needs path since it will open read only
        self.customReports = CustomReports(self.database)
        self.certifications = Certifications()
        self.members = Members()
        self.logEvents = LogEvents()

        if not os.path.exists(self.database):
            if not os.path.exists(dbPath):
                os.mkdir(dbPath)
            with self.dbConnect() as c:
                self.migrate(c, 0)
        else:
            with self.dbConnect() as c:
                data = c.execute('PRAGMA schema_version').fetchone()
                if data[0] != SCHEMA_VERSION:
                    self.migrate(c, data[0])
Esempio n. 2
0
    def __init__(self, screen, messages_to_send, our_team,
                 our_team_first_move):
        self.game_state = STATE_PREPARING
        self.images = {
            'ocean': pygame.image.load('ocean.jpg').convert(),
            'explosion': pygame.image.load('explosion.jpg').convert(),
            'ship': pygame.image.load('battleship.jpg').convert()
        }
        self.our_board = Board(pygame.freetype.Font, GAME_SIZE, 5, 0,
                               self.images)

        self.load_positions_button = Button(
            "Load", 10, 750, self.our_board.load_positions_from_file)
        self.messages_to_send = messages_to_send
        self.our_team = our_team
        self.our_team_first_move = our_team_first_move
        self.save_positions_button = Button(
            "Save", 70, 750, self.our_board.save_positions_to_file)
        self.start_game_button = Button("Start", 130, 750, self.start_game)
        self.status_bar = StatusBar()
        self.screen = screen
        self.selected_their_team = None
        self.selected_their_team_first_move = None
        self.start_game_button.set_enabled(False)
        self.status_bar.update_text(
            'Choose your positions, an opponent, and click Start.')
        self.teams = Teams()
        self.their_board = Board(pygame.freetype.Font, GAME_SIZE, 580, 0,
                                 self.images)
        self.their_team = None
Esempio n. 3
0
def generate_teams(player_list):
    team_list = []
    for i in range(simulations):
        random.shuffle(player_list)
        team = Teams(player_list[:len(player_list) // 2],
                     player_list[len(player_list) // 2:], i)
        if team.valid():
            team_list.append(team)
    return team_list
def lambda_handler(event, context):
    teams = Teams()
    try:
        domain = os.environ.get('BACKLOG_DOMAIN', '')

        for record in event['Records']:
            message_body = json.loads(record['body'])
            message = json.loads(message_body['Message'])

            logger.info(message)

            project = get_value(message, 'project')
            content = get_value(message, 'content')
            createdUser = get_value(message, 'createdUser')

            project_name = get_value(project, 'name')
            projectKey = get_value(project, 'projectKey')
            key_id = get_value(content, 'key_id')
            summary = get_value(content, 'summary')
            milestone_array = get_value(content, 'milestone')
            if len(milestone_array) > 0:
                milestone = get_value(milestone_array[0], 'name')
            else:
                milestone = ''
            estimatedHours = round(get_value(content, 'estimatedHours'), 2)
            actualHours = round(get_value(content, 'actualHours'), 2)
            comment = get_value(get_value(content, 'comment'), 'content')
            status = get_value(get_value(content, 'status'), 'name')
            user = get_value(createdUser, 'name')
            assignee = get_value(get_value(content, 'assignee'), 'name')

            changes = get_value(content, 'changes')

            url = 'https://{domain}/view/{projectKey}-{key_id}'.format(
                domain=domain, projectKey=projectKey, key_id=key_id)
            url_tag = '<a href="{url}">{url}</a>'.format(url=url)

            response = teams.send_message(
                '{summary} ({milestone})'.format(summary=summary,
                                                 milestone=milestone),
                '<b>対応状況:</b> {status}<br><b>担当:</b> {assignee}<br><b>実績時間:</b> {actualHours}<br><b>予定時間:</b> {estimatedHours}<br>{url}<br><b>更新者:</b> {user}<br>{comment}{changes}'
                .format(status=status,
                        user=user,
                        comment=get_comment(comment),
                        actualHours=actualHours,
                        estimatedHours=estimatedHours,
                        url=url_tag,
                        assignee=assignee,
                        changes=get_changes(changes)))

            logger.info(response)
            logger.info(response.text)

    except:
        logger.error(traceback.format_exc())
        raise Exception(traceback.format_exc())
Esempio n. 5
0
def teamsPage():
    page = Teams(dsn = app.config['dsn'])
    if request.method == 'GET':
        page.createTable();
        return page.loadPage()
    elif 'addTeam' in request.form:
        name = request.form['name']
        country = request.form['country']
        constructor = request.form['constructor']
        motorcycle = request.form['motorcycle']
        riderNo = request.form['riderNo']
        return page.addTeam(name, country, constructor, motorcycle, riderNo)
    elif 'initTable' in request.form:
        return page.initTable()
    elif 'updateTeam' in request.form:
        id = request.form['id']
        name = request.form['name']
        country = request.form['country']
        constructor = request.form['constructor']
        motorcycle = request.form['motorcycle']
        riderNo = request.form['riderNo']
        return page.updateTeam(id, name, country, constructor, motorcycle, riderNo)
    elif 'deleteTeam' in request.form:
        id = request.form['id']
        return page.deleteTeamId(id)
    elif 'searchTeam' in request.form:
        name = request.form['name']
        country = request.form['country']
        constructor = request.form['constructor']
        motorcycle = request.form['motorcycle']
        return page.searchTeam(name, country, constructor, motorcycle)
def lambda_handler(event, context):
    teams = Teams()
    try:
        domain = os.environ.get('BACKLOG_DOMAIN', '')
        milestone = int(os.environ.get('QA_MILESTONE', '0'))

        for record in event['Records']:
            message_body = json.loads(record['body'])
            message = json.loads(message_body['Message'])

            project = get_value(message, 'project')
            content = get_value(message, 'content')
            createdUser = get_value(message, 'createdUser')

            milestone_array = get_value(content, 'milestone')
            if len(milestone_array) > 0:
                milestone_id = get_value(milestone_array[0], 'id')
            else:
                return

            if milestone_id != milestone:
                return

            projectKey = get_value(project, 'projectKey')
            key_id = get_value(content, 'key_id')

            description = get_value(content, 'description')

            comment = get_value(get_value(content, 'comment'), 'content')
            user = get_value(createdUser, 'name')

            url = 'https://{domain}/view/{projectKey}-{key_id}'.format(
                domain=domain,
                projectKey=projectKey,
                key_id=key_id
            )
            url_tag = '<a href="{url}">{url}</a>'.format(
                url=url
            )

            teams.send_message(
                '回答',
                '**質問**:{description}<br><br>**{user}の回答**:{comment}<br><br>{url}'.format(
                    description=description,
                    user=user,
                    comment=comment,
                    url=url_tag
                )
            )
    except:
        logger.error(traceback.format_exc())
        raise Exception(traceback.format_exc())
 def __init__(self, dict_info={}):
     if dict_info != {}:
         if "gameCreation" in dict_info.keys():
             self.gameCreation = dict_info["gameCreation"]
         if "gameDuration" in dict_info.keys():
             self.gameDuration = dict_info["gameDuration"]
         if "gameId" in dict_info.keys():
             self.gameId = dict_info["gameId"]
         if "gameMode" in dict_info.keys():
             self.gameMode = dict_info["gameMode"]
         if "gameType" in dict_info.keys():
             self.gameType = dict_info["gameType"]
         if "gameVersion" in dict_info.keys():
             self.gameVersion = dict_info["gameVersion"]
         if "mapId" in dict_info.keys():
             self.mapId = dict_info["mapId"]
         if "platformId" in dict_info.keys():
             self.platformId = dict_info["platformId"]
         if "queueId" in dict_info.keys():
             self.queueId = dict_info["queueId"]
         if "seasonId" in dict_info.keys():
             self.seasonId = dict_info["seasonId"]
         if "participantIdentities" in dict_info.keys():
             self.participantIdentities = [ParticipantIdentities(p) for p in dict_info["participantIdentities"]]
         if "participants" in dict_info.keys():
             self.participants = [Participants(p) for p in dict_info["participants"]]
         if "teams" in dict_info.keys():
             self.teams = [Teams(p) for p in dict_info["teams"]]
Esempio n. 8
0
def main():

    team = Teams(input('Name player 1:'))
    dice_rolls = int(input('How many dice would you like to roll? '))
    dice_size = int(input('How many sides are th dice? '))
    dice_sum = 0

    for i in range(0, dice_rolls):
        roll = random.randint(1, dice_size)
        dice_sum += roll
        team.team_score += roll
        if (roll == 1):
            print(f'You rolled a {roll}! Critical Fail.')
        elif (roll == dice_size):
            print(f'You rolled a {roll}! Critical Success!.')
        else:
            print(f'You rolled a {roll}')
    print(f'You have rolled a total of {dice_sum}!')
    team.description()
    input('Press any key to Exit')
Esempio n. 9
0
def team_page():
    tems = Teams(app.config['dsn'])
    if request.method == 'GET':
        now = datetime.datetime.now()
        temlist = tems.get_teamlist()
        return render_template('teams.html', TeamList = temlist, current_time=now.ctime())
    elif 'teams_to_delete' in request.form:
        id_teams = request.form.getlist('teams_to_delete')
        for id_team in id_teams:
            tems.delete_team(id_team)
        return redirect(url_for('team_page'))
    elif 'teams_to_add' in request.form:
        tems.add_team(request.form['country'])
        return redirect(url_for('team_page'))
    elif 'teams_to_update' in request.form:
        tems.update_team(request.form['id_team'], request.form['country'])
        return redirect(url_for('team_page'))
    elif 'teams_to_search' in request.form:
            searchList = tems.search_team(request.form['name']);
            now = datetime.datetime.now()
            temlist = tems.get_teamlist()
            return render_template('teams.html', TeamList = temlist, SearchList = searchList, current_time=now.ctime())
class CompleteGame:
    gameCreation = 0
    gameDuration = 0
    gameId = 0
    gameMode = ""
    gameType = ""
    gameVersion = ""
    mapId = 0
    platformId = ""
    queueId = 0
    seasonId = 0
    participantIdentities = [ParticipantIdentities()]
    teams = [Teams()]
    participants = [Participants()]

    def __init__(self, dict_info={}):
        if dict_info != {}:
            if "gameCreation" in dict_info.keys():
                self.gameCreation = dict_info["gameCreation"]
            if "gameDuration" in dict_info.keys():
                self.gameDuration = dict_info["gameDuration"]
            if "gameId" in dict_info.keys():
                self.gameId = dict_info["gameId"]
            if "gameMode" in dict_info.keys():
                self.gameMode = dict_info["gameMode"]
            if "gameType" in dict_info.keys():
                self.gameType = dict_info["gameType"]
            if "gameVersion" in dict_info.keys():
                self.gameVersion = dict_info["gameVersion"]
            if "mapId" in dict_info.keys():
                self.mapId = dict_info["mapId"]
            if "platformId" in dict_info.keys():
                self.platformId = dict_info["platformId"]
            if "queueId" in dict_info.keys():
                self.queueId = dict_info["queueId"]
            if "seasonId" in dict_info.keys():
                self.seasonId = dict_info["seasonId"]
            if "participantIdentities" in dict_info.keys():
                self.participantIdentities = [ParticipantIdentities(p) for p in dict_info["participantIdentities"]]
            if "participants" in dict_info.keys():
                self.participants = [Participants(p) for p in dict_info["participants"]]
            if "teams" in dict_info.keys():
                self.teams = [Teams(p) for p in dict_info["teams"]]

    def __str__(self):
        return "GameId: " + str(self.gameId) + "\n" + \
               "GameDuration: " + duration_game_str(self.gameDuration) + "\n" + \
               "GameMode: " + str(self.gameMode) + "\n" + \
               "GameType: " + str(self.gameType) + "\n" + \
               "QueueId: " + queue_str(self.queueId) + "\n" + \
               "SeasonId: " + season_str(self.seasonId)
def main():
    print("""######\tTests players.py\t######""")
    a = Players()
    a.see_all()

    print("""######\tTests PlayerStats\t######""")
    b = PlayerStats(a)
    b.see_all()
    print()

    print("""######\tTests Events\t######""")
    d = Events()
    d.see_all()
    print()

    print("""######\tTests Teams\t######""")
    c = Teams(a, d)
    c.see_all()
    print()

    print("""######\tTests Awards\t######""")
    e = Awards()
    e.see_all()
    print()
Esempio n. 12
0
 def __init__(self, app):
     self.app = app
     self.app.teams = Teams(app)
     self.app.players = Players(app)
     self.app.seasons = Seasons2(app)
Esempio n. 13
0
        )
        rows = cursor.fetchall()
        for row in rows:
            if row[1] != "pg_stat_statements":
                cursor.execute("drop table " + row[1] + " cascade")

        connection.commit()
    return redirect(url_for('create_tables'))


if __name__ == '__main__':
    '''Container objects'''

    app.coaches = Coaches2(app)
    app.coaching = Coaching2(app)
    app.teams = Teams(app)
    app.players = Players(app)
    app.countries = Countries(app)
    app.leagues = Leagues(app)
    app.stadiums = Stadiums(app)
    app.officials = Officials(app)
    app.seasons = Seasons2(app)
    app.matches = Matches(app)
    app.statisticsTeam = StatisticsT(app)
    app.statisticsPlayer = StatisticsP(app)
    app.fixtures = Fixtures(app)
    app.squads = Squads(app)
    app.transfers = Transfers(app)

    VCAP_APP_PORT = os.getenv('VCAP_APP_PORT')
    if VCAP_APP_PORT is not None:
Esempio n. 14
0
class Game:
    def __init__(self, screen, messages_to_send, our_team,
                 our_team_first_move):
        self.game_state = STATE_PREPARING
        self.images = {
            'ocean': pygame.image.load('ocean.jpg').convert(),
            'explosion': pygame.image.load('explosion.jpg').convert(),
            'ship': pygame.image.load('battleship.jpg').convert()
        }
        self.our_board = Board(pygame.freetype.Font, GAME_SIZE, 5, 0,
                               self.images)

        self.load_positions_button = Button(
            "Load", 10, 750, self.our_board.load_positions_from_file)
        self.messages_to_send = messages_to_send
        self.our_team = our_team
        self.our_team_first_move = our_team_first_move
        self.save_positions_button = Button(
            "Save", 70, 750, self.our_board.save_positions_to_file)
        self.start_game_button = Button("Start", 130, 750, self.start_game)
        self.status_bar = StatusBar()
        self.screen = screen
        self.selected_their_team = None
        self.selected_their_team_first_move = None
        self.start_game_button.set_enabled(False)
        self.status_bar.update_text(
            'Choose your positions, an opponent, and click Start.')
        self.teams = Teams()
        self.their_board = Board(pygame.freetype.Font, GAME_SIZE, 580, 0,
                                 self.images)
        self.their_team = None

    def can_start_game(self):
        return self.selected_their_team is not None and self.our_board.is_valid(
        )

    def start_game(self):
        self.their_team = self.selected_their_team
        state = STATE_OUR_TURN if self.our_team_first_move > self.selected_their_team_first_move else STATE_THEIR_TURN
        self.change_game_state(state)

    def change_game_state(self, state):
        self.game_state = state
        if state == STATE_OUR_TURN:
            self.status_bar.update_text("It's your move. Good luck!")
        elif state == STATE_OUR_WIN:
            self.status_bar.update_text("Congratulations! You win!")
        elif state == STATE_THEIR_WIN:
            self.status_bar.update_text("You lost. Maybe next time.")
        else:
            self.status_bar.update_text(
                'Waiting for %s to make their move...' % self.their_team)
        pygame.event.post(
            pygame.event.Event(
                pygame.USEREVENT,
                dict(action=ACTION_GAME_STATE_CHANGED, state=state)))

    def handle_event(self, event):
        if event.type == pygame.KEYDOWN:
            print("Down!")

        elif event.type == pygame.MOUSEBUTTONUP:
            if self.save_positions_button.check_click(event.pos[0],
                                                      event.pos[1]) == HANDLED:
                pass
            elif self.load_positions_button.check_click(
                    event.pos[0], event.pos[1]) == HANDLED:
                pass
            elif self.game_state == STATE_PREPARING \
                    and self.our_board.toggle_ship_click(event.pos[0], event.pos[1]) == HANDLED:
                self.start_game_button.set_enabled(self.can_start_game())
            else:
                if self.game_state == STATE_PREPARING:
                    self.teams.check_click(event.pos[0], event.pos[1])
                    self.start_game_button.check_click(event.pos[0],
                                                       event.pos[1])
                else:
                    self.their_board.make_move_click(event.pos[0],
                                                     event.pos[1])

        elif event.type == pygame.USEREVENT:
            if event.action == ACTION_FIND_ME:
                if not event.team == self.our_team:
                    self.teams.found_team(event.team, event.row)

            elif event.action == ACTION_HIT and event.team == self.their_team:
                self.their_board.record_hit(event.row, event.col)
                if self.their_board.is_wiped_out():
                    self.change_game_state(STATE_OUR_WIN)
                else:
                    self.change_game_state(STATE_THEIR_TURN)

            elif event.action == ACTION_MAKE_MOVE and self.game_state == STATE_OUR_TURN:
                self.messages_to_send.put(
                    '%s|%s|%d|%d' %
                    (self.our_team, ACTION_MOVE, event.row, event.col))

            elif event.action == ACTION_MISS and event.team == self.their_team:
                self.their_board.record_miss(event.row, event.col)
                self.change_game_state(STATE_THEIR_TURN)

            elif event.action == ACTION_MOVE:
                if event.team == self.their_team and self.our_board.check_move(
                        event.row, event.col) == HANDLED:
                    if self.our_board.is_wiped_out():
                        self.change_game_state(STATE_THEIR_WIN)
                    else:
                        self.change_game_state(STATE_OUR_TURN)

            elif event.action == ACTION_SELECT_TEAM:
                self.selected_their_team = event.team
                self.selected_their_team_first_move = event.first_move_number
                self.start_game_button.set_enabled(self.can_start_game())

            elif event.action == ACTION_STATUS:
                self.status_bar.update_text(event.text)

            elif event.action == ACTION_WE_GOT_HIT:
                self.messages_to_send.put(
                    '%s|%s|%d|%d' %
                    (self.our_team, ACTION_HIT, event.row, event.col))

            elif event.action == ACTION_WE_WERE_MISSED:
                self.messages_to_send.put(
                    '%s|%s|%d|%d' %
                    (self.our_team, ACTION_MISS, event.row, event.col))

        self.screen.fill(DARK_BLUE)
        self.our_board.draw(self.screen)
        self.status_bar.draw(self.screen)

        if self.game_state == STATE_PREPARING:
            self.save_positions_button.draw(self.screen)
            self.load_positions_button.draw(self.screen)
            self.start_game_button.draw(self.screen)
            self.teams.draw(self.screen)
        else:
            self.their_board.draw(self.screen)
Esempio n. 15
0
for table in range(int(len(st_body) / 2)):
    team_list = st_body[table].find_all('tr')[2:]

    for t in team_list:
        name = t.find('a').contents[0]
        link = t.find('a')['href']
        team_id = link[link.find('teamId=') +
                       len('teamId='):link.find('seasonId') - 1]
        title = t.find('a')['title']
        owner = title[title.find('(') + 1:title.find(')')]
        wins = t.find_all('td')[1].contents[0]
        losses = t.find_all('td')[2].contents[0]
        ties = t.find_all('td')[3].contents[0]
        win_perc = t.find_all('td')[4].contents[0]
        ffl_teams.append(
            Teams(name, owner, link, team_id, wins, losses, ties, win_perc))
#        print(name)

#end t for
#end table for

#sort teams by team_id
ffl_teams = sorted(ffl_teams, key=lambda teams: teams.team_id)

t_id = []
t_name = []
t_actual_wlp = []
for t in ffl_teams:
    #    print(t)
    t_id.append(t.team_id)
    t_name.append(t.name)
Esempio n. 16
0
def lambda_handler(event, context):
    teams = Teams()
    try:
        s3 = boto3.resource('s3')
        bucket_name = os.environ.get('BUCKET_NAME', None)

        for record in event['Records']:
            message_body = json.loads(record['body'])
            message = json.loads(message_body['Message'])

            project = get_value(message, 'project')
            content = get_value(message, 'content')

            projectKey = get_value(project, 'projectKey')
            key_id = get_value(content, 'key_id')

            object_key = '{projectKey}-{key_id}.json'.format(
                projectKey=projectKey,
                key_id=key_id
            )

            obj = s3.Object(
                bucket_name,
                object_key
            )

            milestone_array = get_value(content, 'milestone')
            if len(milestone_array) > 0:
                milestone = get_value(milestone_array[0], 'name')
            else:
                milestone = ''
            estimatedHours = get_value(content, 'estimatedHours')
            actualHours = get_value(content, 'actualHours')
            status = get_value(get_value(content, 'status'), 'name')
            assignee = get_value(get_value(content, 'assignee'), 'name')
            issueType = get_value(get_value(content, 'issueType'), 'name')
            startDate = get_value(content, 'startDate')
            dueDate = get_value(content, 'dueDate')
            summary = get_value(content, 'summary')

            ticket_json = {
                'milestone': milestone,
                'estimatedHours': estimatedHours,
                'actualHours': actualHours,
                'status': status,
                'assignee': assignee,
                'issueType': issueType,
                'startDate': startDate,
                'dueDate': dueDate,
                'summary': summary
            }

            response = obj.put(
                Body=json.dumps(ticket_json)
            )

            logger.info(response)

    except:
        logger.error(traceback.format_exc())
        teams.send_message(
            'Error',
            traceback.format_exc()
        )
        raise Exception(traceback.format_exc())
Esempio n. 17
0
class Engine(object):
    def __init__(self, dbPath, dbName):
        self.database = dbPath + dbName
        self.dataPath = dbPath
        self.visits = Visits()
        self.guests = Guests()
        self.reports = Reports(self)
        self.teams = Teams()
        self.accounts = Accounts()
        self.devices = Devices()
        self.unlocks = Unlocks()
        # needs path since it will open read only
        self.customReports = CustomReports(self.database)
        self.certifications = Certifications()
        self.members = Members()
        self.logEvents = LogEvents()

        if not os.path.exists(self.database):
            if not os.path.exists(dbPath):
                os.mkdir(dbPath)
            with self.dbConnect() as c:
                self.migrate(c, 0)
        else:
            with self.dbConnect() as c:
                data = c.execute('PRAGMA schema_version').fetchone()
                if data[0] != SCHEMA_VERSION:
                    self.migrate(c, data[0])

    def dbConnect(self):
        return sqlite3.connect(self.database,
                               detect_types=sqlite3.PARSE_DECLTYPES)

    def migrate(self, dbConnection, db_schema_version):
        if db_schema_version < SCHEMA_VERSION:
            self.visits.migrate(dbConnection, db_schema_version)
            self.members.migrate(dbConnection, db_schema_version)
            self.guests.migrate(dbConnection, db_schema_version)
            self.teams.migrate(dbConnection, db_schema_version)
            self.customReports.migrate(dbConnection, db_schema_version)
            self.certifications.migrate(dbConnection, db_schema_version)
            self.accounts.migrate(dbConnection, db_schema_version)
            self.devices.migrate(dbConnection, db_schema_version)
            self.unlocks.migrate(dbConnection, db_schema_version)
            self.logEvents.migrate(dbConnection, db_schema_version)
            dbConnection.execute('PRAGMA schema_version = ' +
                                 str(SCHEMA_VERSION))
        elif db_schema_version != SCHEMA_VERSION:  # pragma: no cover
            raise Exception("Unknown DB schema version" +
                            str(db_schema_version) + ": " + self.database)

    def injectData(self, dictValues):
        areas = {
            "visits": self.visits,
            "members": self.members,
            "guests": self.guests,
            "teams": self.teams,
            "customReports": self.customReports,
            "certifications": self.certifications,
            "accounts": self.accounts,
            "devices": self.devices,
            "unlocks": self.unlocks,
            "logEvents": self.logEvents
        }

        for (key, member) in areas.items():
            if key in dictValues:
                with self.dbConnect() as dbConnection:
                    member.injectData(dbConnection, dictValues[key])

    def getGuestLists(self, dbConnection):
        all_guests = self.guests.getList(dbConnection)

        building_guests = self.reports.guestsInBuilding(dbConnection)

        guests_not_here = [
            guest for guest in all_guests if guest not in building_guests
        ]

        return (building_guests, guests_not_here)
Esempio n. 18
0
 def __init__(self, app):
     self.app = app
     self.app.teams = Teams(app)
     self.app.officials = Officials(app)
     self.app.seasons = Seasons2(app)
Esempio n. 19
0
 def team_ids_dict(self):
     team_ids_dict = dict(
         zip(list(Teams().teams_dataframe()['team_name']),
             list(Teams().teams_dataframe().index)))
     return team_ids_dict
Esempio n. 20
0
            p.add_match_with_player(q, False)


if __name__ == "__main__":
    # load history
    print(
        "\nBalance   Strength  Adv             Azul X Vermelho      Winner   AA  AD  AS  VA  VD  VS  Avg."
    )
    for game in games:
        blue = [[q for q in players if q.name == p][0]
                for p in game['Azul']['players']]
        red = [[q for q in players if q.name == p][0]
               for p in game['Vermelho']['players']]
        score_blue = game['Azul']['score']
        score_red = game['Vermelho']['score']
        teams = Teams(blue, red, 0, [score_blue, score_red])
        tie = []
        if score_blue == score_red:
            blue_result = 0
            red_result = 0
        else:
            blue_result = 1 if score_blue > score_red else -1
            red_result = 1 if score_red > score_blue else -1
        for p in blue:
            p.add_match_result(blue_result)
        for p in red:
            p.add_match_result(red_result)
        update_matches(teams.team_a, teams.team_b)
        update_matches(teams.team_b, teams.team_a)
        print(teams)
Esempio n. 21
0
def lambda_handler(event, context):
    teams = Teams()
    try:
        s3 = boto3.resource('s3')
        bucket_name = os.environ.get('BUCKET_NAME', None)
        api_url = os.environ.get('API_URL', None)
        api_key = os.environ.get('API_KEY', None)
        project_id = os.environ.get('PROJECT_ID', None)
        offset = 0

        backlog_url = '{api_url}?apiKey={api_key}&projectId[]={project_id}&statusId[]=4&count=100&sort=keyId&order=asc&offset='.format(
            api_url=api_url, api_key=api_key, project_id=project_id)

        issues = requests.get(backlog_url + str(offset))

        while len(issues) > 0:

            for record in issues:
                message_body = json.loads(record['body'])
                message = json.loads(message_body['Message'])

                project = get_value(message, 'project')
                content = get_value(message, 'content')

                projectKey = get_value(project, 'projectKey')
                key_id = get_value(content, 'key_id')
                offset = key_id

                object_key = '{projectKey}-{key_id}.json'.format(
                    projectKey=projectKey, key_id=key_id)

                obj = s3.Object(bucket_name, object_key)

                milestone_array = get_value(content, 'milestone')
                if len(milestone_array) > 0:
                    milestone = get_value(milestone_array[0], 'name')
                else:
                    milestone = ''
                estimatedHours = get_value(content, 'estimatedHours')
                actualHours = get_value(content, 'actualHours')
                status = get_value(get_value(content, 'status'), 'name')
                assignee = get_value(get_value(content, 'assignee'), 'name')
                issueType = get_value(get_value(content, 'issueType'), 'name')
                startDate = get_value(content, 'startDate')
                dueDate = get_value(content, 'dueDate')
                summary = get_value(content, 'summary')

                ticket_json = {
                    'milestone': milestone,
                    'estimatedHours': estimatedHours,
                    'actualHours': actualHours,
                    'status': status,
                    'assignee': assignee,
                    'issueType': issueType,
                    'startDate': startDate,
                    'dueDate': dueDate,
                    'summary': summary
                }

                response = obj.put(Body=json.dumps(ticket_json))

                logger.info(response)

            issues = requests.get(backlog_url + str(offset))
            teams.send_message(str(offset))

    except:
        logger.error(traceback.format_exc())
        teams.send_message('Error', traceback.format_exc())
        raise Exception(traceback.format_exc())