-
Notifications
You must be signed in to change notification settings - Fork 16
Conversation
Adds media controls. Improves error control for send_key commands
hisensetv/__init__.py
Outdated
try: | ||
self._call_service(service="remote_service", action="sendkey", payload=keyname) | ||
result = True | ||
except json.JSONDecodeError: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am a little confused by this, what is raising the JSONDecodeError
? Is this something that can be fixed elsewhere?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, well. I have absolutely no idea where that came from... lol.
That line should just be "except:"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What exception is getting raised there? It would be better to scope it down a little, a bare except
will catch system level events like KeyboardInterrupt
and SystemExit
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd have to defer to you here, as my best practices knowledge on exception handling is limited.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally I try to propagate exceptions as much as possible to the user - unless the exceptions are errors due to the internal code rather than a device malfunction or user error.
If this is an internal code error it would be helpful to know what causes it so that we could perhaps change the internal workings to function better, and limit the scope to capture just the exception(s) that are problematic. Are there any specific exceptions that you have had? Do you have the traceback for them?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, I experienced no exceptions in my development. My thought process was to always return a bool value, based on success of send_key command. Any exception failure would be captured and appropriate return value sent.
Correction to exception response.
I committed some changed to your branch - I narrowed the scope of the exception catching for JSON to just the I would prefer that Let me know what you think! Sorry for the slow replies, the coronavirus has made my life a little crazy recently. |
No reason to apologize, if your community is not at or near chaos right now, you must be living in space. I can totally agree understand that _send_key may should remain as is. After looking at again, I agree the exceptions are better if propagated up. |
Nothing is every truly private in python so someone could just overwrite the private class MyTv(HisenseTv):
def _send_key(self, keyname: str):
self._call_service(service="remote_service", action="new_sendkey_action", payload=keyname) |
updates send_key to public
Added 'ok' to list of commands
adds ok,media control commands to usage
renames ff & rew
correction to usage for controls
Yes, I feel it should be public. Also updated README for new media control commands. How do you like the nomenclature: "fast_forward" , "rewind", "volume_up" ? |
Looks good to me! Should I merge now? |
Yes, please. Stay safe
…
On Apr 5, 2020 at 11:06 AM, Alex ***@***.***> wrote:
Looks good to me! Should I merge now?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
Can you please update PyPi so I can download version 0.0.7 |
Adds media controls. Improves error control for send_key commands