WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

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

To: "'xen-devel@xxxxxxxxxxxxxxxxxxx'" <xen-devel@xxxxxxxxxxxxxxxxxxx>
Subject: [Xen-devel] [PATCH] Add exception handling when launching vncviewer
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
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
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
<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-devel] [PATCH] Add exception handling when launching vncviewer, Goncalo Gomes <=