[27523] in Source-Commits
python-afs commit: Add the high-level lsmount function
daemon@ATHENA.MIT.EDU (Jonathan D Reed)
Tue Nov 12 18:27:54 2013
Date: Tue, 12 Nov 2013 18:27:47 -0500
From: Jonathan D Reed <jdreed@MIT.EDU>
Message-Id: <201311122327.rACNRlBB018636@drugstore.mit.edu>
To: source-commits@MIT.EDU
https://github.com/mit-athena/python-afs/commits/1c5ab04603b01d3454c33970de75752ed68f102c
commit 1c5ab04603b01d3454c33970de75752ed68f102c
Author: Jonathan Reed <jdreed@mit.edu>
Date: Tue Oct 29 14:53:19 2013 -0400
Add the high-level lsmount function
Change the import statement for afs._fs to import *, now that
we have defined __all__.
Add the high-level lsmount function.
afs/fs.py | 17 ++++++++++++++++-
1 files changed, 16 insertions(+), 1 deletions(-)
diff --git a/afs/fs.py b/afs/fs.py
index 02c2756..6106508 100644
--- a/afs/fs.py
+++ b/afs/fs.py
@@ -1,6 +1,7 @@
import errno
+import os.path
from afs import _fs
-from afs._fs import whichcell
+from afs._fs import *
def inafs(path):
"""Return True if a path is in AFS."""
@@ -11,3 +12,17 @@ def inafs(path):
return False
return True
+
+def lsmount(path):
+ """Return a volume name for a mountpoint."""
+ # os.path.realpath will take care of ensuring we don't
+ # get back anything that ends in . or .., and will
+ # strip off any trailing slash
+ (dirname, basename) = os.path.split(os.path.realpath(path))
+ try:
+ return _lsmount(dirname, basename)
+ except OSError as e:
+ if e.errno == errno.EINVAL:
+ return None
+ else:
+ raise