Closed bieryAtFnal closed 2 years ago
I think the problem is that sys.argv
does not take into account how the script was originally called (python -m <script>
or /usr/bin/env python <script>
)
In my original text, I should have said that the original changes from Eric are very likely desirable, but at a later time.
Since we always use the interpreter, would it be too hacky to write something like:
f.write("python -m minidaqapp.nanorc.mdapp_multiru_gen " + ' '.join(sys.argv[1:]) + "\n")
If we hacky is what we want... 😉
f.write(f"{sys.executable} -m {__name__} {' '.join(sys.argv[1:])}\n")
Maybe it's worth also adding a minimal protection against spaces in one of the arguments
import shlex # have we got shlex in our pyenv?
f.write(f"{sys.executable} -m {__name__} {' '.join((shlex.quote(a) if ' ' in a else a) for sys.argv[1:])}\n")
I believe this PR is obsolete, as v2.8.2 was released with the other form of the command-line capture.
Alessandro and Eric...
Alessandro, on this branch, I provide a simpler command-line option capture which I believe is more in the spirit of what you were looking for.
I'm sending this change to you for your consideration and any discussion that you would like to have with Eric about his version of the change.
For reference, Eric's change (which is already on the patch/2.8.2 branch) produces a file with contents like the following. I have been using this change in all of my testing this afternoon, and it has performed fine for me:
The code on this branch produces a simpler file:
In both cases, it's not obvious how to use the whole string to re-run the confgen script. the first argument always generates a complaint, for me. But, we can still make use of the rest of the arguments.