Skip to content

Commit

Permalink
Handle keyboard interrupt and exit gracefully
Browse files Browse the repository at this point in the history
  • Loading branch information
dnaeon committed Apr 15, 2015
1 parent d68995d commit 0c1cb70
Showing 1 changed file with 22 additions and 9 deletions.
31 changes: 22 additions & 9 deletions src/pvc/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,19 +141,32 @@ def login(self):
text='Failed to login to {}\n\n{}\n'.format(self.agent.host, msg)
)

def run(self):
self.about()
if not self.login():
return
def disconnect(self):
"""
Disconnect from the remote vSphere host
home = pvc.widget.home.HomeWidget(
agent=self.agent,
dialog=self.dialog
)
home.display()
"""
if not self.agent:
return

self.dialog.infobox(
title='Disconnecting Connection',
text='Disconnecting from {} ...'.format(self.agent.host)
)
self.agent.disconnect()

def run(self):
try:
self.about()
if not self.login():
return

home = pvc.widget.home.HomeWidget(
agent=self.agent,
dialog=self.dialog
)
home.display()
except KeyboardInterrupt:
pass
finally:
self.disconnect()

0 comments on commit 0c1cb70

Please sign in to comment.