You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Traceback (most recent call last):
File "/Users/kim/pyinfra-try/api2.py", line 43, in <module>
host = state.hosts.inventory['@local']
^^^^^^^^^^^
AttributeError: 'State' object has no attribute 'hosts'
The reference to state.host does not seem to be documented in pyinfra.api.state.
Also, the code comments indicate that stdout and stderr should be present in the result of an add_op. However, the return values do not contain these fields. In the example result1 contains:
I searched the examples repo but was unable to find the output of an API operation being accessed at runtime. So, it is not immediately clear how this example should be fixed.
The interface to OperationMeta and state have changed with v3. The following changes should be made to the example.
# add_op returns an OperationMeta for each op, letting you access stdout, stderr, etc. after they run
host = state.inventory.hosts['@local']
print(result1[host].did_change(), result1[host].stdout, result1[host].stderr)
print(result2[host].did_change(), result2[host].stdout, result2[host].stderr)
# We can also get facts for all the hosts
# https://docs.pyinfra.com/en/3.x/apidoc/pyinfra.api.facts.html
print(get_facts(state, Os))
Describe the bug
The API Reference -> Basic Localhost Example fails.
The reference to state.host does not seem to be documented in pyinfra.api.state.
Also, the code comments indicate that stdout and stderr should be present in the result of an add_op. However, the return values do not contain these fields. In the example result1 contains:
I searched the examples repo but was unable to find the output of an API operation being accessed at runtime. So, it is not immediately clear how this example should be fixed.
To Reproduce
Execute Basic Localhost Example. I changed inventory to get the example to run.
Expected behavior
I expected the basic API example to work and I expected stdout to be available in the returned value.
There are two issues here:
The text was updated successfully, but these errors were encountered: