Catch common beginner mistake and give a helpful error message on stderr
501467
def execute(*)
      file, line, = caller.first.split(":")
      colors = SSHKit::Color.new($stderr)
      $stderr.puts colors.colorize("Warning: `execute' should be wrapped in an `on' scope in #{file}:#{line}.", :red)
      $stderr.puts
      $stderr.puts "  task :example do"
      $stderr.puts colors.colorize("    on roles(:app) do", :yellow)
      $stderr.puts "      execute 'whoami'"
      $stderr.puts colors.colorize("    end", :yellow)
      $stderr.puts "  end"
      $stderr.puts
      raise NoMethodError, "undefined method `execute' for main:Object"
    end
741414
def stderr_handle(self):
        """"""
        if self.stderr_file is not None:
            # Needed to prevent any error that could appear.
            # See issue 6267
            try:
                handle = codecs.open(self.stderr_file, 'w', encoding='utf-8')
            except Exception:
                handle = None
        else:
            handle = None

        return handle
64008
def error_log(self, msg='', level=20, traceback=False):
        
        # Override this in subclasses as desired
        sys.stderr.write(msg + '\n')
        sys.stderr.flush()
        if traceback:
            tblines = traceback_.format_exc()
            sys.stderr.write(tblines)
            sys.stderr.flush()
937951
def err(self, output, newline=True):
        """"""
        click.echo(output, nl=newline, err=True)
546827
def handle_err(*args):
    
    if DEBUG:
        print_err(traceback.format_exc(), color=False)
    else:
        print_err(*args, newline=True)
571156
def error(self, message: str) -> None:
        """"""
        if len(self._custom_error_message) > 0:
            message = self._custom_error_message
            self._custom_error_message = ''

        lines = message.split('\n')
        linum = 0
        formatted_message = ''
        for line in lines:
            if linum == 0:
                formatted_message = 'Error: ' + line
            else:
                formatted_message += '\n       ' + line
            linum += 1

        sys.stderr.write(Fore.LIGHTRED_EX + '{}\n\n'.format(formatted_message) + Fore.RESET)
        # sys.stderr.write('{}\n\n'.format(formatted_message))
        self.print_help()
        sys.exit(1)
801575
def perror(*args, **kwargs):
    """"""

    if should_msg(kwargs.get("groups", ["error"])):
        # initialize colorama only if uninitialized
        global colorama_init
        if not colorama_init:
            colorama_init = True
            colorama.init()

        args = indent_text(*args, **kwargs)

        # write to stdout
        sys.stderr.write(colorama.Fore.RED)
        sys.stderr.write("".join(args))
        sys.stderr.write(colorama.Fore.RESET)
        sys.stderr.write("\n")
640356
def error_handler(_, err, arg):
    """"""
    arg.value = err.error
    return libnl.handlers.NL_STOP
697831
def _emit_error(cls, message):
        """"""
        sys.stderr.write('ERROR: {message}\n'.format(message=message))
        sys.stderr.flush()
1146251
def _read_stderr(self):
        
        output = self._decode(self._process.readAllStandardError().data())
        if self._formatter:
            self._formatter.append_message(output, output_format=OutputFormat.ErrorMessageFormat)
        else:
            self.insertPlainText(output)
819029
def succ(cmd, check_stderr=True, stdout=None, stderr=None):
    '''
    
    '''
    code, out, err = run(cmd)

    # Because we're raising error, sometimes we want to process stdout/stderr after catching error
    # so we're copying these outputs if required
    if stdout is not None:
        stdout[:] = out
    if stderr is not None:
        stderr[:] = err

    if code != 0:
        for l in out:
            print(l)
    assert code == 0, 'Return: {} {}\nStderr: {}'.format(code, cmd, err)
    if check_stderr:
        assert err == [], 'Error: {} {}'.format(err, code)
    return code, out, err
796799
def puts_err(s='', newline=True, stream=STDERR):
    """"""
    puts(s, newline, stream)
136545
def stderr(msg, silent=False):
    
    if not silent:
        print(msg, file=sys.stderr)
966048
def handle_error(self, exc, msg):
        
        if self.mode == "api":
            logger.error(msg)
            if self.strict:
                raise exc
        elif self.mode == "cli":
            sys.stderr.write(msg)
            sys.exit(1)
1149700
def error(self, message):
        """"""
        sys.stderr.write('error: %s\n\n' % message)
        self.print_help()
        sys.exit(2)
1268896
def error(message, code=1):
    """"""
    if message:
        print('ERROR: {0}'.format(message), file=sys.stderr)
    else:
        print(file=sys.stderr)
    sys.exit(code)
694565
def errReceived(self, data):
        
        lines = data.splitlines()
        for line in lines:
            log_error("*** {name} stderr *** {line}", 
                    name=self.name,
                    line=self.errFilter(line))