Problem
Say I want to run a request that returns some data, e.g CUPS_Get_Document:
response = ipp.execute(
IppOperation.CUPS_GET_DOCUMENT,
{
"operation-attributes-tag": {
"job-id": 1,
"document-number": 1,
"requesting-user-name": "root",
}
}
)
The response gets parsed but has on "data" field, even if it's been recieved. This is because the ipp.parser.parse function inside ipp.execute gets called without the contains_data parameter.
|
try: |
|
parsed = parse_response(response) |
|
except (structerror, Exception) as exc: # disable=broad-except |
|
raise IPPParseError from exc |
|
def parse( # noqa: PLR0912, PLR0915 |
|
raw_data: bytes, |
|
contains_data: bool = False, # noqa: FBT001, FBT002 |
|
) -> dict[str, Any]: |
Current alternative approach
The only way around this is to manually parse the request, like this
from pyipp.parser import parse as parse_response
response = await ipp.raw(
IppOperation.CUPS_GET_DOCUMENT,
{
"operation-attributes-tag": {
"job-id": 1,
"document-number": 1,
"requesting-user-name": "root",
}
},
)
response = parse_response(response, contains_data=True)
Which works, but is harder than it needs to be
Proposal
How about exposing the contains_data parameter on ipp.execute? This way we can do something like
response = await ipp.execute(
IppOperation.CUPS_GET_DOCUMENT,
{
"operation-attributes-tag": {
"job-id": 1,
"document-number": 1,
"requesting-user-name": "root",
}
},
contains_data=True,
)
To get the parsed data back
Problem
Say I want to run a request that returns some data, e.g
CUPS_Get_Document:The
responsegets parsed but has on "data" field, even if it's been recieved. This is because theipp.parser.parsefunction insideipp.executegets called without thecontains_dataparameter.python-ipp/src/pyipp/ipp.py
Lines 195 to 198 in 3b560f2
python-ipp/src/pyipp/parser.py
Lines 212 to 215 in 3b560f2
Current alternative approach
The only way around this is to manually parse the request, like this
Which works, but is harder than it needs to be
Proposal
How about exposing the
contains_dataparameter onipp.execute? This way we can do something likeTo get the parsed data back