AttributeError: type object 'AlarmDecoder' has no attribute

Contribute source code here. Anything not accompanied by source code will be removed.

AttributeError: type object 'AlarmDecoder' has no attribute

Postby skr25 » Sat Nov 04, 2017 9:35 pm

Hi,
I have issue in sending keys using REST API using swagger help file. I tried t use curl command as below
curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' -d '{"keys":"76781"}' 'http://192.168.1.159:5000/api/v1/alarmdecoder/send?apikey=EXAMPLEA'
Webapp is working ok so far.
It gave me below error

Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1997, in __call__
return self.wsgi_app(environ, start_response)
File "/opt/alarmdecoder-webapp/ad2web/app.py", line 128, in __call__
return self.app(environ, start_response)
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1985, in wsgi_app
response = self.handle_exception(e)
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1540, in handle_exception
reraise(exc_type, exc_value, tb)
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1982, in wsgi_app
response = self.full_dispatch_request()
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1614, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1517, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1612, in full_dispatch_request
rv = self.dispatch_request()
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1598, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/opt/alarmdecoder-webapp/ad2web/decorators.py", line 53, in wrapped_function
resp = make_response(f(*args, **kwargs))
File "/opt/alarmdecoder-webapp/ad2web/api/views.py", line 135, in wrapped
return f(*args, **kwargs)
File "/opt/alarmdecoder-webapp/ad2web/api/views.py", line 213, in alarmdecoder_send
keys = keys.replace("<S1>", AlarmDecoder.KEY_S1 )
AttributeError: type object 'AlarmDecoder' has no attribute 'KEY_S1'

Webapp version is v0.8.0 and firmware is latest stable firmware. Any help will be appreciated.
Regards
Skr25
skr25
newt
newt
 
Posts: 2
Joined: Sat Nov 04, 2017 9:22 pm

Re: AttributeError: type object 'AlarmDecoder' has no attrib

Postby kevin » Sat Nov 04, 2017 9:40 pm

Strange, make sure you've got the latest version of the AlarmDecoder library itself installed. Those constants are defined there.

Code: Select all
    # Constants
    KEY_F1 = chr(1) + chr(1) + chr(1)
    """Represents panel function key #1"""
    KEY_F2 = chr(2) + chr(2) + chr(2)
    """Represents panel function key #2"""
    KEY_F3 = chr(3) + chr(3) + chr(3)
    """Represents panel function key #3"""
    KEY_F4 = chr(4) + chr(4) + chr(4)
    """Represents panel function key #4"""
    KEY_PANIC = chr(2) + chr(2) + chr(2)
    """Represents a panic keypress"""
    KEY_S1 = chr(1) + chr(1) + chr(1)
    """Represents panel special key #1"""
    KEY_S2 = chr(2) + chr(2) + chr(2)
    """Represents panel special key #2"""
    KEY_S3 = chr(3) + chr(3) + chr(3)
    """Represents panel special key #3"""
    KEY_S4 = chr(4) + chr(4) + chr(4)
    """Represents panel special key #4"""
    KEY_S5 = chr(5) + chr(5) + chr(5)
    """Represents panel special key #5"""
    KEY_S6 = chr(6) + chr(6) + chr(6)
    """Represents panel special key #6"""
    KEY_S7 = chr(7) + chr(7) + chr(7)
    """Represents panel special key #7"""
    KEY_S8 = chr(8) + chr(8) + chr(8)
"""Represents panel special key #8"""


in decoder.py of the AlarmDecoder base library
Not an employee of the company. Just here to help and keep things clean.
kevin
Platinum Nut
Platinum Nut
 
Posts: 994
Joined: Fri Aug 16, 2013 10:10 am

Re: AttributeError: type object 'AlarmDecoder' has no attrib

Postby skr25 » Sun Nov 05, 2017 9:36 am

Thanks Kevin for pointing me in right direction. I am able to resolve this issue.
I had old alarmcoder python library. I tried to use pip install alarmdecoder/pip install alarmdecoder --upgrade but it was installing old library everytime. Thereafter, I cloned GIT and installed using python setup.py install . This refreshed the library with latest version.
It is working perfectly now!!. Thanks again for your help!.

Regards
Skr25
skr25
newt
newt
 
Posts: 2
Joined: Sat Nov 04, 2017 9:22 pm


Return to Code Contributions

Who is online

Users browsing this forum: No registered users and 6 guests

cron