Skip to content

Printing does not respond #664

Description

@aihuahua-522

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''}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions