def get(self, agency_tag, route_tag): # pylint: disable=arguments-differ if not agency_tag: error_response1 = exceptions.MissingArgumentValue( 'Missing argument agency') self.build_response(error_response1) return if not route_tag: error_response2 = exceptions.MissingArgumentValue( 'Missing argument route tag') self.build_response(error_response2) return last_time = self.get_query_argument(api.QUERY_LAST_TIME, None) if not last_time: error_response3 = exceptions.MissingArgumentValue( 'Missing argument {0}'.format(api.QUERY_LAST_TIME)) self.build_response(error_response3) return agency_obj = agency.Agency(agency_tag, self.application_settings) route_messages = yield agency_obj.get_route_vehicles( agency_tag, route_tag, last_time) self.build_response(route_messages)
def get(self, agency_tag, route_tag): # pylint: disable=arguments-differ if not agency_tag: error_response = exceptions.MissingArgumentValue( 'Missing argument agency') self.build_response(error_response) return if not route_tag: error_response = exceptions.MissingArgumentValue( 'Missing argument route tag') self.build_response(error_response) return agency_obj = agency.Agency(agency_tag, self.application_settings) schedule = yield agency_obj.get_route_schedule(agency_tag, route_tag) self.build_response(schedule)
def get(self, agency_tag, route_tag): # pylint: disable=arguments-differ if not agency_tag: error_response1 = exceptions.MissingArgumentValue('Missing argument agency') self.build_response(error_response1) return if not route_tag: error_response2 = exceptions.MissingArgumentValue('Missing argument route tag') self.build_response(error_response2) return stop_tag = self.get_query_argument(api.QUERY_STOP_TAG, None) if not stop_tag: error_response3 = exceptions.MissingArgumentValue('Missing argument {0}'. format(api.QUERY_STOP_TAG)) self.build_response(error_response3) return agency_obj = agency.Agency(agency_tag, self.application_settings) route_messages = yield agency_obj.get_route_predictions(agency_tag, route_tag, stop_tag) self.build_response(route_messages)
def get(self, agency_tag, route_tag): # pylint: disable=arguments-differ if not agency_tag: error_response = exceptions.MissingArgumentValue( 'Missing argument agency') self.build_response(error_response) return criteria = {} if route_tag: criteria[api.CRITERIA_ROUTE_TAG] = route_tag not_running_at = self.get_query_argument(api.QUERY_NOT_RUNNING_AT, None) if not_running_at: if len(not_running_at) == 1: not_running_at = '0{0}:00:00'.format(not_running_at) elif len(not_running_at) == 2: not_running_at = '{0}:00:00'.format(not_running_at) elif len(not_running_at) == 4: not_running_at = '0{0}:00'.format(not_running_at) elif len(not_running_at) == 5: not_running_at = '{0}:00'.format(not_running_at) elif len(not_running_at) == 8: pass else: error_response2 = exceptions.InvalidArgumentValue( 'Invalid value {0} for {1} argument'.format( not_running_at, api.QUERY_NOT_RUNNING_AT)) self.build_response(error_response2) return criteria[api.CRITERIA_NOT_RUNNING_AT] = not_running_at fields = self.get_query_argument(api.QUERY_FIELDS, None) fields = fields.split(',') if fields else [] agency_obj = agency.Agency(agency_tag, self.application_settings) if route_tag: route = yield agency_obj.get_route(route_tag, fields) self.build_response(route) else: routes = yield agency_obj.get_routes(criteria) response = {api.TAG_ROUTES: routes} self.build_response(response)
def test_MissingArgumentValue(self): try: raise exceptions.MissingArgumentValue( "Testing MissingArgumentValue") except exceptions.MissingArgumentValue: pass