Skip to content
This repository has been archived by the owner on Jan 5, 2024. It is now read-only.

Handle subprocess stderr output in Python 3.9, treat lpadmin warnings as non-fatal #97

Merged
merged 1 commit into from
Jul 2, 2022

Conversation

eaon
Copy link
Contributor

@eaon eaon commented Jul 1, 2022

As opposed to how it worked in Python 3.7, subprocess.check_call does not raise an exception anymore if there's output on stderr even when the returncode is 0. So we move on to the newer subprocess API that allows us to capture stderr and analyze it even if the returncode is 0.

This is necessary so we can safely ignore lpadmin warnings that would otherwise stop the printing process. This means that at least for now, we'll continue to use Debian supplied printer drivers with CUPS. However a change like #94 ought to be considered/tested in the future for the obvious benefit of not having to deal with printer drivers and easily supporting new printers.

Fixes #93

Towards freedomofpress/securedrop-workstation#600

Testing

To save on time, this PR may be reviewed at the same as #96.

  • make test passes (test-buster CI is currently broken, may be safely ignored)
  • Attempting to print without a printer asks for it to be connected
  • Printing images, .txt files and .docx files with a supported printer connected is successful
  • Export functionality behaves as expected

subprocess.check_call does not raise an exception anymore if there's
just output on stderr - hence, we move on to its newer API that allows
us to capture stderr and analyze it even if the returncode is 0.

It also safely ignores lpadmin driver warnings to allow us to continue
to use printer drivers with CUPS.
Copy link
Contributor

@sssoleileraaa sssoleileraaa left a comment

Choose a reason for hiding this comment

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

lgtm

I tested this along side #96

@eloquence - feel free to merge whenever you get a chance.

@eloquence eloquence merged commit 9bcd76a into main Jul 2, 2022
@sssoleileraaa sssoleileraaa deleted the 93-handle-stderr-output branch July 4, 2022 18:42
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

lpadmin: Printer drivers are deprecated and will stop working in a future version of CUPS
3 participants