Writes out error message specifying the valid commands.

    Returns:
        Failure code for system exit
328396
def error_message():
    
    sys.stderr.write('valid commands:\n')
    for cmd in get_valid_commands():
        sys.stderr.write('\t%s\n' % cmd)
    return -1
91649
def show_error(msg):
    
    sys.stdout.flush()
    sys.stderr.write("\n{0!s}: {1}".format(colored.red("Error"), msg + '\n'))
1221863
def validate (self):
    
    if not os.path.isfile(self.pathname):
      self.message.append('Filename "%s" does not exist.')
    else:
      try:
        with open(self.pathname, 'r') as stream:
          pass
      except IOError:
        self.messages.append('Could not open "%s" for reading.' % self.pathname)

    for line in self.commands:
      messages = [ ]
      if line.cmd and not line.cmd.validate(messages):
        msg = 'error: %s: %s' % (line.cmd.name, " ".join(messages))
        self.log.messages.append(msg)

    return len(self.log.messages) == 0
998229
def execute_return_success(cmd):
    '''
    
    '''

    ret = _run_all(cmd)

    if ret['retcode'] != 0 or 'not supported' in ret['stdout'].lower():
        msg = 'Command Failed: {0}\n'.format(cmd)
        msg += 'Return Code: {0}\n'.format(ret['retcode'])
        msg += 'Output: {0}\n'.format(ret['stdout'])
        msg += 'Error: {0}\n'.format(ret['stderr'])
        raise CommandExecutionError(msg)

    return True
535846
def _check_cmd(call):
    '''
    
    '''
    if call['retcode'] != 0:
        comment = ''
        std_err = call.get('stderr')
        std_out = call.get('stdout')
        if std_err:
            comment += std_err
        if std_out:
            comment += std_out

        raise CommandExecutionError('Error running command: {0}'.format(comment))

    return call
890702
def Exit(msg, code=1):
    
    print >> sys.stderr, msg
    sys.exit(code)
1104690
def write_and_return(
        command, ack, serial_connection, timeout=DEFAULT_WRITE_TIMEOUT):
    ''''''
    clear_buffer(serial_connection)
    with serial_with_temp_timeout(
            serial_connection, timeout) as device_connection:
        response = _write_to_device_and_return(command, ack, device_connection)
    return response
591257
def _scons_syntax_error(e):
    
    etype, value, tb = sys.exc_info()
    lines = traceback.format_exception_only(etype, value)
    for line in lines:
        sys.stderr.write(line+'\n')
    sys.exit(2)
651298
def exit_enable_mode(self, exit_command=""):
        
        output = ""
        if self.check_enable_mode():
            self.write_channel(self.normalize_cmd(exit_command))
            output += self.read_until_prompt()
            if self.check_enable_mode():
                raise ValueError("Failed to exit enable mode.")
        return output
148752
def err(*args):
    
    for value in args:
        sys.stderr.write(value)

    sys.stderr.write(os.linesep)
1006359
def do_exit(self, line):
        """"""
        n_remaining_operations = len(self._command_processor.get_operation_queue())
        if n_remaining_operations:
            d1_cli.impl.util.print_warn(
                """There are {} unperformed operations in the write operation queue. These will
be lost if you exit.""".format(
                    n_remaining_operations
                )
            )
            if not d1_cli.impl.util.confirm("Exit?", default="yes"):
                return
        sys.exit()
41860
def error(self, s, pos):
        
        print("Lexical error:")
        print("%s" % s[:pos+10])  # + 10 for trailing context
        print("%s^" % (" "*(pos-1)))
        for t in self.rv: print(t)
        raise SystemExit
442054
def fail(message, code=-1):
    """"""
    print('Error: %s' % message, file=sys.stderr)
    sys.exit(code)
58475
def _on_process_error(self, error):
        
        if self is None:
            return
        err = PROCESS_ERROR_STRING[error]
        self._formatter.append_message(err + '\r\n', output_format=OutputFormat.ErrorMessageFormat)
225088
def check_error_cmd(result):
    
    return (result.value >= ReturnCode.ERRCMD) and (result.value < ReturnCode.WARNING)
804
def write_command(self, request_id, msg):
        
        self.send_message(msg, 0)
        reply = self.receive_message(request_id)
        result = reply.command_response()

        # Raises NotMasterError or OperationFailure.
        helpers._check_command_response(result)
        return result
85465
def write_error(*args, **kwargs):
    """"""
    if _logger:
        kwargs.pop("end", None)
        kwargs.pop("file", None)
        _logger.error(*args, **kwargs)
    else:
        print(*args, file=sys.stderr, **kwargs)