Merge pull request #10 from jmdejong/clearup

properly clean up after crash
pull/11/head
Jake Funke 2018-05-23 12:48:24 -07:00 committed by GitHub
commit 0af9c129ef
2 changed files with 17 additions and 7 deletions

View File

@ -622,7 +622,10 @@ if __name__ == '__main__':
# my_plant is either a fresh plant or an existing plant at this point
my_plant.start_life()
my_data.start_threads(my_plant)
botany_menu = CursedMenu(my_plant,my_data)
my_data.save_plant(my_plant)
my_data.data_write_json(my_plant)
my_data.update_garden_db(my_plant)
try:
botany_menu = CursedMenu(my_plant,my_data)
my_data.save_plant(my_plant)
my_data.data_write_json(my_plant)
my_data.update_garden_db(my_plant)
finally:
cleanup()

View File

@ -670,7 +670,14 @@ class CursedMenu(object):
def __exit__(self):
self.exit = True
curses.curs_set(2)
curses.endwin()
os.system('clear')
cleanup()
def cleanup():
try:
curses.curs_set(2)
except curses.error:
# cursor not supported; just ignore
pass
curses.endwin()
os.system('clear')