本文整理汇总了Python中models.robot.Robot类的典型用法代码示例。如果您正苦于以下问题:Python Robot类的具体用法?Python Robot怎么用?Python Robot使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Robot类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: show_form
def show_form(self, mid=None):
if mid:
robot = Robot.get_by_id(int(mid), parent=self.current_user.key)
else:
robot = Robot()
form = forms.RobotForm(data=robot.to_dict())
self.render_response('robot/form.html', form=form, mid=mid, robot=robot)
开发者ID:notapresent,项目名称:yukata,代码行数:8,代码来源:handlers.py
示例2: test_set_robot_name
def test_set_robot_name(self):
self.loginUser()
self.giveTeamAdminAccess()
# There is no Robot models that exists yet for this team
form = self.getTeamInfoForm(1124)
form['robot_name'] = 'Test Robot Name'
response = form.submit().follow()
self.assertEqual(response.status_int, 301)
robot = Robot.get_by_id(Robot.renderKeyName('frc1124', self.now.year))
self.assertIsNotNone(robot)
self.assertEqual(robot.robot_name, 'Test Robot Name')
开发者ID:ZachOrr,项目名称:the-blue-alliance,代码行数:13,代码来源:test_suggest_team_admin_review.py
示例3: get
def get(self, team_number):
self._require_admin()
team = Team.get_by_id("frc" + team_number)
if not team:
self.abort(404)
event_teams = EventTeam.query(EventTeam.team == team.key).fetch(500)
team_medias = Media.query(Media.references == team.key).fetch(500)
robots = Robot.query(Robot.team == team.key).fetch()
district_teams = DistrictTeam.query(DistrictTeam.team == team.key).fetch()
years_participated = sorted(TeamParticipationQuery(team.key_name).fetch())
team_medias_by_year = {}
for media in team_medias:
if media.year in team_medias_by_year:
team_medias_by_year[media.year].append(media)
else:
team_medias_by_year[media.year] = [media]
media_years = sorted(team_medias_by_year.keys(), reverse=True)
self.template_values.update({
'event_teams': event_teams,
'team': team,
'team_media_years': media_years,
'team_medias_by_year': team_medias_by_year,
'robots': robots,
'district_teams': district_teams,
'years_participated': years_participated,
})
path = os.path.join(os.path.dirname(__file__), '../../templates/admin/team_details.html')
self.response.out.write(template.render(path, self.template_values))
开发者ID:MC42,项目名称:the-blue-alliance,代码行数:32,代码来源:admin_team_controller.py
示例4: setUp
def setUp(self):
app = webapp2.WSGIApplication([webapp2.Route(r'/<team_key:>', ApiTeamHistoryRobotsController, methods=['GET'])], debug=True)
self.testapp = webtest.TestApp(app)
self.testbed = testbed.Testbed()
self.testbed.activate()
self.testbed.init_datastore_v3_stub()
self.testbed.init_urlfetch_stub()
self.testbed.init_memcache_stub()
self.testbed.init_taskqueue_stub(root_path=".")
self.team = Team(
id="frc1124",
name="UberBots",
team_number=1124,
nickname="UberBots",
)
self.robot = Robot(
id="frc1124_2015",
team=self.team.key,
year=2015,
robot_name="Orion"
)
self.team.put()
self.robot.put()
开发者ID:DNGros,项目名称:the-blue-alliance,代码行数:27,代码来源:test_apiv2_team_controller.py
示例5: get
def get(self, team_number):
self._require_admin()
team = Team.get_by_id("frc" + team_number)
event_teams = EventTeam.query(EventTeam.team == team.key).fetch(500)
team_medias = Media.query(Media.references == team.key).fetch(500)
robots = Robot.query(Robot.team == team.key).fetch()
district_teams = DistrictTeam.query(DistrictTeam.team == team.key).fetch()
team_medias_by_year = {}
for media in team_medias:
if media.year in team_medias_by_year:
team_medias_by_year[media.year].append(media)
else:
team_medias_by_year[media.year] = [media]
self.template_values.update({
'event_teams': event_teams,
'team': team,
'team_medias_by_year': team_medias_by_year,
'robots': robots,
'district_teams': district_teams,
})
path = os.path.join(os.path.dirname(__file__), '../../templates/admin/team_details.html')
self.response.out.write(template.render(path, self.template_values))
开发者ID:CarterFendley,项目名称:the-blue-alliance,代码行数:26,代码来源:admin_team_controller.py
示例6: parse
def parse(self, response):
"""
Parse team info from FMSAPI
Returns a tuple of: list of models (Team, DistrictTeam, Robot),
and a Boolean indicating if there are more pages to be fetched
"""
# Get team json
# don't need to null check, if error, HTTP code != 200, so we wont' get here
current_page = response['pageCurrent']
total_pages = response['pageTotal']
teams = response['teams']
ret_models = []
for teamData in teams:
# Fix issue where FIRST's API returns dummy website for all teams
if teamData['website'] is not None and 'www.firstinspires.org' in teamData['website']:
website = None
else:
website = WebsiteHelper.format_url(teamData.get('website', None))
team = Team(
id="frc{}".format(teamData['teamNumber']),
team_number=teamData['teamNumber'],
name=teamData['nameFull'],
nickname=teamData['nameShort'],
school_name=teamData.get('schoolName'),
home_cmp=teamData.get('homeCMP').lower() if teamData.get('homeCMP') else None,
city=teamData['city'],
state_prov=teamData['stateProv'],
country=teamData['country'],
website=website,
rookie_year=teamData['rookieYear']
)
districtTeam = None
if teamData['districtCode']:
districtAbbrev = DistrictType.abbrevs[teamData['districtCode'].lower()]
districtTeam = DistrictTeam(
id=DistrictTeam.renderKeyName(self.year, districtAbbrev, team.key_name),
team=ndb.Key(Team, team.key_name),
year=self.year,
district=districtAbbrev,
district_key=ndb.Key(District, District.renderKeyName(self.year, teamData['districtCode'].lower())),
)
robot = None
if teamData['robotName']:
robot = Robot(
id=Robot.renderKeyName(team.key_name, self.year),
team=ndb.Key(Team, team.key_name),
year=self.year,
robot_name=teamData['robotName'].strip()
)
ret_models.append((team, districtTeam, robot))
return (ret_models, (current_page < total_pages))
开发者ID:NikhilNarayana,项目名称:the-blue-alliance,代码行数:58,代码来源:fms_api_team_details_parser.py
示例7: TestTeamHistoryRobotsApiController
class TestTeamHistoryRobotsApiController(unittest2.TestCase):
def setUp(self):
app = webapp2.WSGIApplication([webapp2.Route(r'/<team_key:>', ApiTeamHistoryRobotsController, methods=['GET'])], debug=True)
self.testapp = webtest.TestApp(app)
self.testbed = testbed.Testbed()
self.testbed.activate()
self.testbed.init_datastore_v3_stub()
self.testbed.init_urlfetch_stub()
self.testbed.init_memcache_stub()
ndb.get_context().clear_cache() # Prevent data from leaking between tests
self.testbed.init_taskqueue_stub(root_path=".")
self.team = Team(
id="frc1124",
name="UberBots",
team_number=1124,
nickname="UberBots"
)
self.robot = Robot(
id="frc1124_2015",
team=self.team.key,
year=2015,
robot_name="Orion"
)
self.team.put()
self.robot.put()
def tearDown(self):
self.testbed.deactivate()
def testRobotApi(self):
response = self.testapp.get('/frc1124', headers={"X-TBA-App-Id": "tba-tests:team_list-controller-test:v01"})
robot_dict = json.loads(response.body)
self.assertTrue("2015" in robot_dict)
robot = robot_dict["2015"]
self.assertEqual(robot["key"], "frc1124_2015")
self.assertEqual(robot["team_key"], "frc1124")
self.assertEqual(robot["year"], 2015)
self.assertEqual(robot["name"], "Orion")
开发者ID:ZachOrr,项目名称:the-blue-alliance,代码行数:45,代码来源:test_apiv2_team_controller.py
示例8: test_delete_robot_name
def test_delete_robot_name(self):
self.loginUser()
self.giveTeamAdminAccess()
Robot(
id=Robot.renderKeyName(self.team.key_name, self.now.year),
team=self.team.key,
year=self.now.year,
robot_name='First Robot Name',
).put()
form = self.getTeamInfoForm(1124)
self.assertEqual(form['robot_name'].value, 'First Robot Name')
form['robot_name'] = ''
response = form.submit().follow()
self.assertEqual(response.status_int, 301)
robot = Robot.get_by_id(Robot.renderKeyName('frc1124', self.now.year))
self.assertIsNone(robot)
开发者ID:ZachOrr,项目名称:the-blue-alliance,代码行数:19,代码来源:test_suggest_team_admin_review.py
示例9: parse
def parse(self, response):
"""
Parse team info from FMSAPI
Returns a tuple of: list of models (Team, DistrictTeam, Robot),
and a Boolean indicating if there are more pages to be fetched
"""
# Get team json
# don't need to null check, if error, HTTP code != 200, so we wont' get here
current_page = response['pageCurrent']
total_pages = response['pageTotal']
teams = response['teams']
ret_models = []
for teamData in teams:
# concat city/state/country to get address
address = u"{}, {}, {}".format(teamData['city'], teamData['stateProv'], teamData['country'])
team = Team(
id="frc{}".format(teamData['teamNumber']),
team_number=teamData['teamNumber'],
name=teamData['nameFull'],
nickname=teamData['nameShort'],
address=address,
website=teamData['website'],
rookie_year=teamData['rookieYear']
)
districtTeam = None
if teamData['districtCode']:
districtAbbrev = DistrictType.abbrevs[teamData['districtCode'].lower()]
districtTeam = DistrictTeam(
id=DistrictTeam.renderKeyName(self.year, districtAbbrev, team.key_name),
team=ndb.Key(Team, team.key_name),
year=self.year,
district=districtAbbrev
)
robot = None
if teamData['robotName']:
robot = Robot(
id=Robot.renderKeyName(team.key_name, self.year),
team=ndb.Key(Team, team.key_name),
year=self.year,
robot_name=teamData['robotName'].strip()
)
ret_models.append((team, districtTeam, robot))
return (ret_models, (current_page < total_pages))
开发者ID:cmlicata,项目名称:the-blue-alliance,代码行数:50,代码来源:fms_api_team_details_parser.py
示例10: process_form
def process_form(self, mid, dsid):
robot = Robot.get_by_id(int(mid), parent=self.current_user.key)
if dsid:
dataset = DataSet.get_by_id(int(dsid), parent=robot.key)
else:
dataset = DataSet(parent=robot.key)
form = forms.DataSetForm(self.request.POST)
if form.validate():
dataset.populate(**form.data)
key = dataset.put()
return self.redirect_to('dataset-edit', mid=mid, dsid=key.id())
self.render_response('robot/datasetform.html', form=form, mid=mid, dsid=dsid,
dataset=dataset)
开发者ID:notapresent,项目名称:yukata,代码行数:16,代码来源:handlers.py
示例11: post
def post(self):
team_number = self.request.get("team_number")
if not team_number:
self.abort(400)
team_number = int(team_number)
team = Team.get_by_id("frc{}".format(team_number))
if not team:
self.abort(400)
self._require_team_admin_access(team_number)
action = self.request.get('action')
if action == "remove_media_reference":
media, team_ref = self.get_media_and_team_ref(team_number)
if team_ref in media.references:
media.references.remove(team_ref)
if team_ref in media.preferred_references:
media.preferred_references.remove(team_ref)
MediaManipulator.createOrUpdate(media, auto_union=False)
elif action == "remove_media_preferred":
media, team_ref = self.get_media_and_team_ref(team_number)
if team_ref in media.preferred_references:
media.preferred_references.remove(team_ref)
MediaManipulator.createOrUpdate(media, auto_union=False)
elif action == "add_media_preferred":
media, team_ref = self.get_media_and_team_ref(team_number)
if team_ref not in media.preferred_references:
media.preferred_references.append(team_ref)
MediaManipulator.createOrUpdate(media, auto_union=False)
elif action == "set_team_info":
robot_name = self.request.get("robot_name").strip()
current_year = datetime.datetime.now().year
robot_key = Robot.renderKeyName(team.key_name, current_year)
if robot_name:
robot = Robot(
id=robot_key,
team=team.key,
year=current_year,
robot_name=robot_name,
)
RobotManipulator.createOrUpdate(robot)
else:
RobotManipulator.delete_keys([ndb.Key(Robot, robot_key)])
else:
self.abort(400)
self.redirect('/mod/')
开发者ID:ZachOrr,项目名称:the-blue-alliance,代码行数:46,代码来源:team_admin_controller.py
示例12: parse
def parse(self, response):
"""
Parse team info from FMSAPI
Returns a tuple of models (Team, DistrictTeam, Robot)
"""
# Get team json
# don't need to null check, if error, HTTP code != 200, so we wont' get here
teams = response["teams"]
teamData = teams[0]
# concat city/state/country to get address
address = u"{}, {}, {}".format(teamData["city"], teamData["stateProv"], teamData["country"])
team = Team(
team_number=teamData["teamNumber"],
name=teamData["nameFull"],
nickname=teamData["nameShort"],
address=address,
rookie_year=teamData["rookieYear"],
)
districtTeam = None
if teamData["districtCode"]:
districtAbbrev = DistrictType.abbrevs[teamData["districtCode"].lower()]
districtTeam = DistrictTeam(
id=DistrictTeam.renderKeyName(self.year, districtAbbrev, team.key_name),
team=ndb.Key(Team, team.key_name),
year=self.year,
district=districtAbbrev,
)
robot = None
if teamData["robotName"]:
robot = Robot(
id=Robot.renderKeyName(team.key_name, self.year),
team=ndb.Key(Team, team.key_name),
year=self.year,
robot_name=teamData["robotName"].strip(),
)
return (team, districtTeam, robot)
开发者ID:RCB35,项目名称:the-blue-alliance,代码行数:42,代码来源:fms_api_team_details_parser.py
示例13: setUp
def setUp(self):
app = webapp2.WSGIApplication(
[webapp2.Route(r"/<team_key:>", ApiTeamHistoryRobotsController, methods=["GET"])], debug=True
)
self.testapp = webtest.TestApp(app)
self.testbed = testbed.Testbed()
self.testbed.activate()
self.testbed.init_datastore_v3_stub()
self.testbed.init_urlfetch_stub()
self.testbed.init_memcache_stub()
ndb.get_context().clear_cache() # Prevent data from leaking between tests
self.testbed.init_taskqueue_stub(root_path=".")
self.team = Team(id="frc1124", name="UberBots", team_number=1124, nickname="UberBots")
self.robot = Robot(id="frc1124_2015", team=self.team.key, year=2015, robot_name="Orion")
self.team.put()
self.robot.put()
开发者ID:the-blue-alliance,项目名称:the-blue-alliance,代码行数:21,代码来源:test_apiv2_team_controller.py
示例14: post
def post(self):
self._require_admin()
team_key = self.request.get('team_key')
year = int(self.request.get('robot_year'))
name = self.request.get('robot_name')
team = Team.get_by_id(team_key)
if not team:
self.abort(404)
if not year or not name:
self.abort(400)
robot = Robot(
id=Robot.renderKeyName(team_key, year),
team=team.key,
year=year,
robot_name=name.strip()
)
RobotManipulator.createOrUpdate(robot)
self.redirect('/admin/team/{}'.format(team.team_number))
开发者ID:MC42,项目名称:the-blue-alliance,代码行数:22,代码来源:admin_team_controller.py
示例15: delete
def delete(self, mid, dsid):
robot = Robot.get_by_id(int(mid), parent=self.current_user.key)
dataset = DataSet.get_by_id(int(dsid), parent=robot.key)
dataset.key.delete()
return self.redirect_to('robot-view', mid=mid)
开发者ID:notapresent,项目名称:yukata,代码行数:5,代码来源:handlers.py
示例16: index
def index(self):
template_vars = {
'robots': Robot.list(ancestor=self.current_user.key),
'schedules': SCHEDULES
}
self.render_response('robot/index.html', **template_vars)
开发者ID:notapresent,项目名称:yukata,代码行数:6,代码来源:handlers.py
示例17: test_list_returns_one
def test_list_returns_one(self):
groupkey = ndb.Key('_', '_')
robot = Robot(parent=groupkey, name='_', schedule=SCHEDULES.keys()[0])
robot.put()
self.assertEqual(Robot.list(ancestor=groupkey), [robot])
开发者ID:notapresent,项目名称:yukata,代码行数:5,代码来源:test_robot.py
示例18: test_list_returns_empty_list
def test_list_returns_empty_list(self):
groupkey = ndb.Key('_', '_')
self.assertEqual(Robot.list(ancestor=groupkey), [])
开发者ID:notapresent,项目名称:yukata,代码行数:3,代码来源:test_robot.py
示例19: view
def view(self, mid):
robot = Robot.get_by_id(int(mid), parent=self.current_user.key)
crawls = Crawl.query(ancestor=robot.key).order(-Crawl.started_at).fetch()
datasets = DataSet.query(ancestor=robot.key).fetch()
self.render_response('robot/view.html', robot=robot, mid=mid, crawls=crawls,
datasets=datasets, schedules=SCHEDULES)
开发者ID:notapresent,项目名称:yukata,代码行数:6,代码来源:handlers.py
示例20: render_team_details
def render_team_details(cls, handler, team, year, is_canonical):
hof_award_future = award_query.TeamEventTypeAwardsQuery(team.key.id(), EventType.CMP_FINALS, AwardType.CHAIRMANS).fetch_async()
hof_video_future = media_query.TeamTagMediasQuery(team.key.id(), MediaTag.CHAIRMANS_VIDEO).fetch_async()
hof_presentation_future = media_query.TeamTagMediasQuery(team.key.id(), MediaTag.CHAIRMANS_PRESENTATION).fetch_async()
hof_essay_future = media_query.TeamTagMediasQuery(team.key.id(), MediaTag.CHAIRMANS_ESSAY).fetch_async()
media_future = media_query.TeamYearMediaQuery(team.key.id(), year).fetch_async()
social_media_future = media_query.TeamSocialMediaQuery(team.key.id()).fetch_async()
robot_future = Robot.get_by_id_async("{}_{}".format(team.key.id(), year))
team_districts_future = team_query.TeamDistrictsQuery(team.key.id()).fetch_async()
participation_future = team_query.TeamParticipationQuery(team.key.id()).fetch_async()
hof_awards = hof_award_future.get_result()
hof_video = hof_video_future.get_result()
hof_presentation = hof_presentation_future.get_result()
hof_essay = hof_essay_future.get_result()
hall_of_fame = {
"is_hof": len(hof_awards) > 0,
"years": [award.year for award in hof_awards],
"media": {
"video": hof_video[0].youtube_url_link if len(hof_video) > 0 else None,
"presentation": hof_presentation[0].youtube_url_link if len(hof_presentation) > 0 else None,
"essay": hof_essay[0].external_link if len(hof_essay) > 0 else None,
},
}
events_sorted, matches_by_event_key, awards_by_event_key, valid_years = TeamDetailsDataFetcher.fetch(team, year, return_valid_years=True)
if not events_sorted:
return None
district_name = None
district_abbrev = None
team_district_points = None
team_districts = team_districts_future.get_result()
for district in team_districts:
if district and district.year == year:
district_abbrev = district.abbreviation
district_name = district.display_name
if district.rankings:
team_district_points = next(
iter(filter(lambda r: r['team_key'] == team.key_name,
district.rankings)), None)
break
participation = []
season_wlt_list = []
offseason_wlt_list = []
year_match_avg_list = []
current_event = None
matches_upcoming = None
short_cache = False
for event in events_sorted:
event_matches = matches_by_event_key.get(event.key, [])
event_awards = AwardHelper.organizeAwards(awards_by_event_key.get(event.key, []))
matches_organized = MatchHelper.organizeMatches(event_matches)
if event.now:
current_event = event
matches_upcoming = MatchHelper.upcomingMatches(event_matches)
if event.within_a_day:
short_cache = True
if year == 2015:
display_wlt = None
match_avg = EventHelper.calculateTeamAvgScoreFromMatches(team.key_name, event_matches)
year_match_avg_list.append(match_avg)
qual_avg, elim_avg, _, _ = match_avg
else:
qual_avg = None
elim_avg = None
wlt = EventHelper.calculateTeamWLTFromMatches(team.key_name, event_matches)
if event.event_type_enum in EventType.SEASON_EVENT_TYPES:
season_wlt_list.append(wlt)
else:
offseason_wlt_list.append(wlt)
if wlt["win"] + wlt["loss"] + wlt["tie"] == 0:
display_wlt = None
else:
display_wlt = wlt
team_rank = None
if event.details and event.details.rankings2:
for ranking in event.details.rankings2:
if ranking['team_key'] == team.key.id():
team_rank = ranking['rank']
break
video_ids = []
playlist = ""
for level in Match.COMP_LEVELS:
matches = matches_organized[level]
for match in matches:
video_ids += [video.split("?")[0] for video in match.youtube_videos]
if video_ids:
playlist_title = u"{} (Team {})".format(event.name, team.team_number)
playlist = u"https://www.youtube.com/watch_videos?video_ids={}&title={}"
playlist = playlist.format(u",".join(video_ids), playlist_title)
#.........这里部分代码省略.........
开发者ID:MC42,项目名称:the-blue-alliance,代码行数:101,代码来源:team_renderer.py
注:本文中的models.robot.Robot类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论