Skip to content

Commit

Permalink
Improvement required by issue #102. Error message and docstring conta…
Browse files Browse the repository at this point in the history
…ins more details and removed unnecessary line of code
  • Loading branch information
ChristianTremblay committed Dec 2, 2020
1 parent a46ff0c commit db6406b
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions pyhaystack/client/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,9 +239,8 @@ def point_write(
the writeable point entity to retrieve the write status of or write a
value to.
If level is None, the other parameters are required to be None too, the
write status of the point is retrieved. Otherwise, a write is
performed to the nominated point.
To retrieve the write status of the point, value, duration and level are required to be None.
To write to a point, value and level are required and duration is optional.
"""
who = who or self._username
return self._on_point_write(
Expand Down Expand Up @@ -523,10 +522,9 @@ def _on_watch_poll(self, watch, refresh, callback, **kwargs):
def _on_point_write(self, point, level, val, who, duration, callback, **kwargs):
args = {"id": self._obj_to_ref(point)}
if level is None:
who = None # as it may be username
if (val is not None) or (duration is not None):
raise ValueError(
"If level is None, val, who and duration must " "be None too."
"You tried writing a value without specifying a level (or specified a duration without providing a level neither a value. Please provide required level. If trying to retrieve write status of the point, provide None as value, duration and level"
)
else:
args.update({"level": level, "val": val})
Expand Down

0 comments on commit db6406b

Please sign in to comment.