From 85bef2cc8dec14b5e89b2e5bbaf31b0cd2281f18 Mon Sep 17 00:00:00 2001 From: Keir Fraser Date: Mon, 10 May 2010 09:49:33 +0100 Subject: [PATCH] xm: Add exception handling when launching vncviewer Also replaces the call to 'puts' with 'print' as the former is undefined in python Signed-off-by: Goncalo Gomes xen-unstable changeset: 21296:460d156da874 xen-unstable date: Thu May 06 11:13:22 2010 +0100 --- tools/python/xen/xm/console.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tools/python/xen/xm/console.py b/tools/python/xen/xm/console.py index f31d561836..ce86369c63 100644 --- a/tools/python/xen/xm/console.py +++ b/tools/python/xen/xm/console.py @@ -74,10 +74,15 @@ def runVncViewer(domid, do_autopass, do_daemonize=False): if do_daemonize: pid = utils.daemonize('vncviewer', cmdl, vnc_password_tmpfile) if pid == 0: - puts >>sys.stderr, 'failed to invoke vncviewer' + print >>sys.stderr, 'failed to invoke vncviewer' os._exit(-1) else: print 'invoking ', ' '.join(cmdl) if vnc_password_tmpfile is not None: os.dup2(vnc_password_tmpfile.fileno(), 0) - os.execvp('vncviewer', cmdl) + try: + os.execvp('vncviewer', cmdl) + except OSError: + print >>sys.stderr, 'Error: external vncviewer missing or not \ +in the path\nExiting' + os._exit(-1)