Skip to content

Commit

Permalink
[docs] get_attr and set_attr have been deprecated
Browse files Browse the repository at this point in the history
  • Loading branch information
delfick committed Mar 28, 2021
1 parent 11ab6c7 commit c8ca81d
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 16 deletions.
1 change: 1 addition & 0 deletions docs/start/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ ChangeLog
of a ``AnimationTask`` in the same module and the new task register.
* Shuffled the ``photons_app`` module a little. It is unlikely any of the
changed imports will impact users of Photons.
* deprecated ``get_attr`` and ``set_attr`` tasks. Please use ``attr`` instead.

.. _release-core-0-33-0:

Expand Down
4 changes: 2 additions & 2 deletions docs/start/commandline/references.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ uses that to target packets for each device.

For example, get the current color of the device with serial ``d073d5001337``::

$ lifx lan:get_attr d073d5001337 color
$ lifx lan:attr d073d5001337 GetColor

Set the power of these two devices::

$ lifx lan:set_attr d073d5000001,d073d500adb8 power -- '{"level": 65535}'
$ lifx lan:attr d073d5000001,d073d500adb8 SetPower -- '{"level": 65535}'

Photons provides some special references including ``_`` which is a shortcut
for all discovered devices on the network and the
Expand Down
6 changes: 3 additions & 3 deletions docs/start/configuration/discovery_options.rst
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,13 @@ will only discover a single device with the serial of ``d073d5111111`` if it
has the IP address of ``192.168.0.1``::

$ export HARDCODED_DISCOVERY='{"d073d5111111": "192.168.0.1"}'
$ lifx lan:get_attr _ color
$ lifx lan:attr _ GetColor

The ``SERIAL_FILTER`` environment variable sets or overrides any ``serial_filter``
configuration setting::

$ export SERIAL_FILTER=d073d500001,d073d5111111
$ lifx lan:get_attr _ color
$ lifx lan:attr _ GetColor

Photons will do a broadcast discovery, but only for devices with the serial of
``d073d5000001`` and ``d073d5111111``.
Expand All @@ -73,7 +73,7 @@ variable set to null::

$ export HARDCODED_DISCOVERY=null
$ export SERIAL_FILTER=null
$ lifx lan get_attr _ color
$ lifx lan attr _ GetColor

.. _target_options:

Expand Down
8 changes: 3 additions & 5 deletions modules/photons_control/attributes.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@ class attr(task.Task):
"""
Send a message to your bulb and print out all the replies.
This is the same as the get_attr and set_attr commands but doesn't prefix the wanted message with get or set
``target:attr d073d5000000 get_host_firmware``
``target:attr d073d5000000 GetHostFirmware``
"""

target = task.requires_target()
Expand All @@ -46,7 +44,7 @@ async def execute_task(self, **kwargs):

if self.artifact is sb.NotSpecified:
raise BadOption(
f"Please specify what you want to get\nUsage: {sys.argv[0]} <target>:get_attr <reference> <attr_to_get>"
f"Please specify what you want to get\nUsage: {sys.argv[0]} <target>:attr <reference> <attr_to_get>"
)

kls = find_packet(protocol_register, self.artifact, "")
Expand Down Expand Up @@ -80,7 +78,7 @@ async def execute_task(self, **kwargs):

if self.artifact is sb.NotSpecified:
raise BadOption(
f"Please specify what you want to get\nUsage: {sys.argv[0]} <target>:get_attr <reference> <attr_to_get>"
f"Please specify what you want to get\nUsage: {sys.argv[0]} <target>:attr_actual <reference> <attr_to_get>"
)

kls = find_packet(protocol_register, self.artifact, "")
Expand Down
4 changes: 2 additions & 2 deletions modules/photons_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ class CommandSplitter(MergedOptionStringFormatter):
.. code-block:: python
command = "{TARGET|lan:env}:{@:1} {@:2:}"
result = CommandSplitter({"argv": ["my_script", "get_attr", "--silent"]}, command).split()
assert result == ["lan:get_attr", "--silent"]
result = CommandSplitter({"argv": ["my_script", "attr", "--silent"]}, command).split()
assert result == ["lan:attr", "--silent"]
Note that if when running that there was a ``TARGET`` variable in your
environment then it would use that instead of the default ``lan`` specified.
Expand Down
8 changes: 4 additions & 4 deletions modules/tests/photons_core_tests/test_main_lines.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,24 +158,24 @@ class V:
it "run formats correctly", fake_main:
with pytest.helpers.modified_env(LAN_TARGET="well"):
run(
"{LAN_TARGET:env}:get_attr {@:1} {@:2:}",
"{LAN_TARGET:env}:attr {@:1} {@:2:}",
argv=["match:cap=chain", "--silent", "--", '{"one": "two"}'],
)

fake_main.assert_called_once_with(
["well:get_attr", "match:cap=chain", "--silent", "--", '{"one": "two"}'],
["well:attr", "match:cap=chain", "--silent", "--", '{"one": "two"}'],
default_activate=["core"],
)

it "can have defaults for environment", fake_main:
with pytest.helpers.modified_env(LAN_TARGET=None):
run(
"{LAN_TARGET|lan:env}:get_attr {@:1} {@:2:}",
"{LAN_TARGET|lan:env}:attr {@:1} {@:2:}",
argv=["match:cap=chain", "--silent", "--", '{"one": "two"}'],
)

fake_main.assert_called_once_with(
["lan:get_attr", "match:cap=chain", "--silent", "--", '{"one": "two"}'],
["lan:attr", "match:cap=chain", "--silent", "--", '{"one": "two"}'],
default_activate=["core"],
)

Expand Down

0 comments on commit c8ca81d

Please sign in to comment.