From: emellor@leeni.uk.xensource.com Date: Tue, 23 May 2006 15:14:49 +0000 (+0100) Subject: Added get_permissions implementation. X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~16025^2~32 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=43af8d669fedab1e514512104e471e5077ceb339;p=xen.git Added get_permissions implementation. Signed-off-by: Ewan Mellor --- diff --git a/tools/python/xen/xend/xenstore/xstransact.py b/tools/python/xen/xend/xenstore/xstransact.py index b7a8692185..c6a3bb9d82 100644 --- a/tools/python/xen/xend/xenstore/xstransact.py +++ b/tools/python/xen/xend/xenstore/xstransact.py @@ -221,6 +221,34 @@ class xstransact: xshandle().mkdir(self.transaction, self.prependPath(key)) + def get_permissions(self, *args): + """If no arguments are given, return the permissions at this + transaction's path. If one argument is given, treat that argument as + a subpath to this transaction's path, and return the permissions at + that path. Otherwise, treat each argument as a subpath to this + transaction's path, and return a list composed of the permissions at + each of those instead. + """ + if len(args) == 0: + return xshandle().get_permissions(self.transaction, self.path) + if len(args) == 1: + return self._get_permissions(args[0]) + ret = [] + for key in args: + ret.append(self._get_permissions(key)) + return ret + + + def _get_permissions(self, key): + path = self.prependPath(key) + try: + return xshandle().get_permissions(self.transaction, path) + except RuntimeError, ex: + raise RuntimeError(ex.args[0], + '%s, while getting permissions from %s' % + (ex.args[1], path)) + + def set_permissions(self, *args): if len(args) == 0: raise TypeError