clean exit of curses console
This commit is contained in:
parent
2a165380bb
commit
d9359f2d44
|
@ -1,7 +1,9 @@
|
||||||
"""
|
# -*- coding: UTF-8 -*-
|
||||||
|
# kate: syntax Python ;
|
||||||
|
'''
|
||||||
src/bitmessagecurses/__init__.py
|
src/bitmessagecurses/__init__.py
|
||||||
================================
|
================================
|
||||||
"""
|
'''
|
||||||
|
|
||||||
# Copyright (c) 2014 Luke Montalvo <lukemontalvo@gmail.com>
|
# Copyright (c) 2014 Luke Montalvo <lukemontalvo@gmail.com>
|
||||||
# This file adds a alternative commandline interface, feel free to critique and fork
|
# This file adds a alternative commandline interface, feel free to critique and fork
|
||||||
|
@ -9,7 +11,7 @@ src/bitmessagecurses/__init__.py
|
||||||
# This has only been tested on Arch Linux and Linux Mint
|
# This has only been tested on Arch Linux and Linux Mint
|
||||||
# Dependencies:
|
# Dependencies:
|
||||||
# * from python2-pip
|
# * from python2-pip
|
||||||
# * python2-pythondialog
|
# * python2-pythondialog
|
||||||
# * dialog
|
# * dialog
|
||||||
|
|
||||||
import ConfigParser
|
import ConfigParser
|
||||||
|
@ -144,9 +146,9 @@ def resetlookups():
|
||||||
Timer(1, resetlookups, ()).start()
|
Timer(1, resetlookups, ()).start()
|
||||||
|
|
||||||
|
|
||||||
def drawtab(stdscr): # pylint: disable=too-many-branches, too-many-statements
|
def drawtab(stdscr): # pylint: disable=too-many-branches, too-many-statements
|
||||||
"""Method for drawing different tabs"""
|
'''Method for drawing different tabs'''
|
||||||
if menutab in range(1, len(menu) + 1):
|
if menutab in range(1, len(menu) + 1): # pylint: disable=too-many-nested-blocks
|
||||||
if menutab == 1: # Inbox
|
if menutab == 1: # Inbox
|
||||||
stdscr.addstr(3, 5, "To", curses.A_BOLD)
|
stdscr.addstr(3, 5, "To", curses.A_BOLD)
|
||||||
stdscr.addstr(3, 40, "From", curses.A_BOLD)
|
stdscr.addstr(3, 40, "From", curses.A_BOLD)
|
||||||
|
@ -253,19 +255,21 @@ def drawtab(stdscr): # pylint: disable=too-many-branches, too-many-statem
|
||||||
stdscr.addstr(6, 18, "Connections", curses.A_BOLD)
|
stdscr.addstr(6, 18, "Connections", curses.A_BOLD)
|
||||||
stdscr.hline(7, 6, '-', 23)
|
stdscr.hline(7, 6, '-', 23)
|
||||||
streamcount = []
|
streamcount = []
|
||||||
for host, stream in connected_hosts:
|
try:
|
||||||
if stream >= len(streamcount):
|
for host, stream in connected_hosts:
|
||||||
streamcount.append(1)
|
if stream >= len(streamcount):
|
||||||
else:
|
streamcount.append(1)
|
||||||
streamcount[stream] += 1
|
|
||||||
for i, item in enumerate(streamcount):
|
|
||||||
if i < 4:
|
|
||||||
if i == 0:
|
|
||||||
stdscr.addstr(8 + i, 6, "?")
|
|
||||||
else:
|
else:
|
||||||
stdscr.addstr(8 + i, 6, str(i))
|
streamcount[stream] += 1
|
||||||
stdscr.addstr(8 + i, 18, str(item).ljust(2))
|
for i, item in enumerate(streamcount):
|
||||||
|
if i < 4:
|
||||||
|
if i == 0:
|
||||||
|
stdscr.addstr(8 + i, 6, "?")
|
||||||
|
else:
|
||||||
|
stdscr.addstr(8 + i, 6, str(i))
|
||||||
|
stdscr.addstr(8 + i, 18, str(item).ljust(2))
|
||||||
|
except:
|
||||||
|
pass
|
||||||
# Uptime and processing data
|
# Uptime and processing data
|
||||||
stdscr.addstr(6, 35, "Since startup on " + l10n.formatTimestamp(startuptime, False))
|
stdscr.addstr(6, 35, "Since startup on " + l10n.formatTimestamp(startuptime, False))
|
||||||
stdscr.addstr(7, 40, "Processed " + str(
|
stdscr.addstr(7, 40, "Processed " + str(
|
||||||
|
@ -1202,8 +1206,12 @@ def runwrapper():
|
||||||
curses.curs_set(0)
|
curses.curs_set(0)
|
||||||
stdscr.timeout(1000)
|
stdscr.timeout(1000)
|
||||||
|
|
||||||
curses.wrapper(run)
|
try:
|
||||||
doShutdown()
|
curses.wrapper(run)
|
||||||
|
except BaseException:
|
||||||
|
pass
|
||||||
|
finally:
|
||||||
|
doShutdown()
|
||||||
|
|
||||||
|
|
||||||
def run(stdscr):
|
def run(stdscr):
|
||||||
|
@ -1259,5 +1267,5 @@ def doShutdown():
|
||||||
shutdown.doCleanShutdown()
|
shutdown.doCleanShutdown()
|
||||||
sys.stdout = sys.__stdout__
|
sys.stdout = sys.__stdout__
|
||||||
sys.stderr = sys.__stderr__
|
sys.stderr = sys.__stderr__
|
||||||
|
curses.endwin()
|
||||||
os._exit(0) # pylint: disable=protected-access
|
os._exit(0) # pylint: disable=protected-access
|
||||||
|
|
Loading…
Reference in New Issue
Block a user