Skip to content

Commit

Permalink
Fix the parsing of the composition file to JSON when required by Debu…
Browse files Browse the repository at this point in the history
…g (admin) api
  • Loading branch information
debbabi committed Oct 7, 2016
1 parent 4e34262 commit 6c720d3
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions python/cohorte/composer/top/composer.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@
@Requires('_monitor', cohorte.monitor.SERVICE_MONITOR)
@Requires('_node_starter', cohorte.SERVICE_NODE_STARTER)
# ######### added by: Bassem D.
@Requires('_parser', cohorte.composer.SERVICE_PARSER,
optional=False)
@Requires('_parser', cohorte.composer.SERVICE_PARSER, optional=False)
@Requires('_reader', cohorte.SERVICE_FILE_READER, optional=False)
@Property('_autostart', 'autostart', "True")
@Property('_composition_filename', 'composition.filename', "composition.js")
# #########
Expand All @@ -91,6 +91,7 @@ def __init__(self):
self._node_starter = None
# ######### added by: Bassem D.
self._parser = None
self._reader = None
self._autostart = None
self._composition_filename = None
self._composition_json = None
Expand Down Expand Up @@ -130,8 +131,10 @@ def validate(self, context):
if str(self._autostart).lower() in ("true", "yes"):
# Load the composition
try:
composition = self._parser.load(
self._composition_filename, "conf")
self._composition_json = self._reader.load_file(
self._composition_filename, "conf")
composition = self._parser.parse_composition(
self._composition_filename, self._composition_json)
if composition:
_logger.info("Loading composition...")
uid = self.start(composition)
Expand Down Expand Up @@ -228,11 +231,5 @@ def stop(self, uid):
def get_composition_json(self):
"""
Gets composition JSON file raw content
"""
if not self._composition_json:
# parse the composition file
conf_dir = os.path.join(self._context.get_property("cohorte.base"), "conf")
file_name = os.path.join(conf_dir, self._composition_filename)
with open(file_name, "r") as comp_json_file:
self._composition_json = json.load(comp_json_file)
"""
return self._composition_json

0 comments on commit 6c720d3

Please sign in to comment.