http://stackoverflow.com/questions/18937058/python-clear-screen-in-shell
428410
def clear_screen():
    import os, platform
    
    if platform.system() == "Windows":
        tmp = os.system('cls') #for window
    else:
        tmp = os.system('clear') #for Linux
    return True
370979
def reset(self, clear=False):
        
        if self._executing:
            self._executing = False
            self._request_info['execute'] = {}
        self._reading = False
        self._highlighter.highlighting_on = False

        if clear:
            self._control.clear()
            if self._display_banner:
                if self.kernel_banner:
                    self._append_plain_text(self.kernel_banner)
                self._append_plain_text(self.banner)

        # update output marker for stdout/stderr, so that startup
        # messages appear after banner:
        self._show_interpreter_prompt()
605215
public void clear() {
        if (buffer.size() > 0) {
            terminal.format("\r%s", CURSOR_ERASE);
            for (int i = 1; i < buffer.size(); ++i) {
                terminal.format("%s%s", UP, CURSOR_ERASE);
            }
            buffer.clear();
        }
    }
93926
def clear():
    
    if not isatty(sys.stdout):
        return
    # If we're on Windows and we don't have colorama available, then we
    # clear the screen by shelling out.  Otherwise we can use an escape
    # sequence.
    if WIN:
        os.system('cls')
    else:
        sys.stdout.write('\033[2J\033[1;1H')
425432
def clean(session):
    
    clean_dirs = (
        get_path(".cache"),
        get_path(".coverage"),
        get_path(".pytest_cache"),
        get_path("__pycache__"),
        get_path("build"),
        get_path("dist"),
        get_path("docs", "__pycache__"),
        get_path("docs", "build"),
        get_path("scripts", "macos", "__pycache__"),
        get_path("scripts", "macos", "dist_wheels"),
        get_path("scripts", "macos", "fixed_wheels"),
        get_path("src", "bezier.egg-info"),
        get_path("src", "bezier", "__pycache__"),
        get_path("src", "bezier", "extra-dll"),
        get_path("src", "bezier", "lib"),
        get_path("tests", "__pycache__"),
        get_path("tests", "functional", "__pycache__"),
        get_path("tests", "unit", "__pycache__"),
        get_path("wheelhouse"),
    )
    clean_globs = (
        get_path(".coverage"),
        get_path("*.mod"),
        get_path("*.pyc"),
        get_path("src", "bezier", "*.pyc"),
        get_path("src", "bezier", "*.pyd"),
        get_path("src", "bezier", "*.so"),
        get_path("src", "bezier", "quadpack", "*.o"),
        get_path("src", "bezier", "*.o"),
        get_path("tests", "*.pyc"),
        get_path("tests", "functional", "*.pyc"),
        get_path("tests", "unit", "*.pyc"),
    )
    for dir_path in clean_dirs:
        session.run(shutil.rmtree, dir_path, ignore_errors=True)
    for glob_path in clean_globs:
        for filename in glob.glob(glob_path):
            session.run(os.remove, filename)
761749
def clear_high_level_pars(self):
        
        for val in ['mean_type', 'dec', 'inc', 'alpha95', 'K', 'R', 'n_lines', 'n_planes']:
            COMMAND = """self.%s_window.SetValue("")""" % (val)
            exec(COMMAND)
        if self.ie_open:
            for val in ['mean_type', 'dec', 'inc', 'alpha95', 'K', 'R', 'n_lines', 'n_planes']:
                COMMAND = """self.ie.%s_window.SetValue("")""" % (val)
                exec(COMMAND)
        self.set_mean_stats_color()
164820
void redrawRestOfScreen() {
        int linesToRepaint = terminal.getHeight() - getFooterSize() - frameLine;
        LinkedList<String> toRepaintLines = new LinkedList<String>();
        String currentLine = getContent(getLine());
        toRepaintLines.addAll(toDisplayLines(currentLine));
        //Remove already shown lines
        int remainingLines = Math.max(0, getColumn() - 1) / terminal.getWidth();
        for (int r = 0; r < remainingLines; r++) {
            toRepaintLines.removeFirst();
        }

        boolean eof = false;
        for (int l = 1; toRepaintLines.size() < linesToRepaint && !eof; l++) {
            try {
                toRepaintLines.addAll(toDisplayLines(getContent(getLine() + l)));
            } catch (Exception e) {
                eof = true;
            }
        }

        saveCursorPosition();
        for (int l = 0; l < linesToRepaint; l++) {
            console.out().print(ansi().cursor(frameLine + getHeaderSize() + l, 1));
            console.out().print(ansi().eraseLine(Erase.FORWARD));
            if (toRepaintLines.size() > l) {
                displayText(toRepaintLines.get(l));
            } else {
                displayText("");
            }
        }
        restoreCursorPosition();
    }
1086399
def on_ok(self):
        
        npyscreen.notify_wait('Deleting instances given...',
                              title='In progress')
        # keep track of number for shifting instances down for alignment
        shift_num = 1
        to_update = []
        for i, val in enumerate(self.del_instances.values):
            # clean all tools for renmaing and relabeling purposes
            t = val.split(':')
            section = self.display_to_section[val]
            prev_running = self.manifest.option(section, 'running')
            run = prev_running[0] and prev_running[1] == 'yes'
            if i in self.del_instances.value:
                if run:
                    # grab dependencies of tools that linked to previous one
                    if i == 0:
                        dependent_tools = [self.manifest.option(
                            section, 'link_name')[1]]
                        for dependency in Dependencies(dependent_tools):
                            self.clean(**dependency)
                            to_update.append(dependency)
                    self.clean(name=t[0], branch=t[1], version=t[2])
                self.manifest.del_section(section)
            else:
                try:
                    # update instances for tools remaining
                    section = self.display_to_section[val]
                    settings_dict = json.loads(self.manifest.option
                                               (section, 'settings')[1])
                    settings_dict['instances'] = self.new_instances
                    self.manifest.set_option(section, 'settings',
                                             json.dumps(settings_dict))
                    # check if tool name doesn't need to be shifted because
                    # it's already correct
                    identifier = str(shift_num) if shift_num != 1 else ''
                    new_section = section.rsplit(':', 2)
                    new_section[0] = re.sub(r'\d+$', identifier,
                                            new_section[0])
                    new_section = ':'.join(new_section)
                    if section != new_section:
                        # clean tool so that we can rename its container and
                        # labels with new information
                        self.clean(name=t[0], branch=t[1], version=t[2])
                        prev_name = self.manifest.option(section, 'name')[1]
                        new_name = re.split(r'[0-9]', prev_name)[0] + \
                            identifier
                        self.manifest.set_option(section, 'name', new_name)
                        # copy new contents into shifted version
                        self.manifest.add_section(new_section)
                        for val_pair in self.manifest.section(section)[1]:
                            self.manifest.set_option(new_section, val_pair[0],
                                                     val_pair[1])
                        self.manifest.del_section(section)
                        if run:
                            to_update.append({'name': new_name,
                                              'branch': t[1],
                                              'version': t[2]})
                    shift_num += 1
                except Exception as e:
                    npyscreen.notify_confirm('Trouble deleting tools'
                                             ' because ' + str(e))
        self.manifest.write_config()
        tool_d = {}
        for tool in to_update:
            tool_d.update(self.prep_start(**tool)[1])
        if tool_d:
            self.start_tools(tool_d)
        npyscreen.notify_confirm('Done deleting instances.',
                                 title='Finished')
        self.change_screens()
479439
def clear(self):
        
        for _, frame in self._segments.items():
            frame.configure(background=self._bg_color)
982461
def clear_all():
    

    frame = inspect.currentframe().f_back
    try:
        if frame.f_globals.get('variables_order'):
            # we should avoid to declare symbols twice !
            del frame.f_globals['variables_order']
        if frame.f_globals.get('parameters_order'):
            # we should avoid to declare symbols twice !
            del frame.f_globals['parameters_order']
    finally:
        del frame
1049330
function clearScreen(reset) {
    if (reset === void 0) { reset = true; }
    var out = '\x1B[2J';
    var newline = '\n';
    if (chek_1.isWindows()) { // hack cause windows sucks!
        newline = '\r\n';
        out = '';
        var lines = process.stdout['getWindowSize']()[1] || [];
        lines.forEach(function (line) {
            out += '\r\n';
        });
    }
    out += '\x1B[0f';
    process.stdout.write(out);
}
1012032
def clear_java_home():
    
    if os.environ.get("BCBIO_JAVA_HOME"):
        test_cmd = os.path.join(os.environ["BCBIO_JAVA_HOME"], "bin", "java")
        if os.path.exists(test_cmd):
            return "export JAVA_HOME=%s" % os.environ["BCBIO_JAVA_HOME"]
    return "unset JAVA_HOME"
187360
def screensaver():
    '''
    
    '''
    cmd = 'open /System/Library/Frameworks/ScreenSaver.framework/Versions/A/Resources/ScreenSaverEngine.app'
    call = __salt__['cmd.run_all'](
        cmd,
        output_loglevel='debug',
        python_shell=False
    )
    _check_cmd(call)

    return True
605350
def clear(self, *args):
        

        black = (0, 0, 0)  # default

        if len(args) == 0:
            colour = black
        elif len(args) == 1:
            colour = args[0]
        elif len(args) == 3:
            colour = args
        else:
            raise ValueError('Pixel arguments must be given as (r, g, b) or r, g, b')

        self.set_pixels([colour] * 64)
97409
def _clear_context(bin_env=None):
    '''
    
    '''
    contextkey = 'pip.version'
    if bin_env is not None:
        contextkey = '{0}.{1}'.format(contextkey, bin_env)
    __context__.pop(contextkey, None)
490298
def __rmpid(self):
        
        import tempfile
        d = tempfile.gettempdir()
        name = os.path.join(d, "hoverpy.%i.%i"%(self._proxyPort, self._adminPort))
        if os.path.exists(name):
            os.unlink(name)
            logging.debug("deleting %s"%name)
916798
def fullscreen(self):
        ''' 
        '''
        stream = self._stream
        stream.write(self.alt_screen_enable)
        stream.write(str(self.save_title(0)))     # 0 = both icon, title
        stream.flush()
        try:
            yield self
        finally:
            stream.write(self.alt_screen_disable)
            stream.write(str(self.restore_title(0)))  # 0 = icon & title
            stream.flush()