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-3.4-testing] xend: Avoid deprecation warnings with

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-3.4-testing] xend: Avoid deprecation warnings with Python 2.6.
From: "Xen patchbot-3.4-testing" <patchbot-3.4-testing@xxxxxxxxxxxxxxxxxxx>
Date: Tue, 02 Jun 2009 22:10:16 -0700
Delivery-date: Thu, 11 Jun 2009 08:04:03 -0700
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.fraser@xxxxxxxxxx>
# Date 1243863181 -3600
# Node ID e29cc855022599dbb9516e42b8f1eaa2676efca6
# Parent  db5b665e9a5d78716654fa7617f8bc2c1dda4d49
xend: Avoid deprecation warnings with Python 2.6.

Signed-off-by: Brendan Cully <brendan@xxxxxxxxx>
xen-unstable changeset:   19609:4d6029814742
xen-unstable date:        Tue May 19 01:34:34 2009 +0100
---
 tools/python/xen/util/acmpolicy.py |   13 ++++++++++---
 tools/python/xen/xend/XendAPI.py   |   16 +++++++++++-----
 2 files changed, 21 insertions(+), 8 deletions(-)

diff -r db5b665e9a5d -r e29cc8550225 tools/python/xen/util/acmpolicy.py
--- a/tools/python/xen/util/acmpolicy.py        Mon Jun 01 14:32:31 2009 +0100
+++ b/tools/python/xen/util/acmpolicy.py        Mon Jun 01 14:33:01 2009 +0100
@@ -17,12 +17,19 @@
 #============================================================================
 
 import os
-import sha
 import stat
 import array
 import struct
 import shutil
 import commands
+
+# sha is deprecated as of python 2.6
+try:
+    from hashlib import sha1
+except ImportError:
+    # but hashlib was only added in python 2.5
+    from sha import new as sha1
+
 from xml.dom import minidom, Node
 from xen.xend.XendLogging import log
 from xen.util import xsconstants, bootloader, mkdir
@@ -1102,8 +1109,8 @@ class ACMPolicy(XSPolicy):
         return None
 
     def hash(self):
-        """ Calculate a SAH1 hash of the XML policy """
-        return sha.sha(self.toxml())
+        """ Calculate a SHA1 hash of the XML policy """
+        return sha1(self.toxml())
 
     def save(self):
         ### Save the XML policy into a file ###
diff -r db5b665e9a5d -r e29cc8550225 tools/python/xen/xend/XendAPI.py
--- a/tools/python/xen/xend/XendAPI.py  Mon Jun 01 14:32:31 2009 +0100
+++ b/tools/python/xen/xend/XendAPI.py  Mon Jun 01 14:33:01 2009 +0100
@@ -18,13 +18,18 @@ import inspect
 import inspect
 import os
 import Queue
-import sets
 import string
 import sys
 import traceback
 import threading
 import time
 import xmlrpclib
+
+# sets is deprecated as of python 2.6, but set is unavailable in 2.3
+try:
+    set
+except NameError:
+    from sets import Set as set
 
 import XendDomain, XendDomainInfo, XendNode, XendDmesg
 import XendLogging, XendTaskManager, XendAPIStore
@@ -119,16 +124,17 @@ def event_register(session, reg_classes)
 def event_register(session, reg_classes):
     if session not in event_registrations:
         event_registrations[session] = {
-            'classes' : sets.Set(),
+            'classes' : set(),
             'queue'   : Queue.Queue(EVENT_QUEUE_LENGTH),
             'next-id' : 1
             }
     if not reg_classes:
         reg_classes = classes
-    if hasattr(set, 'union_update'):
-        event_registrations[session]['classes'].union_update(reg_classes)
+    sessionclasses = event_registrations[session]['classes']
+    if hasattr(sessionclasses, 'union_update'):
+        sessionclasses.union_update(reg_classes)
     else:
-        event_registrations[session]['classes'].update(reg_classes)
+        sessionclasses.update(reg_classes)
 
 
 

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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-3.4-testing] xend: Avoid deprecation warnings with Python 2.6., Xen patchbot-3.4-testing <=