def __init__(self, path=None):
self.path = path or os.getenv('WEBHDFS_CONFIG', self.default_path)
if osp.exists(self.path):
try:
self.config = json.loads(open(self.path).read())
self.schema = json.loads(resource_string(__name__, 'resources/config_schema.json'))
#self.schema = open("resources/schema.config").read()
try:
js.validate(self.config, self.schema)
except js.ValidationError as e:
print e.message
except js.SchemaError as e:
print e
except ParsingError:
raise HdfsError('Invalid configuration file %r.', self.path)
_logger.info('Instantiated configuration from %r.', self.path)
else:
raise HdfsError('Invalid configuration file %r.', self.path)
评论列表
文章目录