diff options
author | Keir Fraser <keir.fraser@citrix.com> | 2009-05-19 01:34:34 +0100 |
---|---|---|
committer | Keir Fraser <keir.fraser@citrix.com> | 2009-05-19 01:34:34 +0100 |
commit | fdaaa5fe16b80537af735462993877658dff4869 (patch) | |
tree | 746d965ef4695f76de44e2ea17cd931a57eb727e /tools | |
parent | f7a4f4101decbb3a9b977e79cd5ebe6e200e3fc5 (diff) | |
download | xen-fdaaa5fe16b80537af735462993877658dff4869.tar.gz xen-fdaaa5fe16b80537af735462993877658dff4869.tar.bz2 xen-fdaaa5fe16b80537af735462993877658dff4869.zip |
xend: Avoid deprecation warnings with Python 2.6.
Signed-off-by: Brendan Cully <brendan@cs.ubc.ca>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/python/xen/util/acmpolicy.py | 13 | ||||
-rw-r--r-- | tools/python/xen/xend/XendAPI.py | 16 |
2 files changed, 21 insertions, 8 deletions
diff --git a/tools/python/xen/util/acmpolicy.py b/tools/python/xen/util/acmpolicy.py index 1a95c3a2d5..6752169c7b 100644 --- a/tools/python/xen/util/acmpolicy.py +++ b/tools/python/xen/util/acmpolicy.py @@ -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 --git a/tools/python/xen/xend/XendAPI.py b/tools/python/xen/xend/XendAPI.py index 07e6b2100e..6dda3a9c79 100644 --- a/tools/python/xen/xend/XendAPI.py +++ b/tools/python/xen/xend/XendAPI.py @@ -18,7 +18,6 @@ import inspect import os import Queue -import sets import string import sys import traceback @@ -26,6 +25,12 @@ 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 @@ event_registrations = {} 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) |