Execute command line helper.

def call():
    """Execute command line helper."""
    args = get_arguments()

    if args.debug:
        log_level = logging.DEBUG
    elif args.quiet:
        log_level = logging.WARN
    else:
        log_level = logging.INFO

    setup_logging(log_level)

    lupusec = None

    if not args.username or not args.password or not args.ip_address:
            raise Exception("Please supply a username, password and ip.")

    def _devicePrint(dev, append=''):
        _LOGGER.info("%s%s", dev.desc, append)

    try:
        if args.username and args.password and args.ip_address:
            lupusec = lupupy.Lupusec(ip_address=args.ip_address,
                                     username=args.username,
                                     password=args.password)
        
        if args.arm:
            if lupusec.get_alarm().set_away():
                _LOGGER.info('Alarm mode changed to armed')
            else:
                _LOGGER.warning('Failed to change alarm mode to armed')
        
        if args.disarm:
            if lupusec.get_alarm().set_standby():
                _LOGGER.info('Alarm mode changed to disarmed')
            else:
                _LOGGER.warning('Failed to change alarm mode to disarmed')

        if args.home:
            if lupusec.get_alarm().set_home():
                _LOGGER.info('Alarm mode changed to home')
            else:
                _LOGGER.warning('Failed to change alarm mode to home')
            
        if args.history:
            _LOGGER.info(json.dumps(lupusec.get_history()['hisrows'], indent=4, sort_keys=True))

        if args.status:
            _LOGGER.info('Mode of panel: %s', lupusec.get_alarm().mode)
        
        if args.devices:
            for device in lupusec.get_devices():
                _devicePrint(device)
                
    except lupupy.LupusecException as exc:
        _LOGGER.error(exc)
    finally:
        _LOGGER.info('--Finished running--')