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

[makeotf] consume tx stderr #1074

Closed
benkiel opened this issue Jan 4, 2020 · 4 comments
Closed

[makeotf] consume tx stderr #1074

benkiel opened this issue Jan 4, 2020 · 4 comments

Comments

@benkiel
Copy link
Contributor

benkiel commented Jan 4, 2020

(this is a weird edge case, so feel free to close)

When running makeotf from inside another script and redirecting stdout and stderr to a file, the tx errors when converting a format

if not fdkutils.run_shell_command(['tx', '-t1', filePath, fontPath]):
are still printed to stderr (in my case, complaints about underline thickness). I think that if that line was change to consume stderr (as in #751) this would go away. (think as i've not had time to test that change)

@josh-hadley
Copy link
Collaborator

Out of curiosity: did this ever work the way you wanted it to (i.e. in older versions of AFDKO)? The reason I ask is, we've been tinkering with that run_shell_command routine to work around some intermittent issues with our automated testing. Maybe we need to give it some more attention. Can you attach (or describe) a simple test case that reproduces this?

@miguelsousa
Copy link
Member

@josh-hadley before 5f6f575 the messages from tx and other commands were always discarded (see all the 2>&1 tokens thruout). I understand Ben's request but I don't think we should go back to muting everything by default. Perhaps a workable solution is to enabling switching them off by piggy-backing on an existing makeotf option.

@benkiel
Copy link
Contributor Author

benkiel commented Jan 7, 2020

@josh-hadley Yes, I can put together a sample script. For what I was doing, I've gone back to subprocess like so:

args = ["makeotf", "-f", file, "-o", outputPath, "-r", "-nshw"]
run = subprocess.run(args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, universal_newlines=True)
with open(path, "w") as f:
    f.write(run.stdout)

which consumes the even the tx output from makeotf when making a TTF.

Previously I was doing:

from contextlib import redirect_stdout, redirect_stderr
args = ["-f", file, "-o", outputPath, "-r", "-nshw"]
with open(os.path.join(outputPath, f"makeotf_output.txt"), "a") as f:
    with redirect_stdout(f), redirect_stderr(f):
        makeOTFParams = makeotf.MakeOTFParams()
        makeotf.getOptions(makeOTFParams, args)
        makeotf.setMissingParams(makeOTFParams)
        makeotf.setOptionsFromFontInfo(makeOTFParams)

        makeotf.runMakeOTF(makeOTFParams)

That wouldn't catch the output from tx when it was run to convert the TTF for making a TTF.

Again, I don't think this is a big issue, and should likely be closed. Subprocess is likely the better way to run this, not calling it directly in another script.

@josh-hadley
Copy link
Collaborator

Closing, per discussion.

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

3 participants