OpenPrinting / system-config-printer

Graphical user interface for CUPS administration
GNU General Public License v2.0
156 stars 87 forks source link

remove python3-requests #247

Closed slingamn closed 2 years ago

slingamn commented 2 years ago

At this stage, this is mostly just a request for comments. I'm trying to remove python3-requests as a dependency of the Ubuntu base system. This project has been mostly successful for the server edition, since these patches made it possible to run Ubuntu 21.04 and later without python3-requests:

For 22.04 I'd like to remove it as a dependency of the desktop system as well. I think system-config-printer is the only "core" package that still depends on it, so here's a draft of a patch that removes the dependency.

I wasn't sure how best to test these changes. The API at https://openprinting.org/query.cgi seems to be down or misconfigured right now?

Thanks very much for your time.

tillkamppeter commented 2 years ago

@slingamn please use

https://openprinting.org/query.php

instead of

https://openprinting.org/query.cgi

but the same API. This is still working as expected.

Example:

https://openprinting.org/query.php?type=printer&make=HP

This shows all HP printers.

slingamn commented 2 years ago

Thanks, with this change to the query URI (not included in the branch) I was able to test the two changed components (cupshelpers.openprinting.OpenPrinting and newprinter.download_gpg_fingerprint) in isolation. I'm pretty sure they're correct.

Leaving this as two commits for now, I'll clean up the history later.

slingamn commented 2 years ago

Can I provide any more testing or information on this change? Thanks for your help.

zdohnal commented 2 years ago

@slingamn hmm, it seems github didn't show a comment until I click 'start a review'. I wrote the comment on the code two weeks ago...

slingamn commented 2 years ago

One thing that came up in my testing: 15 seconds seems like it might be too short a timeout for this API? I'd welcome any suggestions on this issue.

zdohnal commented 2 years ago

@slingamn I've answered in the comment - I would let the current timeout and enhanced the exception handling so we could be easily found out if it timed out and raise the timeout in the future.

slingamn commented 2 years ago

That makes sense. Is debugprint the correct error reporting mechanism to use?

zdohnal commented 2 years ago

@slingamn yep, IMO debugprint() function is our most viable option.

The code looks fine, would you mind providing steps how to check if it works?

slingamn commented 2 years ago

Here's a snippet that tests the openprinting API query:

import time
import cupshelpers.openprinting
print(cupshelpers.openprinting.__file__)
def callback(a, b, c):
    print("callback returned", a, b, c)
o = cupshelpers.openprinting.OpenPrinting()

result = o.webQuery(parameters={'type': 'printer', 'make': 'HP'}, callback=callback)
# sleep to allow async callback to complete
time.sleep(100)

For the GPG fingerprint code:

from newprinter import download_gpg_fingerprint

print(download_gpg_fingerprint('https://intouch.ebz.epson.net/key/fingerprint'))
zdohnal commented 2 years ago

Test results:

>>> result = o.webQuery(parameters={'type': 'printer', 'make': 'HP'}, callback=callback)
>>> timecallback returned 0 None b'HP-2000C|HP|2000C\nHP-2500C|HP|2500C\nHP-2500CM|HP|2500CM\nHP-2563|HP|2563\nHP-910|HP|910\nHP-915|HP|915\nHP-Business_Inkjet_1000|HP|Business Inkjet 1000\n ...
>>> from newprinter import download_gpg_fingerprint
Unable to init server: Could not connect: Connection refused
Unable to init server: Could not connect: Connection refused
>>> print(download_gpg_fingerprint('https://intouch.ebz.epson.net/key/fingerprint'))
XXXXXXXXXXXX <- real fingerprint here

LGTM ('connection refused' messages are there because I tested it on server machine and X11 server wasn't running), merging.

zdohnal commented 2 years ago

Thank you for the PR!

tillkamppeter commented 2 years ago

@zdohnal could you spin a release of system-config-printer in time before Feature Freeze of Ubuntu 22.04 LTS on Feb 24? The Removal of the dependency on python3-requests as this is the last dependency on python3-requests in Ubuntu 22.04 which allows dropping the package from the distro.

Thanks in advance.

zdohnal commented 2 years ago

Hi Till,

I hope I'll manage that - I'm currently deep in security vulnerabilities in other packages I maintain, so once that is solved and no more new come, I should be able to release s-c-p.

tillkamppeter commented 2 years ago

I have done the 1.5.16 release now, simply from today's GIT state of the art. A year of bug fixes and translations for Ubuntu 22.04 LTS.