本文整理匯總了Python中curses.nocbreak方法的典型用法代碼示例。如果您正苦於以下問題:Python curses.nocbreak方法的具體用法?Python curses.nocbreak怎麽用?Python curses.nocbreak使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類curses
的用法示例。
在下文中一共展示了curses.nocbreak方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: main
# 需要導入模塊: import curses [as 別名]
# 或者: from curses import nocbreak [as 別名]
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")
示例2: wrapper_basic
# 需要導入模塊: import curses [as 別名]
# 或者: from curses import nocbreak [as 別名]
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()
示例3: wrapper_fork
# 需要導入模塊: import curses [as 別名]
# 或者: from curses import nocbreak [as 別名]
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)
示例4: start
# 需要導入模塊: import curses [as 別名]
# 或者: from curses import nocbreak [as 別名]
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()
示例5: manipulate
# 需要導入模塊: import curses [as 別名]
# 或者: from curses import nocbreak [as 別名]
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
示例6: terminate
# 需要導入模塊: import curses [as 別名]
# 或者: from curses import nocbreak [as 別名]
def terminate(self) -> None:
"""Set console settings to their normal state.
This method does not, by itself, cause the application to exit. Nor
does it even cause the input loop to end. It should simply be seen as
a "wrapping up" method for any actions which need to be performed
before the object is destroyed.
"""
self._queue.stop()
self.database.replace_queue(self._queue)
curses.nocbreak()
self._stdscr.keypad(False)
curses.echo()
curses.endwin()
示例7: signal_handler
# 需要導入模塊: import curses [as 別名]
# 或者: from curses import nocbreak [as 別名]
def signal_handler(screen):
"""This function is bound to the SIGINT signal (like ctrl+c) to graciously
exit the program and reset the curses options.
"""
if screen:
screen.clear()
screen.refresh()
curses.nocbreak()
screen.keypad(0)
curses.echo()
curses.endwin()
print("Exiting flowcraft inspection... Bye")
sys.exit(0)
示例8: cleanup
# 需要導入模塊: import curses [as 別名]
# 或者: from curses import nocbreak [as 別名]
def cleanup(gui, poll, injector, ts, tests, command_line, args):
ts.run = False
if gui:
gui.stop()
if poll:
poll.stop()
if injector:
injector.stop()
'''
# doesn't work
if gui:
for (i, c) in enumerate(gui.orig_colors):
curses.init_color(i, c[0], c[1], c[2])
'''
curses.nocbreak();
curses.echo()
curses.endwin()
dump_artifacts(tests, injector, command_line)
if args.save:
with open(LAST, "w") as f:
f.write(hexlify(cstr2py(tests.r.raw_insn)))
sys.exit(0)
示例9: stop
# 需要導入模塊: import curses [as 別名]
# 或者: from curses import nocbreak [as 別名]
def stop(self):
curses.nocbreak();
curses.echo()
curses.endwin()
示例10: shut_down
# 需要導入模塊: import curses [as 別名]
# 或者: from curses import nocbreak [as 別名]
def shut_down():
"""Closes connection and restores terminal"""
curses.nocbreak()
curses.echo()
curses.endwin()
gpsd_socket.close()
print('Keyboard interrupt received\nTerminated by user\nGood Bye.\n')
sys.exit(1)
示例11: on_finish
# 需要導入模塊: import curses [as 別名]
# 或者: from curses import nocbreak [as 別名]
def on_finish(self):
"""Close cleanly the I/O."""
# we need to close curses only if it was opened
if self.debug and not self.compat_debug:
curses.nocbreak()
self.stdscr.keypad(False)
curses.echo()
curses.endwin()
示例12: close
# 需要導入模塊: import curses [as 別名]
# 或者: from curses import nocbreak [as 別名]
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()
示例13: _screen_terminate
# 需要導入模塊: import curses [as 別名]
# 或者: from curses import nocbreak [as 別名]
def _screen_terminate(self):
"""Terminate the curses screen."""
self._stdscr.keypad(0)
curses.nocbreak()
curses.echo()
curses.endwin()
try:
# Remove SIGINT handler.
signal.signal(signal.SIGINT, signal.SIG_DFL)
except ValueError:
# Can't catch signals unless you're the main thread.
pass
示例14: wrapper
# 需要導入模塊: import curses [as 別名]
# 或者: from curses import nocbreak [as 別名]
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()
示例15: _screen_terminate
# 需要導入模塊: import curses [as 別名]
# 或者: from curses import nocbreak [as 別名]
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)