-
Notifications
You must be signed in to change notification settings - Fork 221
Description
Describe the bug
Due to logic and variable number using double prefix args (--lt, --ed etc) is required.
Python code
`
parser = ArgumentParser()
parser.add_argument(
"--es",
type = float,
dest = "e_start",
action="append",
required = True,
help = "e_start"
)
parser.add_argument(
"--ee",
type = float,
dest = "e_end",
action="append",
required = True,
help = "e_end"
)
parser.add_argument(
"--eu",
type = float,
dest = "e_suitei",
action="append",
required = True,
help = "e_suitei"
)
`
Javascript code
return new Promise(async (resolve, reject) => { let arg = []; stations.forEach(st => { arg.push(
--es${st.es}); arg.push(
--ee${st.ee}); arg.push(
--eu${st.eu}`);
});
let options = {
mode: 'text',
pythonOptions: ['-u'],
scriptPath: `${PROJECT_DIR}/src/scripts/algorithm`,
args: arg,
};
}`
Expected behavior
Run the python script by given args
Actual behavior
PythonShellError: usage: *.py [-h] --ee LAT --es LON --eu N
0|index |
0|index | lagrange.py: error: the following arguments are required: --es, --ee, --eu
0|index | at PythonShell.parseError (/workspace/node_modules/python-shell/index.js:268:21)
0|index | at terminateIfNeeded (/workspace/node_modules/python-shell/index.js:139:32)
0|index | at ChildProcess. (/workspace/node_modules/python-shell/index.js:131:13)
0|index | at ChildProcess.emit (node:events:513:28)
0|index | at ChildProcess._handle.onexit (node:internal/child_process:291:12) {
0|index | executable: 'python3',
0|index | options: [ '-u' ],
0|index | script: '/workspace/src/scripts/algorithm/lagrange.py',
0|index | args: [
0|index | '--ee 35.96691467421596',
0|index | '--es 140.0746095366776',
0|index | '--eu 36.1061130',
Other Information (please complete the following information):
- OS: [e.g. Windows10]
- Python Version [e.g. 3.6]
- Node Version [e.g. 12]
Additional context
Data validity or why using args with double-digit naming such a small number of inputs is not essential. The above is only for reproducing the error. The actual code and log are too long.
When using single digit args -e instead of --ee, there is no issue.