Last active
April 2, 2020 18:02
-
-
Save ctalkington/a1c1134a47ccbf256564179c5855c005 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# pylint: disable=W0621 | |
"""Asynchronous Python client for IPP.""" | |
import asyncio | |
from pyipp import IPP | |
async def main(): | |
"""Show example of connecting to your IPP print server.""" | |
async with IPP("ipp://HP79EC40.local:631/ipp/printer") as ipp: | |
"""Get printer information from server.""" | |
response_data = await ipp.execute( | |
0x000B, | |
{ | |
"operation-attributes-tag": { | |
"requested-attributes": [ | |
"printer-name", | |
"printer-type", | |
"printer-location", | |
"printer-info", | |
"printer-make-and-model", | |
"printer-state", | |
"printer-state-message", | |
"printer-state-reason", | |
"printer-uri-supported", | |
"device-uri", | |
"printer-is-shared", | |
], | |
}, | |
}, | |
) | |
data: dict = next(iter(response_data["printers"] or []), {}) | |
print(data) | |
if __name__ == "__main__": | |
loop = asyncio.get_event_loop() | |
loop.run_until_complete(main()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment