Fix for readme FSAPI example
gruberth opened this issue · comments
Thomas Gruber commented
The FSAPI example in the readme should be:
from fsapi.net import FSDevice, wrap, nodes
# First, create the radio object
device = FSDevice("127.0.0.1")
# Create a new session id (only one at a time)
device.new_session()
# In order to simplify the usage of the FSDevice class
api = wrap(device)
friendly_name = api.friendly_name
# or manually
response = device.get(nodes / "netRemote.sys.info.friendlyName")
if response.success:
#_ Again, type(content) = nodes.BaseSysInfoFriendlyName
friendly_name = response.node.value
# Apply a new name via wrapper
api.friendly_name = "FooBar"
# or manually
device.put(nodes / "netRemote.sys.info.friendlyName", value="FooBar")
# get all elements of a list
valid_modes = api.ls_valid_modes()
# get a certain amount of elements beginning at index 3
valid_modes = api.ls_valid_modes(_pos=3, max_items=10)
instead of:
...
# or manually
response = device.get(nodes / "netRemote.sys.info.friendlyName")
if response.status == FS_OK:
#_ Again, type(content) = nodes.BaseSysInfoFriendlyName
friendly_name = response.content.value
# Apply a new name via wrapper
api.friendly_name = "FooBar"
# or manually
device.put(nodes / "netRemote.sys.info.friendlyName", value="FooBar")
...
Thomas Gruber commented
First of all thanks for the quick fixes.
But I am verry sorry, there is still an error which you probably missed:
AttributeError: 'FSResponse' object has no attribute 'content'
.
The line
friendly_name = response.content.value
should be
friendly_name = response.node.value
Greets
MatrixEditor commented
You're right, I must've overlooked that. Thank you!