本文整理汇总了Python中datafeeds.datafeed_fms_api.DatafeedFMSAPI类的典型用法代码示例。如果您正苦于以下问题:Python DatafeedFMSAPI类的具体用法?Python DatafeedFMSAPI怎么用?Python DatafeedFMSAPI使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DatafeedFMSAPI类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get
def get(self, year):
df = DatafeedFMSAPI('v2.0')
df2 = DatafeedFIRSTElasticSearch()
fmsapi_events, fmsapi_districts = df.getEventList(year)
elasticsearch_events = df2.getEventList(year)
merged_events = EventManipulator.mergeModels(fmsapi_events, elasticsearch_events)
events = EventManipulator.createOrUpdate(merged_events)
districts = DistrictManipulator.createOrUpdate(fmsapi_districts)
# Fetch event details for each event
for event in events:
taskqueue.add(
queue_name='datafeed',
target='backend-tasks',
url='/backend-tasks/get/event_details/'+event.key_name,
method='GET'
)
template_values = {
"events": events,
"districts": districts,
}
if 'X-Appengine-Taskname' not in self.request.headers: # Only write out if not in taskqueue
path = os.path.join(os.path.dirname(__file__), '../templates/datafeeds/fms_event_list_get.html')
self.response.out.write(template.render(path, template_values))
示例2: get
def get(self, key_name):
fms_df = DatafeedFMSAPI('v2.0')
fms_details = fms_df.getTeamDetails(date.today().year, key_name)
if fms_details:
team, district_team, robot = fms_details
else:
fms_team = None
district_team = None
robot = None
if team:
team = TeamManipulator.createorUpdate(team)
if district_team:
district_team = DistrictTeamManipulator.createOrUpdate(district_team)
if robot:
robot = RobotManipulator.createOrUpdate(robot)
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))
示例3: get
def get(self, event_key):
df = DatafeedFMSAPI('v2.0')
new_matches = MatchManipulator.createOrUpdate(df.getMatches(event_key))
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))
示例4: get
def get(self, year):
df = DatafeedFMSAPI('v2.0')
fmsapi_districts = df.getDistrictList(year)
districts = DistrictManipulator.createOrUpdate(fmsapi_districts)
template_values = {
"districts": districts,
}
if 'X-Appengine-Taskname' not in self.request.headers: # Only write out if not in taskqueue
path = os.path.join(os.path.dirname(__file__), '../templates/datafeeds/fms_district_list_get.html')
self.response.out.write(template.render(path, template_values))
示例5: 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))
示例6: get
def get(self, event_key):
df = DatafeedFMSAPI('v2.0')
event = Event.get_by_id(event_key)
alliance_selections = df.getEventAlliances(event_key)
if alliance_selections and event.alliance_selections != alliance_selections:
event.alliance_selections_json = json.dumps(alliance_selections)
event._alliance_selections = None
event.dirty = True
EventManipulator.createOrUpdate(event)
template_values = {'alliance_selections': alliance_selections,
'event_name': event.key_name}
if 'X-Appengine-Taskname' not in self.request.headers: # Only write out if not in taskqueue
path = os.path.join(os.path.dirname(__file__), '../templates/datafeeds/usfirst_event_alliances_get.html')
self.response.out.write(template.render(path, template_values))
示例7: get
def get(self, event_key):
df = DatafeedFMSAPI('v2.0', save_response=True)
updated_matches = []
for m1 in df.getMatches(event_key):
m2 = m1.key.get()
# Only update if teams and scores are equal
if m2 and (m1.alliances['red']['teams'] == m2.alliances['red']['teams'] and
m1.alliances['blue']['teams'] == m2.alliances['blue']['teams'] and
m1.alliances['red']['score'] == m2.alliances['red']['score'] and
m1.alliances['blue']['score'] == m2.alliances['blue']['score']):
old_alliances = m2.alliances
old_alliances['red']['dqs'] = m1.alliances['red']['dqs']
old_alliances['blue']['dqs'] = m1.alliances['blue']['dqs']
m2.alliances_json = json.dumps(old_alliances)
updated_matches.append(m2)
else:
logging.warning("Match not equal: {}".format(m1.key.id()))
MatchManipulator.createOrUpdate(updated_matches)
self.response.out.write("DONE")
示例8: get
def get(self, year):
df = DatafeedFMSAPI('v2.0')
df2 = DatafeedFIRSTElasticSearch()
merged_events = EventManipulator.mergeModels(df.getEventList(year), df2.getEventList(year))
events = EventManipulator.createOrUpdate(merged_events)
# Fetch event details for each event
for event in events:
taskqueue.add(
queue_name='datafeed',
url='/backend-tasks/get/event_details/'+event.key_name,
method='GET'
)
template_values = {
"events": events
}
path = os.path.join(os.path.dirname(__file__), '../templates/datafeeds/fms_event_list_get.html')
self.response.out.write(template.render(path, template_values))