zowe / zowe-client-python-sdk

Eclipse Public License 2.0
39 stars 25 forks source link

[zos-tso] issue_command should loop and concatenate multiple responses #260

Closed t1m0thyj closed 3 months ago

t1m0thyj commented 5 months ago

Describe the bug

The Python SDK is lacking the smarts to continue issuing GET requests to obtain more TSO input until the command completes, which is present in the Node SDK used by Zowe CLI.

To Reproduce

Issue a TSO command with a lot of output (>100 lines) with the issue_command method of the TSO SDK and notice that the response is truncated.

Expected behavior

All output from the TSO command should be returned to match the behavior of zowe zos-tso issue command.

Describe your environment

macOS 14.4.1, Python 3.9.6

Additional context

Until the Python SDK officially supports it, here is a workaround to collect all TSO output:

my_tso = Tso(zosmf_profile, tso_profile)
tso_session = my_tso.start_tso_session()
response_json = my_tso.send_tso_message(tso_session, cmd)
response_lines = my_tso.retrieve_tso_messages(response_json)
while not any("TSO PROMPT" in message for message in response_json) or not response_lines:
    custom_args = my_tso._create_custom_request_arguments()
    custom_args["url"] = "{}/{}".format(my_tso.request_endpoint, tso_session)
    response_json = my_tso.request_handler.perform_request("GET", custom_args)["tsoData"]
    response_lines += my_tso.retrieve_tso_messages(response_json)
my_tso.end_tso_session(tso_session)
print("\n".join(response_lines))
github-actions[bot] commented 5 months ago

Thank you for creating a bug report. We will investigate the bug and evaluate its impact on the product. If you haven't already, please ensure you have provided steps to reproduce the bug and as much context as possible.