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


Python datafeed_usfirst.DatafeedUsfirst类代码示例

本文整理汇总了Python中datafeeds.datafeed_usfirst.DatafeedUsfirst的典型用法代码示例。如果您正苦于以下问题:Python DatafeedUsfirst类的具体用法?Python DatafeedUsfirst怎么用?Python DatafeedUsfirst使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: get

    def get(self, event_key):
        df = DatafeedUsfirst()

        event = Event.get_by_id(event_key)
        new_matches = MatchManipulator.createOrUpdate(df.getMatches(event))

        if new_matches:
            for match in new_matches:
                if hasattr(match, 'dirty') and match.dirty:
                    # Enqueue push notification
                    try:
                        FirebasePusher.updated_event(event.key_name)
                    except:
                        logging.warning("Enqueuing Firebase push failed!")
                    # Enqueue task to calculate matchstats
                    taskqueue.add(
                            url='/tasks/math/do/event_matchstats/' + event.key_name,
                            method='GET')
                    break


        template_values = {
            'matches': new_matches,
        }

        path = os.path.join(os.path.dirname(__file__), '../templates/datafeeds/usfirst_matches_get.html')
        self.response.out.write(template.render(path, template_values))
开发者ID:quintessentiallyunathoritative,项目名称:the-blue-alliance,代码行数:27,代码来源:datafeed_controller.py

示例2: get

    def get(self, key_name):
        df = DatafeedUsfirst()
        legacy_df = DatafeedUsfirstLegacy()

        team = df.getTeamDetails(Team.get_by_id(key_name))
        if not team:
            logging.warning("getTeamDetails with DatafeedUsfirst for event id {} failed. Retrying with DatafeedUsfirstLegacy.".format(key_name))
            team = legacy_df.getTeamDetails(Team.get_by_id(key_name))
        else:
            legacy_team = legacy_df.getTeamDetails(Team.get_by_id(key_name))
            if legacy_team is not None:
                team.rookie_year = legacy_team.rookie_year  # only available on legacy df

        if team:
            team = TeamManipulator.createOrUpdate(team)
            success = True
        else:
            success = False

        template_values = {
            'key_name': key_name,
            'team': team,
            'success': success,
        }

        path = os.path.join(os.path.dirname(__file__), '../templates/datafeeds/usfirst_team_details_get.html')
        self.response.out.write(template.render(path, template_values))
开发者ID:dewdn2,项目名称:the-blue-alliance,代码行数:27,代码来源:datafeed_controller.py

示例3: get

    def get(self, event_key):
        datafeed = DatafeedUsfirst()

        event = Event.get_by_id(event_key)
        new_awards = AwardManipulator.createOrUpdate(datafeed.getEventAwards(event))
        if type(new_awards) != list:
            new_awards = [new_awards]

        # create EventTeams
        team_ids = set()
        for award in new_awards:
            for team in award.team_list:
                team_ids.add(team.id())
        teams = TeamManipulator.createOrUpdate([Team(
            id=team_id,
            team_number=int(team_id[3:]))
            for team_id in team_ids])
        if teams:
            event_teams = EventTeamManipulator.createOrUpdate([EventTeam(
                id=event_key + "_" + team.key.id(),
                event=event.key,
                team=team.key,
                year=event.year)
                for team in teams])

        template_values = {
            'awards': new_awards,
        }

        path = os.path.join(os.path.dirname(__file__), '../templates/datafeeds/usfirst_awards_get.html')
        self.response.out.write(template.render(path, template_values))
开发者ID:linuxuser0,项目名称:the-blue-alliance,代码行数:31,代码来源:datafeed_controller.py

示例4: get

    def get(self, year, first_eid):
        datafeed = DatafeedUsfirst()

        event = datafeed.getEventDetails(int(year), first_eid)
        event = EventManipulator.createOrUpdate(event)
        
        teams = datafeed.getEventTeams(int(year), first_eid)
        teams = TeamManipulator.createOrUpdate(teams)

        if teams:
            event_teams = [EventTeam(
                id = event.key.id() + "_" + team.key.id(),
                event = event.key,
                team = team.key,
                year = event.year)
                for team in teams]
            event_teams = EventTeamManipulator.createOrUpdate(event_teams)
        else:
            event_teams = []

        template_values = {
            'event': event,
            'event_teams': event_teams,
        }
        
        path = os.path.join(os.path.dirname(__file__), '../templates/datafeeds/usfirst_event_details_get.html')
        self.response.out.write(template.render(path, template_values))
开发者ID:dweitz,项目名称:the-blue-alliance,代码行数:27,代码来源:datafeed_controller.py

示例5: get

    def get(self, key_name):
        # Combines data from three datafeeds with priorities:
        # 1) DatafeedFMSAPI
        # 2) DatafeedUsfirst (missing rookie year)
        # 3) DatafeedUsfirstLegacy (has all info)

        legacy_df = DatafeedUsfirstLegacy()
        usfirst_df = DatafeedUsfirst()
        fms_df = DatafeedFMSAPI('v2.0')

        # Start with lowest priority
        legacy_team = legacy_df.getTeamDetails(Team.get_by_id(key_name))
        usfirst_team = usfirst_df.getTeamDetails(Team.get_by_id(key_name))
        fms_details = fms_df.getTeamDetails(tba_config.MAX_YEAR, key_name)

        # Separate out the multiple models returned from FMSAPI call
        # Since we're only hitting one team at a time, the response won't
        # ever be paginated so we can ignore the possibility
        if fms_details and fms_details[0]:
            models, more_pages = fms_details
            fms_team, district_team, robot = models[0]
        else:
            fms_team = None
            district_team = None
            robot = None

        team = None
        if usfirst_team:
            team = TeamManipulator.updateMergeBase(usfirst_team, legacy_team)
        if fms_team:
            team = TeamManipulator.updateMergeBase(fms_team, team)

        if district_team:
            district_team = DistrictTeamManipulator.createOrUpdate(district_team)
        if robot:
            robot = RobotManipulator.createOrUpdate(robot)
        if team:
            team = TeamManipulator.createOrUpdate(team)
            success = True
        else:
            success = False
            logging.warning("getTeamDetails failed for team: {}".format(key_name))

        template_values = {
            'key_name': key_name,
            'team': team,
            'success': success,
            'district': district_team,
            'robot': robot,
        }

        path = os.path.join(os.path.dirname(__file__), '../templates/datafeeds/usfirst_team_details_get.html')
        self.response.out.write(template.render(path, template_values))
开发者ID:arilotter,项目名称:the-blue-alliance,代码行数:53,代码来源:datafeed_controller.py

示例6: get

    def get(self, event_key):
        datafeed = DatafeedUsfirst()

        event = Event.get_by_id(event_key)
        new_awards = AwardManipulator.createOrUpdate(datafeed.getEventAwards(event))

        template_values = {
            'awards': new_awards,
        }

        path = os.path.join(os.path.dirname(__file__), '../templates/datafeeds/usfirst_awards_get.html')
        self.response.out.write(template.render(path, template_values))
开发者ID:chrismarra,项目名称:the-blue-alliance,代码行数:12,代码来源:datafeed_controller.py

示例7: TestDatafeedUsfirstTeams

class TestDatafeedUsfirstTeams(unittest2.TestCase):
    def setUp(self):
        self.testbed = testbed.Testbed()
        self.testbed.activate()
        self.testbed.init_urlfetch_stub()
        self.testbed.init_datastore_v3_stub()
        self.testbed.init_memcache_stub()

        self.datafeed = DatafeedUsfirst()

        self.team177 = Team(
            id="frc177",
            team_number=177,
            first_tpid=61771,
            first_tpid_year=2012
        )
        self.team177.put()

    def tearDown(self):
        self.testbed.deactivate()

    def test_getTeamDetails(self):
        team = self.datafeed.getTeamDetails(self.team177)

        ## Broken as result of FIRST website redesign -gregmarra 20151122
        # self.assertEqual(team.name, "UTC Power/Ensign Bickford Aerospace & Defense & South Windsor High School")
        # self.assertEqual(team.address, u"South Windsor, CT, USA")
        # self.assertEqual(team.nickname, "Bobcat Robotics")
        # self.assertEqual(team.website, "http://www.bobcatrobotics.org")

    def test_getTeamsTpids(self):
        Team(
          id="frc4409",
          team_number=4409,
          first_tpid=0,  # should be 74735
          first_tpid_year=2011
        ).put()

        # We can skip 2000 records, paginate, and still get frc4409 and frc4410 in 2012
        self.datafeed.getTeamsTpids(2012, skip=2000)

        # Check new team insertion
        frc4410 = Team.get_by_id("frc4410")
        self.assertEqual(frc4410.team_number, 4410)
        self.assertEqual(frc4410.first_tpid, 74193)
        self.assertEqual(frc4410.first_tpid_year, 2012)

        # Check old team updating
        frc4409 = Team.get_by_id("frc4409")
        self.assertEqual(frc4409.team_number, 4409)
        self.assertEqual(frc4409.first_tpid, 74735)
        self.assertEqual(frc4409.first_tpid_year, 2012)
开发者ID:arilotter,项目名称:the-blue-alliance,代码行数:52,代码来源:test_datafeed_usfirst_teams.py

示例8: get

    def get(self, key_name):
        # Combines data from three datafeeds with priorities:
        # 1) DatafeedFMSAPI (missing website)
        # 2) DatafeedUsfirst (missing rookie year)
        # 3) DatafeedUsfirstLegacy (has all info)

        legacy_df = DatafeedUsfirstLegacy()
        usfirst_df = DatafeedUsfirst()
        fms_df = DatafeedFMSAPI('v2.0')

        # Start with lowest priority
        legacy_team = legacy_df.getTeamDetails(Team.get_by_id(key_name))
        usfirst_team = usfirst_df.getTeamDetails(Team.get_by_id(key_name))
        fms_details = fms_df.getTeamDetails(date.today().year, key_name)

        if fms_details:
            fms_team, district_team, robot = fms_details
        else:
            fms_team = None
            district_team = None
            robot = None

        team = None
        if usfirst_team:
            team = TeamManipulator.updateMergeBase(usfirst_team, legacy_team)
        if fms_team:
            team = TeamManipulator.updateMergeBase(fms_team, team)

        if district_team:
            district_team = DistrictTeamManipulator.createOrUpdate(district_team)
        if robot:
            robot = RobotManipulator.createOrUpdate(robot)
        if team:
            team = TeamManipulator.createOrUpdate(team)
            success = True
        else:
            success = False
            logging.warning("getTeamDetails failed for team: {}".format(key_name))

        template_values = {
            'key_name': key_name,
            'team': team,
            'success': success,
            'district': district_team,
            'robot': robot,
        }

        path = os.path.join(os.path.dirname(__file__), '../templates/datafeeds/usfirst_team_details_get.html')
        self.response.out.write(template.render(path, template_values))
开发者ID:RCB35,项目名称:the-blue-alliance,代码行数:49,代码来源:datafeed_controller.py

示例9: TestDatafeedUsfirstEvents

class TestDatafeedUsfirstEvents(unittest2.TestCase):
    def setUp(self):
        self.testbed = testbed.Testbed()
        self.testbed.activate()
        self.testbed.init_urlfetch_stub()
        self.testbed.init_memcache_stub()

        self.datafeed = DatafeedUsfirst()

    def tearDown(self):
        self.testbed.deactivate()

    def test_getEvent(self):
        # test with 2011ct
        event = self.datafeed.getEventDetails("5561")

        self.assertEqual(event.key.id(), "2011ct")
        self.assertEqual(event.name, "Northeast Utilities FIRST Connecticut Regional")
        self.assertEqual(event.event_type_enum, EventType.REGIONAL)
        self.assertEqual(event.start_date, datetime.datetime(2011, 3, 31, 0, 0))
        self.assertEqual(event.end_date, datetime.datetime(2011, 4, 2, 0, 0))
        self.assertEqual(event.year, 2011)
        self.assertEqual(event.venue_address, "Connecticut Convention Center\r\n100 Columbus Blvd\r\nHartford, CT 06103\r\nUSA")
        self.assertEqual(event.website, "http://www.ctfirst.org/ctr")
        self.assertEqual(event.event_short, "ct")

    def test_getEventTeams(self):
        # test with 2011ct
        teams = self.datafeed.getEventTeams(2011, "5561")

        sort_key = lambda t: t[1]
        self.assertEqual(
            sorted([(team.team_number, team.first_tpid) for team in teams], key=sort_key),
            sorted([(383, 41829), (1124, 42285), (155, 41609), (3634, 51637), (999, 42215), (1699, 42751), (173, 41625), (175, 41629), (716, 42049), (178, 41635), (2170, 43331), (3146, 44577), (2168, 43335), (2067, 43175), (181, 41641), (1991, 43133), (3125, 44539), (2785, 44073), (1740, 42765), (1784, 42895), (3654, 51609), (3718, 49891), (558, 41939), (3719, 52081), (230, 41681), (3464, 49827), (177, 41633), (2064, 43159), (195, 41651), (3104, 44463), (3555, 49069), (3141, 44487), (3461, 47483), (3525, 48801), (237, 41691), (3182, 44547), (571, 41947), (176, 41631), (1071, 42251), (2836, 43965), (126, 41585), (157, 41611), (69, 41519), (1027, 42235), (663, 42007), (3585, 50743), (1073, 42255), (501, 41899), (869, 42131), (714, 42047), (1923, 42947), (743, 42051), (20, 41475), (3204, 44731), (1601, 42659), (2791, 43935), (533, 41919), (694, 42027)], key=sort_key)
        )

    def test_getEventList(self):
        events = self.datafeed.getEventList(2011)

        self.assertEqual(len(events), 58)  # 58 events expected

        self.assertEqual(events[0].first_eid, "5519")
        self.assertEqual(events[0].event_type_enum, EventType.REGIONAL)
        self.assertEqual(events[0].name, "BAE Systems/Granite State Regional")

        self.assertEqual(events[1].first_eid, "5523")
        self.assertEqual(events[1].event_type_enum, EventType.REGIONAL)
        self.assertEqual(events[1].name, "New Jersey Regional")
开发者ID:chrismarra,项目名称:the-blue-alliance,代码行数:48,代码来源:test_datafeed_usfirst_events.py

示例10: setUp

 def setUp(self):
     self.testbed = testbed.Testbed()
     self.testbed.activate()
     self.testbed.init_urlfetch_stub()
     self.testbed.init_memcache_stub()
     
     self.datafeed = DatafeedUsfirst()
开发者ID:dweitz,项目名称:the-blue-alliance,代码行数:7,代码来源:test_datafeed_usfirst_events.py

示例11: setUp

    def setUp(self):
        self.testbed = testbed.Testbed()
        self.testbed.activate()
        self.testbed.init_urlfetch_stub()
        self.testbed.init_memcache_stub()
        self.testbed.init_datastore_v3_stub()
        self.testbed.init_taskqueue_stub(root_path=".")

        self.datafeed = DatafeedUsfirst()
开发者ID:arilotter,项目名称:the-blue-alliance,代码行数:9,代码来源:test_datafeed_usfirst_events.py

示例12: TestDatafeedUsfirstEvents

class TestDatafeedUsfirstEvents(unittest2.TestCase):
    def setUp(self):
        self.testbed = testbed.Testbed()
        self.testbed.activate()
        self.testbed.init_urlfetch_stub()
        self.testbed.init_memcache_stub()
        self.testbed.init_datastore_v3_stub()
        self.testbed.init_taskqueue_stub(root_path=".")

        self.datafeed = DatafeedUsfirst()

    def tearDown(self):
        self.testbed.deactivate()

## Breaks with new FIRST website -gregmarra 20151122
#    def test_getEvent(self):
        # test with 2011ct

        # event = self.datafeed.getEventDetails("5561")
        # 
        # self.assertEqual(event.key.id(), "2011ct")
        # self.assertEqual(event.name, "Northeast Utilities FIRST Connecticut Regional")
        # self.assertEqual(event.event_type_enum, EventType.REGIONAL)
        # self.assertEqual(event.start_date, datetime.datetime(2011, 3, 31, 0, 0))
        # self.assertEqual(event.end_date, datetime.datetime(2011, 4, 2, 0, 0))
        # self.assertEqual(event.year, 2011)
        # self.assertEqual(event.venue_address, "Connecticut Convention Center\r\n100 Columbus Blvd\r\nHartford, CT 06103\r\nUSA")
        # self.assertEqual(event.website, "http://www.ctfirst.org/ctr")
        # self.assertEqual(event.event_short, "ct")

    def test_getEventAlliances(self):
        event = Event(
            event_short='cur',
            year=2014,
        )
        alliances = self.datafeed.getEventAlliances(event)
        self.assertEqual(
            alliances,
            [
                {'picks': ['frc254', 'frc469', 'frc2848', 'frc74'], 'declines':[] },
                {'picks': ['frc1718', 'frc2451', 'frc573', 'frc2016'], 'declines':[] },
                {'picks': ['frc2928', 'frc2013', 'frc1311', 'frc842'], 'declines':[] },
                {'picks': ['frc180', 'frc125', 'frc1323', 'frc2468'], 'declines':[] },
                {'picks': ['frc118', 'frc359', 'frc4334', 'frc865'], 'declines':[] },
                {'picks': ['frc135', 'frc1241', 'frc11', 'frc68'], 'declines':[] },
                {'picks': ['frc3478', 'frc177', 'frc294', 'frc230'], 'declines':[] },
                {'picks': ['frc624', 'frc987', 'frc3476', 'frc3015'], 'declines':[] },
            ]
        )
开发者ID:arilotter,项目名称:the-blue-alliance,代码行数:49,代码来源:test_datafeed_usfirst_events.py

示例13: TestDatafeedUsfirstMatches

class TestDatafeedUsfirstMatches(unittest2.TestCase):
    def setUp(self):
        self.testbed = testbed.Testbed()
        self.testbed.activate()
        self.testbed.init_urlfetch_stub()
        self.testbed.init_datastore_v3_stub()
        self.testbed.init_memcache_stub()
        
        self.datafeed = DatafeedUsfirst()
    
    def tearDown(self):
        self.testbed.deactivate()
    
    def test_getMatchResultsList(self):
        event = Event(
          id = "2011ct",
          event_short = "ct",
          year = 2011
        )
        
        matches = self.datafeed.getMatches(event)
        
        # Test 2011ct_qm1
        match = matches[0]
        self.assertEqual(match.comp_level, "qm")
        self.assertEqual(match.set_number, 1)
        self.assertEqual(match.match_number, 1)
        self.assertEqual(match.team_key_names, [u'frc69', u'frc571', u'frc176', u'frc3464', u'frc20', u'frc1073'])
        self.assertEqual(match.alliances_json, """{"blue": {"score": 57, "teams": ["frc3464", "frc20", "frc1073"]}, "red": {"score": 74, "teams": ["frc69", "frc571", "frc176"]}}""")
        self.assertEqual(match.time_string, "9:29 AM")

        # Test 2011ct_qf2m3
        match = matches[-7]
        self.assertEqual(match.comp_level, "qf")
        self.assertEqual(match.set_number, 2)
        self.assertEqual(match.match_number, 3)
        self.assertEqual(match.team_key_names, [u'frc716', u'frc3125', u'frc181', u'frc1699', u'frc1124', u'frc714'])
        self.assertEqual(match.alliances_json, """{"blue": {"score": 74, "teams": ["frc1699", "frc1124", "frc714"]}, "red": {"score": 90, "teams": ["frc716", "frc3125", "frc181"]}}""")
        self.assertEqual(match.time_string, "2:05 PM")

        # Test 2011ct_f1m2
        match = matches[-1]
        self.assertEqual(match.comp_level, "f")
        self.assertEqual(match.set_number, 1)
        self.assertEqual(match.match_number, 2)
        self.assertEqual(match.team_key_names, [u'frc195', u'frc1923', u'frc155', u'frc177', u'frc175', u'frc1073'])
        self.assertEqual(match.alliances_json, """{"blue": {"score": 65, "teams": ["frc177", "frc175", "frc1073"]}, "red": {"score": 97, "teams": ["frc195", "frc1923", "frc155"]}}""")
        self.assertEqual(match.time_string, "3:23 PM")
开发者ID:dweitz,项目名称:the-blue-alliance,代码行数:48,代码来源:test_datafeed_usfirst_matches.py

示例14: setUp

    def setUp(self):
        self.testbed = testbed.Testbed()
        self.testbed.activate()
        self.testbed.init_urlfetch_stub()
        self.testbed.init_datastore_v3_stub()
        self.testbed.init_memcache_stub()

        self.datafeed = DatafeedUsfirst()

        self.team177 = Team(
            id="frc177",
            team_number=177,
            first_tpid=61771,
            first_tpid_year=2012
        )
        self.team177.put()
开发者ID:BowlesCR,项目名称:the-blue-alliance,代码行数:16,代码来源:test_datafeed_usfirst_teams.py


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