Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

in some specific casees, marx needs to be run in TTY and not with a pipe connected to Stdin #78

Open
hamogu opened this issue Dec 7, 2023 · 0 comments

Comments

@hamogu
Copy link
Member

hamogu commented Dec 7, 2023

I'm encountering this when I call marx through from Python through subprocess.run. I don't think it's Python specific and I can probably use shell constructs, too, to trigger the same behavior, but I'm just going to stick with the "Calling from Python" here as an example.

I noticed that MARX fails with stdin is NOT a tty. is certain parameters are passed. Most parameters are fine, but a certain subset of them triggers this, if marx is not called from a shell, e.g.:
subprocess.run(['marx', 'SpectrumType="FILE"', 'SpectrumFile=abspowerlaw.spec').
It works fine, if there is no SpectrumFile parameters. Tracing around the code a bit, it comes down to _pf_query_current_value in pfquery.c which is triggered for reading from parameters in marx.par that are of type "f" (file). Note, that this does not apply to fits files (e.g. the ASPSOL file), which are read as parameter type "string" and then that file name string is passed to jdfits. However, text files are read with the pfiles modules that's part of marx which triggers this.

While the pfiles module is written to require a TTY, I don't see fundamentally why it has to be. On the other hand, I'm somewhat reluctant to change the C implementation of something that works for just a tiny bit on increased convenience for calling marx from Python.

For my immediate use case, I can work around that by changing the syntax slightly and passing it all to a new shell:
subprocess.run(['marx SpectrumType="FILE" SpectrumFile=abspowerlaw.spec'], shell=True).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant