def test_command(subdevice, num_tests=2): """Adjust a command as necessary to get valid arguments. """ _LOG.info('command before testing:\n{}'.format(subdevice.cmd)) for i in range(2): rc = subdevice.command_test() if rc is None: _LOG.info('command is valid') return _LOG.info('test {} returned {}\n{}'.format(i, rc, subdevice.cmd)) _LOG.error('error preparing command: {}'.format(rc)) _sys.exit(1)