[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH] Add exception handling when launching vncviewer


  • To: "'xen-devel@xxxxxxxxxxxxxxxxxxx'" <xen-devel@xxxxxxxxxxxxxxxxxxx>
  • From: Goncalo Gomes <Goncalo.Gomes@xxxxxxxxxxxxx>
  • Date: Wed, 5 May 2010 11:47:18 +0100
  • Accept-language: en-US
  • Acceptlanguage: en-US
  • Delivery-date: Wed, 05 May 2010 03:50:17 -0700
  • List-id: Xen developer discussion <xen-devel.lists.xensource.com>
  • Thread-index: AcrsBnicTgmfx8kYTbCud5pN7gmgyAAOOLTA
  • Thread-topic: [PATCH] Add exception handling when launching vncviewer

The attached patch:

1. Replaces the call to 'puts' with 'print' as the former is undefined in python

2. Adds exception handling when attempting to execute a missing vncviewer and 
prints convenient information.


Cheers,
 -Goncalo.


Signed-off-by: Goncalo Gomes <Goncalo.Gomes@xxxxxxxxxxxxx>

diff -r efa1b905d893 tools/python/xen/xm/console.py
--- a/tools/python/xen/xm/console.py    Tue May 04 13:59:55 2010 +0100
+++ b/tools/python/xen/xm/console.py    Wed May 05 04:39:18 2010 +0100
@@ -74,10 +74,15 @@
     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)

Attachment: console.diff
Description: console.diff

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.