# HG changeset patch
# User cl349@xxxxxxxxxxxxxxxxxxxx
# Node ID f92bdd9153f54583512635ced9d5a8812233f29e
# Parent d5497a2156608e05dc2deabd91c73604afe6c813
Add store function.
Signed-off-by: Christian Limpach <Christian.Limpach@xxxxxxxxxxxx>
diff -r d5497a215660 -r f92bdd9153f5
tools/python/xen/xend/xenstore/xstransact.py
--- a/tools/python/xen/xend/xenstore/xstransact.py Wed Sep 14 19:17:22 2005
+++ b/tools/python/xen/xend/xenstore/xstransact.py Wed Sep 14 19:22:31 2005
@@ -121,6 +121,20 @@
return ret[0]
return ret
+ def store(self, *args):
+ for tup in args:
+ if len(tup) == 2:
+ (key, val) = tup
+ try:
+ fmt = { str : "%s",
+ int : "%i",
+ float : "%f" }[type(val)]
+ except KeyError:
+ raise TypeError
+ else:
+ (key, val, fmt) = tup
+ self.write(key, fmt % val)
+
def Read(cls, path, *args):
while True:
@@ -216,3 +230,22 @@
raise
Gather = classmethod(Gather)
+
+ def Store(cls, path, *args):
+ while True:
+ try:
+ t = cls(path)
+ v = t.store(*args)
+ t.commit()
+ return v
+ except RuntimeError, ex:
+ t.abort()
+ if ex.args[0] == errno.ETIMEDOUT:
+ pass
+ else:
+ raise
+ except:
+ t.abort()
+ raise
+
+ Store = classmethod(Store)
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog
|