mirror of
https://github.com/EDCD/EDDN.git
synced 2025-04-20 18:47:39 +03:00
Make use of pkg_resources to keep egg file zipped
Used to keep schemas in egg file
This commit is contained in:
parent
86cdb0d912
commit
6a86ee904f
@ -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
|
||||
|
||||
|
@ -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):
|
||||
|
Loading…
x
Reference in New Issue
Block a user