Skip to content

Remove ghostscript message when converting PDFs#404

Open
Matistjati wants to merge 1 commit intoKattis:masterfrom
Matistjati:402-remove-ghostscript-output
Open

Remove ghostscript message when converting PDFs#404
Matistjati wants to merge 1 commit intoKattis:masterfrom
Matistjati:402-remove-ghostscript-output

Conversation

@Matistjati
Copy link
Copy Markdown
Contributor

Closes #402.
Before:

Loading problem fredrikspizzeria
Checking config
Checking statement
GPL Ghostscript 9.55.0 (2021-09-27)
Copyright (C) 2021 Artifex Software, Inc.  All rights reserved.
This software is supplied under the GNU AGPLv3 and comes with NO WARRANTY:
see the file COPYING for details.
Processing pages 1 through 1.
Page 1
GPL Ghostscript 9.55.0 (2021-09-27)
Copyright (C) 2021 Artifex Software, Inc.  All rights reserved.
This software is supplied under the GNU AGPLv3 and comes with NO WARRANTY:
see the file COPYING for details.
Processing pages 1 through 1.
Page 1
GPL Ghostscript 9.55.0 (2021-09-27)
Copyright (C) 2021 Artifex Software, Inc.  All rights reserved.
This software is supplied under the GNU AGPLv3 and comes with NO WARRANTY:
see the file COPYING for details.
Processing pages 1 through 1.
Page 1
GPL Ghostscript 9.55.0 (2021-09-27)
Copyright (C) 2021 Artifex Software, Inc.  All rights reserved.
This software is supplied under the GNU AGPLv3 and comes with NO WARRANTY:
see the file COPYING for details.
Processing pages 1 through 1.
Page 1
Checking validators

After:

Loading problem fredrikspizzeria
Checking config
Checking statement
Checking validators
...

log.warning('Failed to convert %s image "%s to %s', oldext, name, newext)
result = subprocess.run(cmd, stdout=subprocess.DEVNULL, stderr=subprocess.PIPE)
if result.returncode:
log.error(f'Failed to convert {oldext} image {name} to {newext}.\n{result.stderr.decode(errors="replace")}')
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When logging, you want to keep printf-formatting instead of using an f-string if the data is not strictly controlled.

This will crash if any of the strings contain something looking like a printf specifier (e.g., if the error message from ghostscript happens to conrtain %s).

@gkreitz
Copy link
Copy Markdown
Contributor

gkreitz commented Apr 13, 2026

I've fixed CI now, so please also rebase to get a nice green checkmark. :)

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

Successfully merging this pull request may close these issues.

Don't print ghostscript output when running verifyproblem

2 participants