diff --git a/helpers/odmOptionsToJson.py b/helpers/odmOptionsToJson.py index 578d3ce..5491457 100644 --- a/helpers/odmOptionsToJson.py +++ b/helpers/odmOptionsToJson.py @@ -22,6 +22,8 @@ import imp import argparse import json +sys.path.append(sys.argv[2]) + imp.load_source('context', sys.argv[2] + '/opendm/context.py') odm = imp.load_source('config', sys.argv[2] + '/opendm/config.py') diff --git a/libs/Task.js b/libs/Task.js index 0050cf6..1f47d02 100644 --- a/libs/Task.js +++ b/libs/Task.js @@ -397,14 +397,14 @@ module.exports = class Task{ return result; }, {}); - runnerOptions["project-path"] = fs.realpathSync(this.getProjectFolderPath()); + runnerOptions["project-path"] = fs.realpathSync(Directories.data); runnerOptions["pmvs-num-cores"] = os.cpus().length; if (this.gpcFiles.length > 0){ runnerOptions.gcp = fs.realpathSync(path.join(this.getGpcFolderPath(), this.gpcFiles[0])); } - this.runningProcesses.push(odmRunner.run(runnerOptions, (err, code, signal) => { + this.runningProcesses.push(odmRunner.run(runnerOptions, this.uuid, (err, code, signal) => { if (err){ this.setStatus(statusCodes.FAILED, {errorMessage: `Could not start process (${err.message})`}); finished(err); diff --git a/libs/odmOptions.js b/libs/odmOptions.js index 7e933e5..6c5bf6f 100644 --- a/libs/odmOptions.js +++ b/libs/odmOptions.js @@ -18,6 +18,7 @@ along with this program. If not, see . "use strict"; let odmRunner = require('./odmRunner'); let assert = require('assert'); +let logger = require('./logger'); let odmOptions = null; @@ -84,6 +85,20 @@ module.exports = { value = false; } + // If 'choices' is specified, try to convert it to array + if (values.choices){ + try{ + values.choices = JSON.parse(values.choices.replace(/'/g, '"')); // Convert ' to " + }catch(e){ + logger.warn(`Cannot parse choices: ${values.choices}`); + } + } + + if (Array.isArray(values.choices)){ + type = "string"; // TODO: change to enum + domain = values.choices; + } + help = help.replace(/\%\(default\)s/g, value); // In the end, all values must be converted back @@ -186,7 +201,9 @@ module.exports = { validate: function(){ return true; // All strings/paths are fine } - } + } + + // TODO: handle enum ]; let checkDomain = function(domain, value){ diff --git a/libs/odmRunner.js b/libs/odmRunner.js index 460cb6b..3efd30a 100644 --- a/libs/odmRunner.js +++ b/libs/odmRunner.js @@ -25,7 +25,8 @@ let logger = require('./logger'); module.exports = { - run: function(options, done, outputReceived){ + run: function(options, projectName, done, outputReceived){ + assert(projectName !== undefined, "projectName must be specified"); assert(options["project-path"] !== undefined, "project-path must be defined"); let command = [path.join(config.odm_path, "run.py")]; @@ -43,6 +44,8 @@ module.exports = { } } + command.push(projectName); + logger.info(`About to run: python ${command.join(" ")}`); if (config.test){ @@ -102,7 +105,7 @@ module.exports = { // Launch let childProcess = spawn("python", [path.join(__dirname, "..", "helpers", "odmOptionsToJson.py"), - "--project-path", config.odm_path]); + "--project-path", config.odm_path, "bogusname"]); let output = []; childProcess