def __fetch_configuration(self, coordinator): if __debug__: logging.debug('coordinator: %s', coordinator) stream = urllib2.urlopen(coordinator.configuration_url()) body = stream.read() info = stream.info() if body: if __debug__: logging.debug('Got representation: %s', body) new_timestamp = timestamper.try_loads(info.get('x-timestamp', None)) if new_timestamp: new_configuration = configuration.try_load_json(body, timestamp=new_timestamp) return (new_configuration, coordinator) return (None, coordinator)
def __get_timestamp(self, env): try: return timestamper.try_loads(env.get('HTTP_X_TIMESTAMP', None)) or timestamper.now() except ValueError: raise httpserver.BadRequest()