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-changelog

[Xen-changelog] [xen-4.0-testing] tools/python: Replace python string ex

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-4.0-testing] tools/python: Replace python string exceptions with ValueError exceptions
From: "Xen patchbot-4.0-testing" <patchbot-4.0-testing@xxxxxxxxxxxxxxxxxxx>
Date: Thu, 23 Dec 2010 11:35:30 -0800
Delivery-date: Thu, 23 Dec 2010 11:38:18 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Keir Fraser <keir@xxxxxxx>
# Date 1292608560 0
# Node ID 938d1fc2935e3f3b73f6d2dc46bb4d78ca5fd3df
# Parent  af7110f4f80307413cec60ae4191d6863ba1b540
tools/python: Replace python string exceptions with ValueError exceptions

There are at least some syntax errors when trying to use the xen utils
with python2.6.  The attached patch changes these string exception
into ValueErrors:

   - tools/python/xen/util/bugtool.py (getBugTitle)
   - tools/python/xen/xend (class XendBase): not catched
   - tools/python/xen/xm/xenapi_create.py (sxp2xmlconvert_sxp_to_xml):
     the method already raises a ValueError for similiar condition.
   - tools/python/xen/xm/main.py (xm_network_attach): not catched.

For all but maybe the first one, the replacement of the string
exceptions into ValueErrors seems to be safe.

Signed-off-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
xen-unstable changeset:   22153:95c90bd63aed
xen-unstable date:        Tue Sep 14 17:46:21 2010 +0100
---
 tools/python/xen/util/bugtool.py     |    2 +-
 tools/python/xen/xend/XendBase.py    |    2 +-
 tools/python/xen/xm/main.py          |    2 +-
 tools/python/xen/xm/xenapi_create.py |    2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

diff -r af7110f4f803 -r 938d1fc2935e tools/python/xen/util/bugtool.py
--- a/tools/python/xen/util/bugtool.py  Fri Dec 17 16:13:54 2010 +0000
+++ b/tools/python/xen/util/bugtool.py  Fri Dec 17 17:56:00 2010 +0000
@@ -141,7 +141,7 @@ def getBugTitle(bug):
     finally:
         f.close()
 
-    raise "Could not find title of bug %d!" % bug
+    raise ValueError("Could not find title of bug %d!" % bug)
 
 
 def send(bug, conn, fd, filename, username, password):
diff -r af7110f4f803 -r 938d1fc2935e tools/python/xen/xend/XendBase.py
--- a/tools/python/xen/xend/XendBase.py Fri Dec 17 16:13:54 2010 +0000
+++ b/tools/python/xen/xend/XendBase.py Fri Dec 17 17:56:00 2010 +0000
@@ -115,7 +115,7 @@ class XendBase:
             # In OSS, ref == uuid
             return uuid
         else:
-            raise "Big Error.. TODO!"
+            raise ValueError("Big Error.. TODO!")
 
     def get_all_records(cls):
         return dict([(inst.get_uuid(), inst.get_record())
diff -r af7110f4f803 -r 938d1fc2935e tools/python/xen/xm/main.py
--- a/tools/python/xen/xm/main.py       Fri Dec 17 16:13:54 2010 +0000
+++ b/tools/python/xen/xm/main.py       Fri Dec 17 17:56:00 2010 +0000
@@ -2616,7 +2616,7 @@ def xm_network_attach(args):
                              for ref, record in server.xenapi.network
                              .get_all_records().items()])
             if bridge not in networks.keys():
-                raise "Unknown bridge name!"
+                raise ValueError("Unknown bridge name!")
             return networks[bridge]
 
         vif_conv = {
diff -r af7110f4f803 -r 938d1fc2935e tools/python/xen/xm/xenapi_create.py
--- a/tools/python/xen/xm/xenapi_create.py      Fri Dec 17 16:13:54 2010 +0000
+++ b/tools/python/xen/xm/xenapi_create.py      Fri Dec 17 17:56:00 2010 +0000
@@ -703,7 +703,7 @@ class sxp2xml:
                 vm.attributes['security_label'] = \
                                     
security.set_security_label(sec_data[0][1][1],sec_data[0][2][1])
             except Exception, e:
-                raise "Invalid security data format: %s" % str(sec_data)
+                raise ValueError("Invalid security data format: %s" % 
str(sec_data))
 
         # Make the name tag
 

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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-4.0-testing] tools/python: Replace python string exceptions with ValueError exceptions, Xen patchbot-4.0-testing <=