-
Notifications
You must be signed in to change notification settings - Fork 31
Open
Description
my code:
# 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 printing via IPP print server using multi-step workflow."""
pdf_file = "test.png"
with open(pdf_file, "rb") as f: # noqa: PTH123, ASYNC230
content = f.read()
async with IPP("ipps://192.168.1.92:631/ipp/print") as ipp:
# Step 1: Create an empty print job
create_response = await ipp.execute(
IppOperation.CREATE_JOB,
{
"operation-attributes-tag": {
"requesting-user-name": "Me",
"job-name": "My Test Job",
},
},
)
print("Create Job Response:", create_response)
# Extract job ID from the response
job_id = create_response['jobs'][0]['job-id']
print(f"Created job with ID: {job_id}")
# Step 2: Send document data to the created job
send_response = await ipp.execute(
IppOperation.SEND_DOCUMENT,
{
"operation-attributes-tag": {
"requesting-user-name": "Me",
"job-id": job_id,
"document-format": "image/jpeg",
"last-document": True, # Indicates this is the final document
},
"data": content,
},
)
print("Send Document Response:", send_response)
if __name__ == "__main__":
loop = asyncio.get_event_loop()
loop.run_until_complete(main())my console:
Create Job Response: {'version': (2, 0), 'status-code': 0, 'request-id': 24470, 'operation-attributes': {'attributes-charset': 'utf-8', 'attributes-natural-language': 'en'}, 'unsupported-attributes': [], 'jobs': [{'job-uri': 'ipp://192.168.1.92/ipp/print/job-0008', 'job-id': 8, 'job-state': <IppJobState.PENDING: 3>, 'job-state-reasons': 'job-data-insufficient', 'job-state-message': ''}], 'printers': [], 'data': b''}
Created job with ID: 8
Send Document Response: {'version': (2, 0), 'status-code': 0, 'request-id': 65154, 'operation-attributes': {'attributes-charset': 'utf-8', 'attributes-natural-language': 'en'}, 'unsupported-attributes': [], 'jobs': [{'job-uri': 'ipp://192.168.1.92/ipp/print/job-0008', 'job-id': 8, 'job-state': <IppJobState.PROCESSING: 5>, 'job-state-reasons': 'none', 'job-state-message': ''}], 'printers': [], 'data': b''}
But the printer is completely unresponsive
get jobs result:
{'version': (2, 0), 'status-code': 0, 'request-id': 38639, 'operation-attributes': {'attributes-charset': 'utf-8', 'attributes-natural-language': 'en'}, 'unsupported-attributes': [], 'jobs': [], 'printers': [], 'data': b''}
Metadata
Metadata
Assignees
Labels
No labels