Catch CTRL-C before init screen

pull/8/head
nicolargo 2011-12-04 22:00:23 +01:00
parent 91efbc6ace
commit ac6fe891b1
1 changed files with 7 additions and 4 deletions

View File

@ -213,7 +213,6 @@ class glancesScreen():
# If current > 70% of max then color = self.if70pc_color / A_BOLD # If current > 70% of max then color = self.if70pc_color / A_BOLD
# If current > 90% of max then color = self.if90pc_color / A_REVERSE # If current > 90% of max then color = self.if90pc_color / A_REVERSE
# By default: color = self.default_color / 0 # By default: color = self.default_color / 0
max = 0
try: try:
(current * 100) / max (current * 100) / max
except ZeroDivisionError: except ZeroDivisionError:
@ -271,8 +270,11 @@ class glancesScreen():
def update(self): def update(self):
# Refresh the screen # Refresh the screen
self.term_window.refresh() self.term_window.refresh()
# Sleep # Sleep
curses.napms(self.__refresh_time*1000) #curses.napms(self.__refresh_time*1000)
time.sleep(self.__refresh_time)
# Getkey # Getkey
self.__catchKey() self.__catchKey()
@ -432,14 +434,15 @@ def init():
printSyntax() printSyntax()
sys.exit(0) sys.exit(0)
# Catch CTRL-C
signal.signal(signal.SIGINT, signal_handler)
# Init stats # Init stats
stats = glancesStats() stats = glancesStats()
# Init screen # Init screen
screen = glancesScreen(refresh_time) screen = glancesScreen(refresh_time)
# Catch CTRL-C
signal.signal(signal.SIGINT, signal_handler)
def main(): def main():
# Init stuff # Init stuff