0

I want to send a command through the CLI to a PTC Integrity Server and capture the response in a string using python.

I'm using following code:

import subprocess
result = subprocess.Popen("My Command", stdout=subprocess.PIPE, stderr=subprocess.PIPE)
while result.poll() is None:
    time.sleep(1) ## this is only executed once
output, error = result.communicate(timeout=30)
print(output)

for simple commands like "echo foo" it is working like a charm, even simply polling info from PTC works fine, but creating an item:

im createissue --hostname=MyHost --port=MyPort --field="Summary=MySummary"

leads to an empty output:

b''

I see that the command is executed properly and the item is created but I cannot grab the response

If I do follwing:

result = subprocess.Popen("My Command")
'''
while result.poll() is None:
    time.sleep(1)
output, error = result.communicate(timeout=30)
'''
print(result)

I get the response:

<Popen: returncode: None args: 'im createissue --hostname=MyHost ...>

but still see in my pycharm console the output I would expect.

I think the response is taking to long and python does not wait until the response is available. Any clue on how to solve this?

Benjamin
  • 1
  • 1

1 Answers1

0

Solved it myself, the RV&S/ integrity delivers the response in the >>Error<< object

Benjamin
  • 1
  • 1