xm: Add exception handling when launching vncviewer
authorKeir Fraser <keir.fraser@citrix.com>
Thu, 6 May 2010 10:13:22 +0000 (11:13 +0100)
committerKeir Fraser <keir.fraser@citrix.com>
Thu, 6 May 2010 10:13:22 +0000 (11:13 +0100)
Also replaces the call to 'puts' with 'print' as the former is
undefined in python

Signed-off-by: Goncalo Gomes <Goncalo.Gomes@eu.Citrix.com>
tools/python/xen/xm/console.py

index f31d561836888cc5d98716487b86bb56908dff63..ce86369c63bb6fc50980df6a3068e5a13c86663c 100644 (file)
@@ -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)