Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve issue with libcoap API #75

Merged
merged 2 commits into from
Oct 26, 2017
Merged

Conversation

ggravlingen
Copy link
Member

This is a solution proposed by @rudyvan

@ggravlingen
Copy link
Member Author

@lwis can the error thrown by Travis be accepted?

It's the except: pass lines (from device.py) that fail and some Google-fu tells me it's advised to not use this syntax?

    def set_predefined_color(self, colorname, *, index=0):
        try:
            color = COLORS[colorname.lower().replace(" ", "_")]
        except:
            pass
        else:
            return self.set_hex_color(color, index=index)

@lwis
Copy link
Collaborator

lwis commented Oct 25, 2017

Hmm, that needs fixing. We must be expecting some builtin exception to be thrown there. Catch all isn't good practice. Wonder why this has only just started failing.

@ggravlingen
Copy link
Member Author

@lwis my thoughts too as Travis passed this in the previous PR. Suggestion: let this through (as it's already a part of master branch) and raise a bug to fix it?

@ggravlingen
Copy link
Member Author

ggravlingen commented Oct 25, 2017

Getting this error when implementing the suggested fix. Putting it here for documentation and am currently looking into it.

DEBUG:pytradfri.api.libcoap_api:Executing 192.168.0.129 get ['status']
DEBUG:pytradfri.api.libcoap_api:Received: {}
DEBUG:pytradfri.api.libcoap_api:Executing 192.168.0.129 get ['15001']
DEBUG:pytradfri.api.libcoap_api:Received: [65541,65538,65536,65537,65540,65539,65542]
Traceback (most recent call last):
  File "/usr/lib/python3.5/runpy.py", line 184, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/lib/python3.5/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/home/patrik/Documents/pytradfri/pytradfri/__main__.py", line 22, in <module>
    devices = api(*devices_commands)
TypeError: request() takes 1 positional argument but 7 were given

Maybe this was the reason the current code in master uses indexing?

@rudyvan
Copy link
Contributor

rudyvan commented Oct 25, 2017

You just have to remove the asterix and then it worked, apologies i should have mentioned it.
devices=api(devices_commands)
Sorry, traveling now and cannot help further.

@ggravlingen ggravlingen merged commit 964df55 into master Oct 26, 2017
@ggravlingen ggravlingen deleted the resolveissuewithlibcoapAPI branch October 26, 2017 17:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants