mirror of
https://github.com/xen-project/xen.git
synced 2026-10-29 10:40:03 +01:00
xend: Avoid deprecation warnings with Python 2.6.
Signed-off-by: Brendan Cully <brendan@cs.ubc.ca>
This commit is contained in:
1 parent
f7a4f4101d
commit
fdaaa5fe16
2 files changed
+21
-8
No files matched your search
@@ -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 ###
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
|
||||
|
||||