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] Add remove and list support. Also make all class methods

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] Add remove and list support. Also make all class methods "safe".
From: Xen patchbot -unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Fri, 09 Sep 2005 17:42:12 +0000
Delivery-date: Fri, 09 Sep 2005 17:40:51 +0000
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/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/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 cl349@xxxxxxxxxxxxxxxxxxxx
# Node ID 1a27091a1e7a5d6b73bf6bbf2d687fc6acc21412
# Parent  54af576824313c4eff97de59691dc4f825f88fd1
Add remove and list support.  Also make all class methods "safe".
Signed-off-by: Christian Limpach <Christian.Limpach@xxxxxxxxxxxx>

diff -r 54af57682431 -r 1a27091a1e7a 
tools/python/xen/xend/xenstore/xstransact.py
--- a/tools/python/xen/xend/xenstore/xstransact.py      Fri Sep  9 17:03:34 2005
+++ b/tools/python/xen/xend/xenstore/xstransact.py      Fri Sep  9 17:34:40 2005
@@ -88,40 +88,81 @@
         else:
             raise TypeError
 
+    def _remove(self, key):
+        path = "%s/%s" % (self.path, key)
+        return xshandle().rm(path)
+
+    def remove(self, *args):
+        if len(args) == 0:
+            raise TypeError
+        for key in args:
+            self._remove(key)
+
+    def _list(self, key):
+        path = "%s/%s" % (self.path, key)
+        return map(lambda x: key + "/" + x, xshandle().ls(path))
+
+    def list(self, *args):
+        if len(args) == 0:
+            raise TypeError
+        ret = []
+        for key in args:
+            ret.extend(self._list(key))
+        return ret
+
+
     def Read(cls, path, *args):
-        t = cls(path)
-        v = t.read(*args)
-        t.commit()
-        return v
-
-    Read = classmethod(Read)
-
-    def Write(cls, path, *args, **opts):
-        t = cls(path)
-        t.write(*args, **opts)
-        t.commit()
-
-    Write = classmethod(Write)
-
-    def SafeRead(cls, path, *args):
         while True:
             try:
-                return cls.Read(path, *args)
+                t = cls(path)
+                v = t.read(*args)
+                t.commit()
+                return v
             except RuntimeError, ex:
                 if ex.args[0] == errno.ETIMEDOUT:
                     pass
                 raise
 
-    SafeRead = classmethod(SafeRead)
+    Read = classmethod(Read)
 
-    def SafeWrite(cls, path, *args, **opts):
+    def Write(cls, path, *args, **opts):
         while True:
             try:
-                cls.Write(path, *args, **opts)
+                t = cls(path)
+                t.write(*args, **opts)
+                t.commit()
                 return
             except RuntimeError, ex:
                 if ex.args[0] == errno.ETIMEDOUT:
                     pass
                 raise
 
-    SafeWrite = classmethod(SafeWrite)
+    Write = classmethod(Write)
+
+    def Remove(cls, *args):
+        while True:
+            try:
+                t = cls(path)
+                t.remove(*args)
+                t.commit()
+                return
+            except RuntimeError, ex:
+                if ex.args[0] == errno.ETIMEDOUT:
+                    pass
+                raise
+
+    Remove = classmethod(Remove)
+
+    def List(cls, path, *args):
+        while True:
+            try:
+                t = cls(path)
+                v = t.list(*args)
+                t.commit()
+                return v
+            except RuntimeError, ex:
+                if ex.args[0] == errno.ETIMEDOUT:
+                    pass
+                raise
+
+    List = classmethod(List)

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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] Add remove and list support. Also make all class methods "safe"., Xen patchbot -unstable <=