當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。