diff --git a/src/eddn/Gateway.py b/src/eddn/Gateway.py index cdab0a2..58ac841 100644 --- a/src/eddn/Gateway.py +++ b/src/eddn/Gateway.py @@ -13,7 +13,8 @@ import zlib import zmq.green as zmq from datetime import datetime -import os +from pkg_resources import resource_string +# import os from eddn.conf.Settings import Settings, loadConfig from eddn.core.Validator import Validator, ValidationSeverity @@ -44,7 +45,8 @@ def configure(): sender.bind(binding) for schemaRef, schemaFile in Settings.GATEWAY_JSON_SCHEMAS.iteritems(): - validator.addSchemaResource(schemaRef, os.path.dirname(__file__) + '/' + schemaFile) + validator.addSchemaResource(schemaRef, resource_string(__name__, schemaFile)) + # validator.addSchemaResource(schemaRef, os.path.dirname(__file__) + '/' + schemaFile) def push_message(string_message, topic): @@ -137,7 +139,7 @@ def parse_and_error_handle(data): 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 - # it as the EMDR upload key value. + # it as the EDDN upload key value. ip_hash = hashlib.sha1(ip_hash_salt + get_remote_address()).hexdigest() parsed_message['header']['uploaderKey'] = ip_hash diff --git a/src/eddn/core/Validator.py b/src/eddn/core/Validator.py index 18ea5b4..93398fb 100644 --- a/src/eddn/core/Validator.py +++ b/src/eddn/core/Validator.py @@ -9,10 +9,10 @@ class Validator(object): schemas = {"http://example.com": {}} - def addSchemaResource(self, schemaRef, schemaFile): + def addSchemaResource(self, schemaRef, schema): if schemaRef in self.schemas.keys(): raise Exception("Attempted to redefine schema for " + schemaRef) - schema = simplejson.load(open(schemaFile, "r")) + schema = simplejson.loads(schema) self.schemas[schemaRef] = schema def validate(self, json_object):