def get(self, alias):
        special_webcasts_future = Sitevar.get_by_id_async(
            'gameday.special_webcasts')
        special_webcasts = special_webcasts_future.get_result()
        aliases = special_webcasts.contents.get(
            "aliases", {}) if special_webcasts else {}

        if alias in aliases:
            self.redirect("/gameday{}".format(aliases[alias]))
            return

        # Allow an alias to be an event key
        if not ValidationHelper.event_id_validator(alias):
            event = Event.get_by_id(alias)
            if event and event.webcast and event.within_a_day:
                params = self.get_param_string_for_event(event)
                self.redirect("/gameday{}".format(params))
                return

        # Allow an alias to be a team number
        team_key = "frc{}".format(alias)
        if not ValidationHelper.team_id_validator(team_key):
            now = datetime.datetime.now()
            team_events_future = TeamYearEventsQuery(team_key,
                                                     now.year).fetch_async()
            team_events = team_events_future.get_result()
            for event in team_events:
                if event and event.webcast and event.within_a_day:
                    params = self.get_param_string_for_event(event)
                    self.redirect("/gameday{}".format(params))
                    return

        self.redirect("/gameday")
        return
Example #2
0
    def get(self, alias):
        special_webcasts_future = Sitevar.get_by_id_async('gameday.special_webcasts')
        special_webcasts = special_webcasts_future.get_result()
        aliases = special_webcasts.contents.get("aliases", {}) if special_webcasts else {}

        if alias in aliases:
            self.redirect("/gameday{}".format(aliases[alias]))
            return

        # Allow an alias to be an event key
        if not ValidationHelper.event_id_validator(alias):
            event = Event.get_by_id(alias)
            if event and event.webcast and event.within_a_day:
                params = self.get_param_string_for_event(event)
                self.redirect("/gameday{}".format(params))
                return

        # Allow an alias to be a team number
        team_key = "frc{}".format(alias)
        if not ValidationHelper.team_id_validator(team_key):
            now = datetime.datetime.now()
            team_events_future = TeamYearEventsQuery(team_key, now.year).fetch_async()
            team_events = team_events_future.get_result()
            for event in team_events:
                if event and event.webcast and event.within_a_day:
                    params = self.get_param_string_for_event(event)
                    self.redirect("/gameday{}".format(params))
                    return

        self.redirect("/gameday")
        return
    def get(self, *args, **kw):
        self._validate_tba_app_id()
        self._errors = ValidationHelper.validate(self._validators)
        if self._errors:
            self.abort(400)

        self._track_call(*args, **kw)
        super(ApiBaseController, self).get(*args, **kw)
    def get(self, *args, **kw):
        self._validate_tba_app_id()
        self._errors = ValidationHelper.validate(self._validators)
        if self._errors:
            self.abort(400)

        self._track_call(*args, **kw)
        super(ApiBaseController, self).get(*args, **kw)
 def test_match_validation(self):
     errors = ValidationHelper.validate([("match_id_validator",
                                          "0010c1_0m2")])
     self.assertEqual(
         errors,
         {"Errors": [{
             "match_id": "0010c1_0m2 is not a valid match id"
         }]})
    def get(self, *args, **kw):
        self._validate_tba_app_id()
        self._errors = ValidationHelper.validate(self._validators)
        if self._errors:
            self.abort(400)

        self._track_call(*args, **kw)
        super(ApiBaseController, self).get(*args, **kw)
        self.response.headers['X-TBA-Version'] = '{}'.format(self.API_VERSION)
Example #7
0
    def get(self, *args, **kw):
        self._validate_tba_app_id()
        self._errors = ValidationHelper.validate(self._validators)
        if self._errors:
            self.abort(400)

        self._track_call(*args, **kw)
        super(ApiBaseController, self).get(*args, **kw)
        self.response.headers['X-TBA-Version'] = '{}'.format(self.API_VERSION)
    def get(self, *args, **kw):
        self._validate_tba_app_id()
        self._errors = ValidationHelper.validate(self._validators)
        if self._errors:
            self.abort(400)

        self._track_call(*args, **kw)
        super(ApiBaseController, self).get(*args, **kw)
        self._set_cache_header_length(self.CACHE_HEADER_LENGTH)
    def get(self, *args, **kw):
        self._validate_tba_app_id()
        self._errors = ValidationHelper.validate(self._validators)
        if self._errors:
            self.abort(400)

        self._track_call(*args, **kw)
        super(ApiBaseController, self).get(*args, **kw)
        self.response.headers["X-TBA-Version"] = "{}".format(self.API_VERSION)
        self.response.headers["Vary"] = "Accept-Encoding"
    def get(self, *args, **kw):
        self._validate_tba_auth_key()
        self._errors = ValidationHelper.validate_request(self)
        if self._errors:
            self.abort(404)

        self._track_call(*args, **kw)
        super(ApiBaseController, self).get(*args, **kw)
        self.response.headers['X-TBA-Version'] = '{}'.format(self.API_VERSION)
        self.response.headers['Vary'] = 'Accept-Encoding'
    def get(self, *args, **kw):
        self._validate_tba_app_id()
        self._errors = ValidationHelper.validate(self._validators)
        if self._errors:
            self.abort(400)

        self._track_call(*args, **kw)
        super(ApiBaseController, self).get(*args, **kw)
        self.response.headers["X-TBA-Version"] = "{}".format(self.API_VERSION)
        self._set_cache_header_length(self.CACHE_HEADER_LENGTH)
    def get(self, *args, **kw):
        self._validate_tba_auth_key()
        self._errors = ValidationHelper.validate_request(self)
        if self._errors:
            self.abort(404)

        self._track_call(*args, **kw)
        super(ApiBaseController, self).get(*args, **kw)
        self.response.headers['X-TBA-Version'] = '{}'.format(self.API_VERSION)
        self.response.headers['Vary'] = 'Accept-Encoding'
    def post(self, *args, **kw):
        self._validate_tba_auth_key()
        self._errors = ValidationHelper.validate_request(self)
        if self._errors:
            self.abort(404)

        rendered = self._render(*args, **kw)
        self._track_call(*args, **kw)
        self.response.out.write(rendered)
        self.response.headers['X-TBA-Version'] = '{}'.format(self.API_VERSION)
        self.response.headers['Vary'] = 'Accept-Encoding'
    def post(self, *args, **kw):
        self._validate_tba_auth_key()
        self._errors = ValidationHelper.validate_request(self)
        if self._errors:
            self.abort(404)

        rendered = self._render(*args, **kw)
        self._track_call(*args, **kw)
        self.response.out.write(rendered)
        self.response.headers['X-TBA-Version'] = '{}'.format(self.API_VERSION)
        self.response.headers['Vary'] = 'Accept-Encoding'
    def post(self, *args, **kw):
        with TraceContext() as root:
            with root.span("ApiBaseController.post"):
                self._validate_tba_auth_key()
                self._errors = ValidationHelper.validate_request(self)
                if self._errors:
                    self.abort(404)

                rendered = self._render(*args, **kw)
                self.response.out.write(rendered)
                self.response.headers['X-TBA-Version'] = '{}'.format(self.API_VERSION)
                self.response.headers['Vary'] = 'Accept-Encoding'

                if not self._errors:
                    self._track_call(*args, **kw)
 def test_combo_validation(self):
     errors = ValidationHelper.validate([("match_id_validator",
                                          "0010c1_0m2"),
                                         ("team_id_validator", "frc01"),
                                         ("event_id_validator", "1cmp")])
     self.assertEqual(
         errors, {
             "Errors": [{
                 "match_id": "0010c1_0m2 is not a valid match id"
             }, {
                 "team_id": "frc01 is not a valid team id"
             }, {
                 "event_id": "1cmp is not a valid event id"
             }]
         })
    def post(self, *args, **kw):
        with TraceContext() as root:
            with root.span("ApiBaseController.post"):
                self._validate_tba_auth_key()
                self._errors = ValidationHelper.validate_request(self)
                if self._errors:
                    self.abort(404)

                rendered = self._render(*args, **kw)
                self.response.out.write(rendered)
                self.response.headers['X-TBA-Version'] = '{}'.format(
                    self.API_VERSION)
                self.response.headers['Vary'] = 'Accept-Encoding'

                if not self._errors:
                    self._track_call(*args, **kw)
Example #18
0
	def __get_images_norm_and_scaled(self, image_file_name: str):
		_input = self.get_model().get_inputs()[self._input_output_id]
		input_shape = ValidationHelper.get_list_filtered_from_none(_input['shape'])
		target_channels = min(input_shape)
		target_size = tuple(list(filter(lambda item: item != target_channels, input_shape)))
		if not os.path.isfile(image_file_name) or not os.access(image_file_name, os.R_OK):
			self.get_model().set_error(MindError(
				ERROR_CODE_FILTER_FILE_IS_UNREACHABLE,
				'{}: file [{}] is not accessible',
				[self.__class__.__name__, image_file_name]
			))
			return
		_image = Image.open(image_file_name)
		_image = _image.resize(target_size, Image.ANTIALIAS)
		_image = _image.convert(mode=self.__get_pillow_mode_for_channels(target_channels))
		result = np.asarray(_image, dtype=_input['type'])
		result /= 255  # normalization
		result = result.reshape(input_shape)
		return result
 def testEventValidation(self):
     errors = ValidationHelper.validate([("event_id_validator", "1cmp")])
     self.assertEqual(errors, {"Errors": [{"event_id": "1cmp is not a valid event id"}]})
 def test_event_validation(self):
     errors = ValidationHelper.validate([("event_id_validator", "1cmp")])
     self.assertEqual(
         errors, {"Errors": [{
             "event_id": "1cmp is not a valid event id"
         }]})
 def testMichiganEigthFinalsValidValidation(self):
     errors = ValidationHelper.validate([("match_id_validator", "2015micmp_ef3m1")])
     self.assertEqual(None, errors)
 def testTeamValidation(self):
     errors = ValidationHelper.validate([("team_id_validator", "frc01")])
     self.assertEqual(errors, {"Errors": [{"team_id": "frc01 is not a valid team id"}]})
 def testValidValidation(self):
     errors = ValidationHelper.validate([("team_id_validator", "frc101")])
     self.assertEqual(None, errors)
 def test_michigan_eigth_finals_valid_validation(self):
     errors = ValidationHelper.validate([("match_id_validator",
                                          "2015micmp_ef3m1")])
     self.assertEqual(None, errors)
 def test_multi_digits_in_event_key(self):
     errors = ValidationHelper.validate([("event_id_validator", "2017bc18")
                                         ])
     self.assertEqual(None, errors)
 def test_valid_validation(self):
     errors = ValidationHelper.validate([("team_id_validator", "frc101")])
     self.assertEqual(None, errors)
 def test_multi_digits_in_event_key(self):
     errors = ValidationHelper.validate([("event_id_validator", "2017bc18")])
     self.assertEqual(None, errors)
 def testMatchValidation(self):
     errors = ValidationHelper.validate([("match_id_validator", "0010c1_0m2")])
     self.assertEqual(errors, {"Errors": [{"match_id": "0010c1_0m2 is not a valid match id"}]})
 def test_team_validation(self):
     errors = ValidationHelper.validate([("team_id_validator", "frc01")])
     self.assertEqual(
         errors, {"Errors": [{
             "team_id": "frc01 is not a valid team id"
         }]})
 def testComboValidation(self):
     errors = ValidationHelper.validate([("match_id_validator", "0010c1_0m2"),
         ("team_id_validator", "frc01"),
         ("event_id_validator", "1cmp")])
     self.assertEqual(errors, {"Errors": [{"match_id": "0010c1_0m2 is not a valid match id"}, {"team_id": "frc01 is not a valid team id"},{"event_id": "1cmp is not a valid event id"}]})