i tru to flow the floranet setup,when i want to create an application it gives me a huge error in the terminal[python 2.7//ubuntu]
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
import click from floranet.util import euiString, devaddrString, intHexString, hexStringInt from floranet.commands import version, restRequest @click .group() def app(): pass @app .command() @click .pass_context @click .argument( 'appeui' , nargs = 1 ) def show(ctx, appeui): """show an application, or all applications. Args: ctx (Context): Click context appeui (str): Application EUI """ if '.' in appeui: appeui = str (hexStringInt( str (appeui))) # Form the url and payload server = ctx.obj[ 'server' ] payload = { 'token' : ctx.obj[ 'token' ]} url + = '/apps' if appeui = = 'all' else '/app/{}' . format (appeui) # Make the request data = restRequest(server, url, 'get' , payload, 200 ) if data is None : return # Single application if appeui ! = 'all' : a = data indent = ' ' * 10 if a[ 'appinterface_id' ] = = 0 : a[ 'appinterface_id' ] = '-' if a[ 'domain' ] is None : a[ 'domain' ] = '-' click.echo( 'Application EUI: ' + euiString(a[ 'appeui' ])) click.echo( '{}name: {}' . format (indent, a[ 'name' ])) click.echo( '{}domain: {}' . format (indent, a[ 'domain' ])) click.echo( '{}fport: {}' . format (indent, a[ 'fport' ])) click.echo( '{}interface {}' . format (indent, a[ 'appinterface_id' ])) if a[ 'appinterface_id' ] ! = '-' : click.echo( '{}Properties:' . format (indent)) properties = sorted (a[ 'properties' ].values(), key = lambda k: k[ 'port' ]) for p in properties: click.echo( '{} {} {}:{}' . format (indent, p[ 'port' ], p[ 'name' ], p[ 'type' ])) return # All applications click.echo( '{:14}' . format ( 'Application' ) + \ '{:24}' . format ( 'AppEUI' ) + \ '{:15}' . format ( 'Domain' ) + \ '{:6}' . format ( 'Fport' ) + \ '{:10}' . format ( 'Interface' )) for i,a in data.iteritems(): if a[ 'appinterface_id' ] = = 0 : a[ 'appinterface_id' ] = '-' if a[ 'domain' ] is None : a[ 'domain' ] = '-' click.echo( '{:13.13}' . format (a[ 'name' ]) + ' ' + \ '{:23}' . format (euiString(a[ 'appeui' ])) + ' ' + \ '{:14.14}' . format (a[ 'domain' ]) + ' ' + \ '{:5.5}' . format ( str (a[ 'fport' ])) + ' ' + \ '{:10}' . format ( str (a[ 'appinterface_id' ]))) @app .command(context_settings = dict ( ignore_unknown_options = True , allow_extra_args = True )) @click .argument( 'appeui' ) @click .pass_context def add(ctx, appeui): """add an application. Args: ctx (Context): Click context appeui (str): Application EUI string """ if '.' in appeui: appeui = str (hexStringInt( str (appeui))) # Translate kwargs to dict args = dict (item.split( '=' , 1 ) for item in ctx.args) # Check for required args required = [ 'name' , 'appnonce' , 'appkey' , 'fport' ] missing = [item for item in required if item not in args.keys()] if missing: if len (missing) = = 1 : click.echo( "Missing argument " + missing[ 0 ]) else : click.echo( "Missing arguments: " + ' ' .join(missing)) return args[ 'appnonce' ] = int ( '0x' + str (args[ 'appnonce' ]), 16 ) args[ 'appkey' ] = hexStringInt( str (args[ 'appkey' ])) # Create the payload server = ctx.obj[ 'server' ] payload = { 'token' : ctx.obj[ 'token' ], 'appeui' : appeui} payload.update(args) # Perform a POST on /apps endpoint if restRequest(server, url, 'post' , payload, 201 ) is None : return @app .command(context_settings = dict ( ignore_unknown_options = True , allow_extra_args = True )) @click .argument( 'appeui' ) @click .pass_context] |
Error:2019-04-18T09:50:11+0100 [twisted.web.wsgi._ErrorStream#error] [2019-04-18 09:50:11,067] ERROR in app: Exception on /api/v1.0/apps [POST]
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/Flask-1.0.2-py2.7.egg/flask/app.py", line 1813, in full_dispatch_request
rv = self.dispatch_request()
File "/usr/local/lib/python2.7/dist-packages/Flask-1.0.2-py2.7.egg/flask/app.py", line 1799, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/usr/local/lib/python2.7/dist-packages/Flask_RESTful-0.3.7-py2.7.egg/flask_restful/__init__.py", line 458, in wrapper
resp = resource(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/Flask-1.0.2-py2.7.egg/flask/views.py", line 88, in view
return self.dispatch_request(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/Flask_RESTful-0.3.7-py2.7.egg/flask_restful/__init__.py", line 573, in dispatch_request
resp = meth(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/Flask_Login-0.4.1-py2.7.egg/flask_login/utils.py", line 261, in decorated_view
return func(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/crochet-1.9.0-py2.7.egg/crochet/_eventloop.py", line 510, in wrapper
return eventual_result.wait(timeout)
File "/usr/local/lib/python2.7/dist-packages/crochet-1.9.0-py2.7.egg/crochet/_eventloop.py", line 241, in wait
result.raiseException()
File "<string>", line 2, in raiseException
KeyError: 'appinterface_id'