Ejemplo n.º 1
0
def handle():
    ''''''
    command = bottle.request.forms.get('command').strip()

    args = command.split()
    name = args[0].upper()
    args = [util.toNumber(t, t) for t in args[1:]]
    valid, msgs = CMD_API.validate(name, *args)

    if valid:
        bottle.response.status = 200
        validation_status = '{} Passed Ground Verification'.format(command)
        log.info('Command Validation: {}'.format(validation_status))
    else:
        bottle.response.status = 400
        validation_status = '{} Command Failed Ground Verification'.format(command)

    bottle.response.content_type = 'application/json'
    return json.dumps({
        'msgs': [str(m) for m in msgs],
        'status': validation_status
    })
Ejemplo n.º 2
0
        def handle():
            """Send a given command
            :formparam command: The command that should be sent. If arguments
                                are to be included they should be separated via
                                whitespace.
            **Example command format**
            .. sourcecode:
               myExampleCommand argumentOne argumentTwo
            """
            with Sessions.current() as session:
                command = bottle.request.forms.get('command').strip()

                args = command.split()
                if args:
                    name = args[0].upper()
                    args = [util.toNumber(t, t) for t in args[1:]]

                    if self.send(name, *args):
                        Sessions.addEvent('cmd:hist', command)
                        bottle.response.status = 200
                    else:
                        bottle.response.status = 400
                else:
                    bottle.response.status = 400