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


Python robot.Robot类代码示例

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


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


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