exit gracefully on ctrlc
This commit is contained in:
parent
7fd6b6ab51
commit
7038e8f852
@ -87,11 +87,13 @@ class CommandLine:
|
|||||||
p = self.prompt()
|
p = self.prompt()
|
||||||
try:
|
try:
|
||||||
c = input(p)
|
c = input(p)
|
||||||
except EOFError:
|
except (EOFError, KeyboardInterrupt):
|
||||||
self.handle_eof()
|
self.handle_eof()
|
||||||
break
|
break
|
||||||
try:
|
try:
|
||||||
self.handle_cmd(c)
|
self.handle_cmd(c)
|
||||||
except Exception as e:
|
except KeyboardInterrupt:
|
||||||
|
print("Interrupted")
|
||||||
|
except (Exception) as e:
|
||||||
logging.error(e, exc_info=True)
|
logging.error(e, exc_info=True)
|
||||||
|
|
||||||
|
@ -24,6 +24,10 @@ class Commander(CommandLine):
|
|||||||
self.stop_auto= False
|
self.stop_auto= False
|
||||||
super().__init__()
|
super().__init__()
|
||||||
|
|
||||||
|
def handle_eof(self):
|
||||||
|
self.store.close()
|
||||||
|
print("Goodbye!")
|
||||||
|
|
||||||
def prompt(self):
|
def prompt(self):
|
||||||
if self.ship:
|
if self.ship:
|
||||||
return f'{self.ship.symbol}> '
|
return f'{self.ship.symbol}> '
|
||||||
|
Loading…
Reference in New Issue
Block a user