1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
|
# pylint: disable=W0621
"""Asynchronous Python client for IPP."""
import asyncio
from pyipp import IPP
from pyipp.enums import IppOperation
async def main() -> None:
"""Show example of connecting to your IPP print server."""
async with IPP("ipps://192.168.1.92:631/ipp/print") as ipp:
response = await ipp.raw(
IppOperation.GET_PRINTER_ATTRIBUTES,
{
"version": (2, 0), # try (1, 1) for older devices
"operation-attributes-tag": {
"requested-attributes": [
"printer-device-id",
"printer-name",
"printer-type",
"printer-location",
"printer-info",
"printer-make-and-model",
"printer-state",
"printer-state-message",
"printer-state-reasons",
"printer-supply",
"printer-up-time",
"printer-uri-supported",
"device-uri",
"printer-is-shared",
"printer-more-info",
"printer-firmware-string-version",
"marker-colors",
"marker-high-levels",
"marker-levels",
"marker-low-levels",
"marker-names",
"marker-types",
],
},
},
)
with open("printer-attributes.bin", "wb") as file: # noqa: PTH123, ASYNC230
file.write(response)
file.close()
if __name__ == "__main__":
loop = asyncio.get_event_loop()
loop.run_until_complete(main())
|