diff --git a/helpers/odmOptionsToJson.py b/helpers/odmOptionsToJson.py
new file mode 100644
index 0000000..578d3ce
--- /dev/null
+++ b/helpers/odmOptionsToJson.py
@@ -0,0 +1,38 @@
+#!/usr/bin/env python
+'''
+Node-OpenDroneMap Node.js App and REST API to access OpenDroneMap.
+Copyright (C) 2016 Node-OpenDroneMap Contributors
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see .
+'''
+
+import sys
+import imp
+import argparse
+import json
+
+imp.load_source('context', sys.argv[2] + '/opendm/context.py')
+odm = imp.load_source('config', sys.argv[2] + '/opendm/config.py')
+
+options = {}
+class ArgumentParserStub(argparse.ArgumentParser):
+ def add_argument(self, *args, **kwargs):
+ argparse.ArgumentParser.add_argument(self, *args, **kwargs)
+ options[args[0]] = {}
+ for name, value in kwargs.items():
+ options[args[0]][str(name)] = str(value)
+
+odm.parser = ArgumentParserStub()
+odm.config()
+print json.dumps(options)
diff --git a/index.js b/index.js
index 2d9d3ec..ce0149f 100644
--- a/index.js
+++ b/index.js
@@ -158,7 +158,7 @@ process.on ('SIGINT', gracefulShutdown);
// Startup
let taskManager;
let server;
-
+/*
async.series([
cb => { taskManager = new TaskManager(cb); },
cb => { server = app.listen(3000, err => {
@@ -168,4 +168,6 @@ async.series([
}
], err => {
if (err) console.log("Error during startup: " + err.message);
-});
+});*/
+let odmOptionsParser = require('./libs/odmOptionsParser');
+odmOptionsParser.getOptions(function(){});
diff --git a/libs/Task.js b/libs/Task.js
index 9a3eea6..ff5c077 100644
--- a/libs/Task.js
+++ b/libs/Task.js
@@ -137,7 +137,7 @@ module.exports = class Task{
this.setStatus(statusCodes.CANCELED);
if (wasRunning && this.runnerProcess){
- // TODO: this does guarantee that
+ // TODO: this does NOT guarantee that
// the process will immediately terminate.
// In fact, often times ODM will continue running for a while
// This might need to be fixed on ODM's end.
diff --git a/libs/odmOptionsParser.js b/libs/odmOptionsParser.js
new file mode 100644
index 0000000..8329db9
--- /dev/null
+++ b/libs/odmOptionsParser.js
@@ -0,0 +1,75 @@
+/*
+Node-OpenDroneMap Node.js App and REST API to access OpenDroneMap.
+Copyright (C) 2016 Node-OpenDroneMap Contributors
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see .
+*/
+"use strict";
+let odmRunner = require('./odmRunner');
+
+module.exports = {
+ getOptions: function(done){
+ odmRunner.getJsonOptions((err, json) => {
+ if (err) done(err);
+ else{
+ for (let option in json){
+ if (option === "-h") continue;
+ let values = json[option];
+
+ let type = "";
+ let defaultValue = "";
+ let help = values.help || "";
+ let range = values.metavar.replace(/[<>]/g, "").trim();
+
+ switch(values.type.trim()){
+ case "":
+ type = "int";
+ defaultValue = values['default'] !== undefined ?
+ parseInt(values['default']) :
+ 0;
+ break;
+ case "":
+ type = "float";
+ defaultValue = values['default'] !== undefined ?
+ parseFloat(values['default']) :
+ 0.0;
+ break;
+ default:
+ type = "string";
+ defaultValue = values['default'].trim();
+ }
+
+ if (values['default'] === "True"){
+ type = "bool";
+ defaultValue = true;
+ }else if (values['default'] === "False"){
+ type = "bool";
+ defaultValue = false;
+ }
+
+
+
+ let result = {
+ type, defaultValue, range, help
+ };
+
+ console.log(values);
+ console.log(result);
+ console.log('-----');
+ }
+ done();
+ }
+ });
+ }
+};
diff --git a/libs/odmRunner.js b/libs/odmRunner.js
index 6cd41f7..281433c 100644
--- a/libs/odmRunner.js
+++ b/libs/odmRunner.js
@@ -44,5 +44,30 @@ module.exports = {
});
return childProcess;
+ },
+
+ getJsonOptions: function(done){
+ // Launch
+ let childProcess = spawn("python", [`${__dirname}/../helpers/odmOptionsToJson.py`,
+ "--project-path", ODM_PATH]);
+ let output = [];
+
+ childProcess
+ .on('exit', (code, signal) => {
+ try{
+ let json = JSON.parse(output.join(""));
+ done(null, json);
+ }catch(err){
+ done(err);
+ }
+ })
+ .on('error', done);
+
+ let processOutput = chunk => {
+ output.push(chunk.toString());
+ };
+
+ childProcess.stdout.on('data', processOutput);
+ childProcess.stderr.on('data', processOutput);
}
};