# HG changeset patch
# User emellor@ewan
# Node ID 578a73fdeb2f3b76f83ad167691e07385e0f623e
# Parent f7a09745ca56a31e1ed8d52ee8c936ef69704948
Changed dangerous default parameter values where used to use None instead.
Renamed variables type and ord since these clash with built-in names. Renamed
unused variables to mark them as such. Changed scheduler.py to use *args and
**kwargs rather than the strange non-idiomatic imitation of the same.
Signed-off-by: Ewan Mellor <ewan@xxxxxxxxxxxxx>
diff -r f7a09745ca56 -r 578a73fdeb2f tools/python/xen/xend/Args.py
--- a/tools/python/xen/xend/Args.py Sun Sep 18 17:21:12 2005
+++ b/tools/python/xen/xend/Args.py Sun Sep 18 21:41:12 2005
@@ -32,12 +32,12 @@
self.arg_dict = {}
self.key_ord = []
self.key_dict = {}
- for (name, type) in paramspec:
+ for (name, typ) in paramspec:
self.arg_ord.append(name)
- self.arg_dict[name] = type
- for (name, type) in keyspec:
+ self.arg_dict[name] = typ
+ for (name, typ) in keyspec:
self.key_ord.append(name)
- self.key_dict[name] = type
+ self.key_dict[name] = typ
def get_args(self, d, xargs=None):
args = {}
@@ -56,12 +56,12 @@
def split_args(self, d, args, keys):
for (k, v) in d.items():
if k in self.arg_dict:
- type = self.arg_dict[k]
- val = self.coerce(type, v)
+ typ = self.arg_dict[k]
+ val = self.coerce(typ, v)
args[k] = val
elif k in self.key_dict:
- type = self.key_dict[k]
- val = self.coerce(type, v)
+ typ = self.key_dict[k]
+ val = self.coerce(typ, v)
keys[k] = val
else:
raise ArgError('Invalid parameter: %s' % k)
@@ -85,20 +85,20 @@
d[k] = val
return self.get_args(d, xargs=xargs)
- def coerce(self, type, v):
+ def coerce(self, typ, v):
try:
- if type == 'int':
+ if typ == 'int':
val = int(v)
- elif type == 'long':
+ elif typ == 'long':
val = long(v)
- elif type == 'str':
+ elif typ == 'str':
val = str(v)
- elif type == 'sxpr':
+ elif typ == 'sxpr':
val = self.sxpr(v)
- elif type == 'bool':
+ elif typ == 'bool':
val = self.bool(v)
else:
- raise ArgError('invalid type:' + str(type))
+ raise ArgError('invalid type:' + str(typ))
return val
except ArgError:
raise
@@ -142,7 +142,9 @@
Used on the client.
"""
- def __init__(self, fn, paramspec, keyspec={}):
+ def __init__(self, fn, paramspec, keyspec = None):
+ if keyspec == None:
+ keyspec = {}
Args.__init__(self, paramspec, keyspec)
self.fn = fn
@@ -154,7 +156,9 @@
Used in the HTTP server.
"""
- def __init__(self, fn, paramspec, keyspec={}):
+ def __init__(self, fn, paramspec, keyspec = None):
+ if keyspec == None:
+ keyspec = {}
Args.__init__(self, paramspec, keyspec)
self.fn = fn
diff -r f7a09745ca56 -r 578a73fdeb2f tools/python/xen/xend/EventServer.py
--- a/tools/python/xen/xend/EventServer.py Sun Sep 18 17:21:12 2005
+++ b/tools/python/xen/xend/EventServer.py Sun Sep 18 21:41:12 2005
@@ -145,7 +145,7 @@
self.lock.release()
if async:
- scheduler.now(self.call_handlers, [event, val])
+ scheduler.now(self.call_handlers, event, val)
else:
self.call_handlers(event, val)
diff -r f7a09745ca56 -r 578a73fdeb2f tools/python/xen/xend/Vifctl.py
--- a/tools/python/xen/xend/Vifctl.py Sun Sep 18 17:21:12 2005
+++ b/tools/python/xen/xend/Vifctl.py Sun Sep 18 21:41:12 2005
@@ -13,13 +13,13 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#============================================================================
# Copyright (C) 2004, 2005 Mike Wray <mike.wray@xxxxxx>
+# Copyright (C) 2005 XenSource Ltd
#============================================================================
"""Xend interface to networking control scripts.
"""
import os
import os.path
-import sys
import xen.util.process
from xen.xend import XendRoot
@@ -71,7 +71,7 @@
vif = vif_old
return vif
-def vifctl(op, vif=None, script=None, domain=None, mac=None, bridge=None,
ipaddr=[]):
+def vifctl(op, vif=None, script=None, domain=None, mac=None, bridge=None,
ipaddr=None):
"""Call a vif control script.
Xend calls this when bringing vifs up or down.
diff -r f7a09745ca56 -r 578a73fdeb2f tools/python/xen/xend/scheduler.py
--- a/tools/python/xen/xend/scheduler.py Sun Sep 18 17:21:12 2005
+++ b/tools/python/xen/xend/scheduler.py Sun Sep 18 21:41:12 2005
@@ -13,11 +13,12 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#============================================================================
# Copyright (C) 2004, 2005 Mike Wray <mike.wray@xxxxxx>
+# Copyright (C) 2005 XenSource Ltd
#============================================================================
import threading
-def later(delay, fn, args=(), kwargs={}):
+def later(delay, fn, *args, **kwargs):
"""Schedule a function to be called later.
@param delay: delay in seconds
@@ -29,7 +30,7 @@
timer.start()
return timer
-def now(fn, args=(), kwargs={}):
+def now(fn, *args, **kwargs):
"""Schedule a function to be called now.
@param fn: function
diff -r f7a09745ca56 -r 578a73fdeb2f tools/python/xen/xend/xenstore/xswatch.py
--- a/tools/python/xen/xend/xenstore/xswatch.py Sun Sep 18 17:21:12 2005
+++ b/tools/python/xen/xend/xenstore/xswatch.py Sun Sep 18 21:41:12 2005
@@ -1,4 +1,5 @@
# Copyright (C) 2005 Christian Limpach <Christian.Limpach@xxxxxxxxxxxx>
+# Copyright (C) 2005 XenSource Ltd
# This file is subject to the terms and conditions of the GNU General
# Public License. See the file "COPYING" in the main directory of
@@ -15,7 +16,7 @@
xs = None
xslock = threading.Lock()
- def __init__(self, path, fn, args=(), kwargs={}):
+ def __init__(self, path, fn, *args, **kwargs):
self.fn = fn
self.args = args
self.kwargs = kwargs
@@ -46,11 +47,11 @@
cls.threadcond.release()
while True:
try:
- (ord, owr, oer) = select.select([ cls.xs ], [], [])
+ (fd, _1, _2) = select.select([ cls.xs ], [], [])
cls.xslock.acquire()
# reconfirm ready to read with lock
- (ord, owr, oer) = select.select([ cls.xs ], [], [], 0.001)
- if not cls.xs in ord:
+ (fd, _1, _2) = select.select([ cls.xs ], [], [], 0.001)
+ if not cls.xs in fd:
cls.xslock.release()
continue
we = cls.xs.read_watch()
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog
|