Python curses.endwin() Examples
The following are 30
code examples of curses.endwin().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
curses
, or try the search function
.
Example #1
Source File: raspcloud.py From RaspberryCloud with GNU General Public License v3.0 | 6 votes |
def donate(s): curses.endwin() clearscreen() print JColor.FGYELLOW + JColor.BOLDON + "Donate Bitcoin" + JColor.ENDC + JColor.BOLDOFF print "19Ve bRAu 8ZdT zf7A JnJv dCyh qSBZ qMon T\n" print JColor.FGYELLOW + JColor.BOLDON + "Donate Dogecoin" + JColor.ENDC + JColor.BOLDOFF print "DBGX4dwhD7SHhfcgzKjSZ2yJDhruAPgPUP\n" print JColor.FGYELLOW + JColor.BOLDON + "Donate via Paypal" + JColor.ENDC + JColor.BOLDOFF print "http://bit.ly/1klxN1M\n" print JColor.FGGREEN + JColor.BOLDON + """ However, what I'd really love more than a donation is a job! I'm fresh out of college and haven't had much luck finding one. I know it's a long shot, but if you are interested in hiring me, full-time, part-time or on a freelance basis, please email me at hall.jared.m@gmail.com and let me know! My resume is available on my website at http://www.jaredmhall.com. I'm also the proud creator of http://www.doge4.us as well as the android app over at http://goo.gl/JpeJFV. So if you're into that sort of thing, give 'em a look sometime! Thank you for your time and stay stoked!\n""" + JColor.ENDC + JColor.BOLDOFF print raw_input("Press [ENTER] to continue..") start_raspberry_cloud(s)
Example #2
Source File: __main__.py From musicbox with MIT License | 6 votes |
def start(): parser = argparse.ArgumentParser() parser.add_argument( "-v", "--version", help="show this version and exit", action="store_true" ) args = parser.parse_args() if args.version: latest = Menu().check_version() curses.endwin() print("NetEase-MusicBox installed version:" + version) if latest != version: print("NetEase-MusicBox latest version:" + str(latest)) sys.exit() nembox_menu = Menu() try: nembox_menu.start_fork(version) except (OSError, TypeError, ValueError, KeyError, IndexError): # clean up terminal while failed curses.echo() curses.nocbreak() curses.endwin() traceback.print_exc()
Example #3
Source File: interface.py From bitcoind-ncurses with MIT License | 6 votes |
def main(block_viewer, window, interface_queue, rpcc, poller, initial_mode=None): error_message = False rpcc.request("getnetworkinfo") rpcc.request("getblockchaininfo") try: state = init_state() splash.draw_window(state, window) check_window_size(interface_queue, state, window, 12, 75) # min_y, min_x if initial_mode: hotkey.change_mode(state, window, initial_mode, poller) error_message = loop(block_viewer, state, window, interface_queue, rpcc, poller) finally: # restore sane terminal state, end RPC thread curses.nocbreak() curses.endwin() if error_message: sys.stderr.write("bitcoind-ncurses encountered an error\n") sys.stderr.write("Message: " + error_message + "\n")
Example #4
Source File: cyberbot.py From cyberbot with MIT License | 6 votes |
def run(self): while any(_.is_alive() for _ in self.processes): time.sleep(0.1) self.stdscr_size = self.stdscr.getmaxyx() self.build_progress_screen() self.build_status_screen() self.build_output_screen() # terminate manually when all tasks finished if self.task_num == self.task_total: for _ in self.processes: _.terminate() self.stdscr.addstr(self.stdscr_size[0] - 2, 0, 'Done! please type "q" to exit.') self.stdscr.refresh() while self.stdscr.getch() != ord('q'): time.sleep(1) curses.endwin()
Example #5
Source File: wrapper.py From BinderFilter with MIT License | 6 votes |
def wrapper(func, *args, **kwds): """Wrapper function that initializes curses and calls another function, restoring normal keyboard/screen behavior on error. The callable object 'func' is then passed the main window 'stdscr' as its first argument, followed by any other arguments passed to wrapper(). """ try: # Initialize curses stdscr = curses.initscr() # Turn off echoing of keys, and enter cbreak mode, # where no buffering is performed on keyboard input curses.noecho() curses.cbreak() # In keypad mode, escape sequences for special keys # (like the cursor keys) will be interpreted and # a special value like curses.KEY_LEFT will be returned stdscr.keypad(1) # Start color, too. Harmless if the terminal doesn't have # color; user can test with has_color() later on. The try/catch # works around a minor bit of over-conscientiousness in the curses # module -- the error return from C start_color() is ignorable. try: curses.start_color() except: pass return func(stdscr, *args, **kwds) finally: # Set everything back to normal if 'stdscr' in locals(): stdscr.keypad(0) curses.echo() curses.nocbreak() curses.endwin()
Example #6
Source File: airpydump.py From airpydump with MIT License | 6 votes |
def manipulate(self, pkt): if self.save: self.file__.write(pkt) self.call1(pkt) self.call2(pkt) call3_varbell = self.call3(pkt) if bool(call3_varbell): self.ntwk_call_3.append(call3_varbell) call4_varbell = self.call4(pkt) if bool(call4_varbell): self.ntwk_call_4.append(call4_varbell) if self.curses: try: self.display.print_handler() except: curses.nocbreak() self.display.screen.keypad(0) curses.echo() curses.endwin() return
Example #7
Source File: npyssafewrapper.py From apple_bleee with GNU General Public License v3.0 | 6 votes |
def wrapper_basic(call_function): #set the locale properly locale.setlocale(locale.LC_ALL, '') return curses.wrapper(call_function) #def wrapper(call_function): # locale.setlocale(locale.LC_ALL, '') # screen = curses.initscr() # curses.noecho() # curses.cbreak() # # return_code = call_function(screen) # # curses.nocbreak() # curses.echo() # curses.endwin()
Example #8
Source File: npyssafewrapper.py From apple_bleee with GNU General Public License v3.0 | 6 votes |
def wrapper_fork(call_function, reset=True): pid = os.fork() if pid: # Parent os.waitpid(pid, 0) if reset: external_reset() else: locale.setlocale(locale.LC_ALL, '') _SCREEN = curses.initscr() try: curses.start_color() except: pass _SCREEN.keypad(1) curses.noecho() curses.cbreak() curses.def_prog_mode() curses.reset_prog_mode() return_code = call_function(_SCREEN) _SCREEN.keypad(0) curses.echo() curses.nocbreak() curses.endwin() sys.exit(0)
Example #9
Source File: iotop.py From psutil with BSD 3-Clause "New" or "Revised" License | 6 votes |
def refresh_window(procs, disks_read, disks_write): """Print results on screen by using curses.""" curses.endwin() templ = "%-5s %-7s %11s %11s %s" win.erase() disks_tot = "Total DISK READ: %s | Total DISK WRITE: %s" \ % (bytes2human(disks_read), bytes2human(disks_write)) print_line(disks_tot) header = templ % ("PID", "USER", "DISK READ", "DISK WRITE", "COMMAND") print_line(header, highlight=True) for p in procs: line = templ % ( p.pid, p._username[:7], bytes2human(p._read_per_sec), bytes2human(p._write_per_sec), p._cmdline) try: print_line(line) except curses.error: break win.refresh()
Example #10
Source File: predator_prey_env.py From IC3Net with MIT License | 5 votes |
def exit_render(self): curses.endwin()
Example #11
Source File: song_list.py From Pytify with MIT License | 5 votes |
def __init__(self, items): self.pytify = get_pytify_class_by_platform()() self.items = items self.position = 2 self.song_length = len(items) - 1 # Init curses screen self.window = curses.initscr() self.window.keypad(1) self.panel = panel.new_panel(self.window) self.panel.hide() panel.update_panels() # Show shortcuts self.shortcuts() # Disable echoing of keys to the screen curses.noecho() # Disable blinking cursor curses.curs_set(False) # Use user terminal settings curses.endwin() # Display window curses.wrapper(self.display)
Example #12
Source File: traffic_junction_env.py From IC3Net with MIT License | 5 votes |
def exit_render(self): curses.endwin()
Example #13
Source File: debug.py From shadowlands with MIT License | 5 votes |
def debug(): global debugging if not debugging: curses.nocbreak() curses.echo() curses.endwin() debugging = True
Example #14
Source File: common.py From NoobSec-Toolkit with GNU General Public License v2.0 | 5 votes |
def getConsoleWidth(default=80): """ Returns console width """ width = None if os.getenv("COLUMNS", "").isdigit(): width = int(os.getenv("COLUMNS")) else: try: try: FNULL = open(os.devnull, 'w') except IOError: FNULL = None process = execute("stty size", shell=True, stdout=PIPE, stderr=FNULL or PIPE) stdout, _ = process.communicate() items = stdout.split() if len(items) == 2 and items[1].isdigit(): width = int(items[1]) except (OSError, MemoryError): pass if width is None: try: import curses stdscr = curses.initscr() _, width = stdscr.getmaxyx() curses.endwin() except: pass return width or default
Example #15
Source File: common.py From NoobSec-Toolkit with GNU General Public License v2.0 | 5 votes |
def getConsoleWidth(default=80): """ Returns console width """ width = None if os.getenv("COLUMNS", "").isdigit(): width = int(os.getenv("COLUMNS")) else: try: try: FNULL = open(os.devnull, 'w') except IOError: FNULL = None process = execute("stty size", shell=True, stdout=PIPE, stderr=FNULL or PIPE) stdout, _ = process.communicate() items = stdout.split() if len(items) == 2 and items[1].isdigit(): width = int(items[1]) except (OSError, MemoryError): pass if width is None: try: import curses stdscr = curses.initscr() _, width = stdscr.getmaxyx() curses.endwin() except: pass return width or default
Example #16
Source File: colorlog.py From pySINDy with MIT License | 5 votes |
def __init__(self, color=True, datefmt=None): r""" :arg bool color: Enables color support. :arg string fmt: Log message format. It will be applied to the attributes dict of log records. The text between ``%(color)s`` and ``%(end_color)s`` will be colored depending on the level if color support is on. :arg dict colors: color mappings from logging level to terminal color code :arg string datefmt: Datetime format. Used for formatting ``(asctime)`` placeholder in ``prefix_fmt``. .. versionchanged:: 3.2 Added ``fmt`` and ``datefmt`` arguments. """ logging.Formatter.__init__(self, datefmt=datefmt) self._colors = {} if color and _stderr_supports_color(): # The curses module has some str/bytes confusion in # python3. Until version 3.2.3, most methods return # bytes, but only accept strings. In addition, we want to # output these strings with the logging module, which # works with unicode strings. The explicit calls to # unicode() below are harmless in python2 but will do the # right conversion in python 3. fg_color = (curses.tigetstr("setaf") or curses.tigetstr("setf") or "") if (3, 0) < sys.version_info < (3, 2, 3): fg_color = str(fg_color, "ascii") for levelno, code in self.DEFAULT_COLORS.items(): self._colors[levelno] = str(curses.tparm(fg_color, code), "ascii") self._normal = str(curses.tigetstr("sgr0"), "ascii") scr = curses.initscr() self.termwidth = scr.getmaxyx()[1] curses.endwin() else: self._normal = '' # Default width is usually 80, but too wide is worse than too narrow self.termwidth = 70
Example #17
Source File: ui.py From ice with GNU General Public License v3.0 | 5 votes |
def stop(self): if not self.scr: return self.scr.erase() self.scr.refresh() curses.nocbreak() self.scr.keypad(0) curses.echo() curses.endwin()
Example #18
Source File: curses_ui.py From deep_image_model with Apache License 2.0 | 5 votes |
def _screen_terminate(self): """Terminate the curses screen.""" self._stdscr.keypad(0) curses.nocbreak() curses.echo() curses.endwin() # Remove SIGINT handler. signal.signal(signal.SIGINT, signal.SIG_DFL)
Example #19
Source File: tui.py From awesome-finder with MIT License | 5 votes |
def run(self): """Continue running the awesome finder until get interrupted""" try: self.input_stream() except KeyboardInterrupt: pass finally: curses.endwin()
Example #20
Source File: tui.py From python-curses-scroll-example with MIT License | 5 votes |
def run(self): """Continue running the TUI until get interrupted""" try: self.input_stream() except KeyboardInterrupt: pass finally: curses.endwin()
Example #21
Source File: evilmaid.py From EvilAbigail with GNU General Public License v2.0 | 5 votes |
def destroy(self): """ Clear screen and exit """ self.screen.erase() self.refresh() curses.endwin()
Example #22
Source File: airpydump.py From airpydump with MIT License | 5 votes |
def print_exit(self, signal, frame): self.stop_hopper = True if self.curses == True: curses.nocbreak() self.display.screen.keypad(0) curses.echo() curses.endwin() tabulator__ = [] tabulator__2 = [] headers = [color.BOLD+'BSSID', 'ESSID', 'PWR', 'BEAC', 'DATA', 'ENC', 'CIPHER', 'AUTH', 'CH', 'VENDOR'+color.END] for key, value in self.ntwk_call_1.items(): #print "BSSID: %s ESSID: %s BEAC: %d DATA: %d ENC: %s CIPHER: %s AUTH: %s CH: %d VENDOR: %s" % (key.upper(), value[0], value[1], value[2], value[3], value[6], value[7], value[4], value[5]) if value[1] > 10: tab_list_ = [key.upper(),\ color.BLUE+value[0]+color.END,\ value[8] if value[8] < -2 else color.RED+'?'+color.END,\ color.PURPLE+str(value[1])+color.END,\ color.YELLOW+str(value[2])+color.END if value[2] > 150 else value[2],\ color.RED+value[3]+color.END if value[3] in ('WEP', 'OPN') else color.GREEN+value[3]+color.END,\ color.GREEN+value[6]+color.END if 'CCMP' in value[6] else color.RED+value[6]+color.END,\ color.RED+value[7]+color.END if value[7] != "PSK" else value[7],\ color.DARKCYAN+str(value[4])+color.END if value[4] > 12 else value[4],\ color.GREEN+value[5]+color.END if value[5] is not 'unknown' else color.RED+value[5]+color.END] tabulator__.append(tab_list_) del tab_list_ print "\n"+tabulate(tabulator__, headers=headers, tablefmt="simple") if self.handshakes: print "\n"+tabulate(self.ntwk_call_3, headers=[color.BOLD+'TARGET', 'HANDSHAKE'+color.END], tablefmt="simple") for key, value in self.ntwk_call_4.items(): tabulator__2.append([color.BLUE+value[0].upper()+color.END,\ key.upper(),\ color.GREEN+str(value[1])+color.END if value[1]<-2 else color.RED+'?'+color.END,\ value[2], value[3]]) print "\n"+tabulate(tabulator__2, headers=[color.BOLD+'BSSID', 'CLIENT', 'PWR', 'FRAMES', 'VENDOR'+color.END], tablefmt='simple') sys.exit("\n"+color.YELLOW+"BYE!"+color.END) ########################################
Example #23
Source File: screen.py From deepWordBug with Apache License 2.0 | 5 votes |
def close(self, restore=True): """ Close down this Screen and tidy up the environment as required. :param restore: whether to restore the environment or not. """ self._signal_state.restore() if restore: self._screen.keypad(0) curses.echo() curses.nocbreak() curses.endwin()
Example #24
Source File: npyspmfuncs.py From apple_bleee with GNU General Public License v3.0 | 5 votes |
def CallSubShell(subshell): """Call this function if you need to execute an external command in a subshell (os.system). All the usual warnings apply -- the command line will be expanded by the shell, so make sure it is safe before passing it to this function.""" curses.def_prog_mode() #curses.endwin() # Probably causes a memory leak. rtn = os.system("%s" % (subshell)) curses.reset_prog_mode() if rtn is not 0: return False else: return True curses.reset_prog_mode()
Example #25
Source File: npyssafewrapper.py From apple_bleee with GNU General Public License v3.0 | 5 votes |
def wrapper_no_fork(call_function, reset=False): global _NEVER_RUN_INITSCR if not _NEVER_RUN_INITSCR: warnings.warn("""Repeated calls of endwin may cause a memory leak. Use wrapper_fork to avoid.""") global _SCREEN return_code = None if _NEVER_RUN_INITSCR: _NEVER_RUN_INITSCR = False locale.setlocale(locale.LC_ALL, '') _SCREEN = curses.initscr() try: curses.start_color() except: pass curses.noecho() curses.cbreak() _SCREEN.keypad(1) curses.noecho() curses.cbreak() _SCREEN.keypad(1) try: return_code = call_function(_SCREEN) finally: _SCREEN.keypad(0) curses.echo() curses.nocbreak() # Calling endwin() and then refreshing seems to cause a memory leak. curses.endwin() if reset: external_reset() return return_code
Example #26
Source File: grid.py From ngrid with BSD 3-Clause "New" or "Revised" License | 5 votes |
def show_model(model, cfg={}, num_frozen=0): """ Shows an interactive view of the model on a connected TTY. @type model A model instance from this module. """ full_cfg = dict(DEFAULT_CFG) full_cfg.update(cfg) cfg = full_cfg view = GridView(model, cfg, num_frozen=num_frozen) scr = curses.initscr() curses.start_color() curses.use_default_colors() curses.init_pair(1, -1, -1) # normal curses.init_pair(2, curses.COLOR_BLUE, -1) # frozen curses.init_pair(3, -1, -1) # separator curses.init_pair(4, -1, -1) # footer curses.init_pair(5, curses.COLOR_BLACK, curses.COLOR_WHITE) # cursor curses.init_pair(6, curses.COLOR_WHITE, curses.COLOR_BLUE) # selection curses.init_pair(7, curses.COLOR_BLUE, curses.COLOR_WHITE) # frz sel try: curses.noecho() curses.cbreak() scr.keypad(1) view.set_screen(scr, locale.getpreferredencoding()) view.show() finally: curses.nocbreak() scr.keypad(0) curses.echo() curses.endwin()
Example #27
Source File: dht_monitor.py From lbry-sdk with MIT License | 5 votes |
def teardown_curses(): curses.nocbreak() stdscr.keypad(0) curses.echo() curses.endwin()
Example #28
Source File: screen.py From wpm with GNU Affero General Public License v3.0 | 5 votes |
def deinit(self): """Deinitializes curses.""" curses.nocbreak() self.screen.keypad(False) curses.echo() curses.endwin()
Example #29
Source File: screen.py From deepWordBug with Apache License 2.0 | 5 votes |
def _resize_handler(self, *_): """ Window resize signal handler. We don't care about any of the parameters passed in beyond the object reference. """ curses.endwin() curses.initscr() self._re_sized = True
Example #30
Source File: ncurses.py From collection with MIT License | 5 votes |
def quit (self): if self.screen: self.screen.keypad(0) self.screen = None curses.echo() curses.nocbreak() curses.endwin() # curses.reset_shell_mode() return 0