From 04a8f91b8c6f0fad29cebb131763d0e69553bc9b Mon Sep 17 00:00:00 2001 From: Jonathan Harris Date: Mon, 3 Jul 2017 12:58:44 +0100 Subject: [PATCH] Rewrite schemas during transition period --- src/eddn/Gateway.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/eddn/Gateway.py b/src/eddn/Gateway.py index e288518..fd95333 100644 --- a/src/eddn/Gateway.py +++ b/src/eddn/Gateway.py @@ -37,6 +37,11 @@ statsCollector = StatsCollector() statsCollector.start() +# Migration from schemas.elite-markets.net to eddn.edcd.io - Remove after transition complete! +import re +TRANSITION_RE = re.compile('^https://eddn.edcd.io/schemas/(.+)') + + def configure(): # Get the list of transports to bind from settings. This allows us to PUB # messages to multiple announcers over a variety of socket types @@ -145,6 +150,11 @@ def parse_and_error_handle(data): if validationResults.severity <= ValidationSeverity.WARN: parsed_message['header']['gatewayTimestamp'] = datetime.utcnow().isoformat() + 'Z' + # Migration from schemas.elite-markets.net to eddn.edcd.io - Remove after transition complete! + match = TRANSITION_RE.match(parsed_message['$schemaRef']) + if match and match.group(1): + parsed_message['$schemaRef'] = 'http://schemas.elite-markets.net/eddn/%s' % match.group(1) + ip_hash_salt = Settings.GATEWAY_IP_KEY_SALT if ip_hash_salt: # If an IP hash is set, salt+hash the uploader's IP address and set