Enables terminal raw mode during the context.

    Note: Currently noop for Windows systems.

    Usage: ::

        with raw_mode():
            do_some_stuff()
198121
def raw_mode():
    
    if WIN:
        # No implementation for windows yet.
        yield  # needed for the empty context manager to work
    else:
        #  imports are placed here because this will fail under Windows
        import tty
        import termios

        if not isatty(sys.stdin):
            f = open("/dev/tty")
            fd = f.fileno()
        else:
            fd = sys.stdin.fileno()
            f = None
        try:
            old_settings = termios.tcgetattr(fd)
            tty.setraw(fd)
        except termios.error:
            pass
        try:
            yield
        finally:
            # this block sets the terminal to sane mode again,
            # also in case an exception occured in the context manager
            try:
                termios.tcsetattr(fd, termios.TCSADRAIN, old_settings)
                # sys.stdout.flush()  # not needed I think.
                if f is not None:
                    f.close()
            except termios.error:
                pass
697119
def _raw_open(self, flags, mode=0o777):
        
        return self._accessor.open(self, flags, mode)
318897
def setup_context_menu(self):
        """"""
        ShellBaseWidget.setup_context_menu(self)
        self.copy_without_prompts_action = create_action(self,
                                     _("Copy without prompts"),
                                     icon=ima.icon('copywop'),
                                     triggered=self.copy_without_prompts)
        clear_line_action = create_action(self, _("Clear line"),
                                     QKeySequence(get_shortcut('console',
                                                               'Clear line')),
                                     icon=ima.icon('editdelete'),
                                     tip=_("Clear line"),
                                     triggered=self.clear_line)
        clear_action = create_action(self, _("Clear shell"),
                                     QKeySequence(get_shortcut('console',
                                                               'Clear shell')),
                                     icon=ima.icon('editclear'),
                                     tip=_("Clear shell contents "
                                           "('cls' command)"),
                                     triggered=self.clear_terminal)
        add_actions(self.menu, (self.copy_without_prompts_action,
                    clear_line_action, clear_action))
623871
def reset_terminal():
    ''' 
    '''
    if os.name == 'nt':
        from .windows import cls
        cls()
    else:
        text = sc.reset
        _write(text)
        return text
1316767
def setup_logfile_raw(self, logfile, mode='w'):
        ''''''
        self.logfile_raw = open(logfile, mode=mode)
721098
def enable_lldp(self, port_name, is_ncb=True, is_nb=False):
    

    if is_ncb:
        self.run_lldptool(["-L", "-i", port_name, "-g", "ncb",
                           "adminStatus=rxtx"])
    if is_nb:
        self.run_lldptool(["-L", "-i", port_name, "-g", "nb",
                           "adminStatus=rxtx"])
41524
def touch(self, mode=0o666, exist_ok=True):
        
        if self.exists() and not exist_ok:
            raise OSError(17, "File exists", str(self))

        self._accessor.touch(self)
610708
def set_mode
      chmod = command? 'chmod'
      find = command? 'find'

      return unless chmod && find

      {fmode: 'f', dmode: 'd'}.each do |k, v|
        next if send(k).nil?
        cmd = [find, destination_path, '-type', v, '-exec']
        cmd.concat [chmod, send(k).to_s(8), '{}', '+']
        logger.debug { "Running command: #{cmd.join ' '}" }
        system(*cmd)
      end
    end
196003
def _raise_on_mode(self, mode):
        
        valid_modes = [
            'random_sample',
            'random_sample_per_pix',
            'samples',
            'median',
            'mean',
            'best',
            'percentile']

        if mode not in valid_modes:
            raise ValueError(
                '"{}" is not a valid `mode`. Valid modes are:\n'
                '  {}'.format(mode, valid_modes)
            )
1055422
def get_file_mode_for_reading(context):
    
    format = context['tar'].get('format', None)

    if format or format == '':
        mode = f"r:{context.get_formatted_string(format)}"
    else:
        mode = 'r:*'

    return mode
179792
def set_raw(self, *args):
        
        if not self.enabled: return
        args = map(lambda x: str(x), [x for x in args if x is not None])
        self._write_raw(';'.join(args) + 'm')
892015
def enable_from_env(state=None):
    
    try:
        x = os.environ.get(
            ENVVAR,
            state,
        )
        value = bool(int(x))
    except Exception:  # pylint: disable=broad-except
        value = bool(state)

    return enable(value)
835298
def terminal(self, out=None, border=None):
        
        for qrcode in self:
            qrcode.terminal(out=out, border=border)
438644
def _set_mode(self):
        
        if self.mode is not None:
            logger.debug("changing permission bits of %s to %s", self.path, oct(self.mode))
            os.chmod(self.path, self.mode)
676933
function setRawMode (mode) {
  if (mode) {
    this.do.suppress_go_ahead()
    this.will.suppress_go_ahead()
    this.will.echo()
  } else {
    this.dont.suppress_go_ahead()
    this.wont.suppress_go_ahead()
    this.wont.echo()
  }
}
132552
def raw_cmd(self, *args):
        ''''''
        cmd_line = [self.adb()] + self.adb_host_port_options + list(args)
        if os.name != "nt":
            cmd_line = [" ".join(cmd_line)]
        return subprocess.Popen(cmd_line, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
177029
def _raw_open(self, flags, mode=0o777):
        
        if self._closed:
            self._raise_closed()
        return self._accessor.open(self, flags, mode)