Commit 250ce7d9 by rfkelly0

rename TahoeFS => TahoeLAFS for consistency with upstream project naming

parent d1cdcd50
''' '''
fs.contrib.tahoefs fs.contrib.tahoelafs
================== ====================
Example (it will use publicly available, but slow-as-hell Tahoe-LAFS cloud):: Example (it will use publicly available, but slow-as-hell Tahoe-LAFS cloud)::
from fs.contrib.tahoefs import TahoeFS, Connection from fs.contrib.tahoelafs import TahoeLAFS, Connection
dircap = TahoeFS.createdircap(webapi='http://pubgrid.tahoe-lafs.org') dircap = TahoeLAFS.createdircap(webapi='http://pubgrid.tahoe-lafs.org')
print "Your dircap (unique key to your storage directory) is", dircap print "Your dircap (unique key to your storage directory) is", dircap
print "Keep it safe!" print "Keep it safe!"
fs = TahoeFS(dircap, autorun=False, timeout=300, webapi='http://pubgrid.tahoe-lafs.org') fs = TahoeLAFS(dircap, autorun=False, timeout=300, webapi='http://pubgrid.tahoe-lafs.org')
f = fs.open("foo.txt", "a") f = fs.open("foo.txt", "a")
f.write('bar!') f.write('bar!')
f.close() f.close()
...@@ -21,7 +21,7 @@ When any problem occurred, you can turn on internal debugging messages:: ...@@ -21,7 +21,7 @@ When any problem occurred, you can turn on internal debugging messages::
l.setLevel(logging.DEBUG) l.setLevel(logging.DEBUG)
l.addHandler(logging.StreamHandler(sys.stdout)) l.addHandler(logging.StreamHandler(sys.stdout))
... your Python code using TahoeFS ... ... your Python code using TahoeLAFS ...
TODO: TODO:
...@@ -39,7 +39,7 @@ TODO: ...@@ -39,7 +39,7 @@ TODO:
* python3 support * python3 support
* remove creating blank files (depends on FileUploadManager) * remove creating blank files (depends on FileUploadManager)
TODO (Not TahoeFS specific tasks): TODO (Not TahoeLAFS specific tasks):
* RemoteFileBuffer on the fly buffering support * RemoteFileBuffer on the fly buffering support
* RemoteFileBuffer unit tests * RemoteFileBuffer unit tests
* RemoteFileBuffer submit to trunk * RemoteFileBuffer submit to trunk
...@@ -64,7 +64,7 @@ from fs.base import fnmatch, NoDefaultMeta ...@@ -64,7 +64,7 @@ from fs.base import fnmatch, NoDefaultMeta
from util import TahoeUtil from util import TahoeUtil
from connection import Connection from connection import Connection
logger = fs.getLogger('fs.tahoefs') logger = fs.getLogger('fs.tahoelafs')
def _fix_path(func): def _fix_path(func):
"""Method decorator for automatically normalising paths.""" """Method decorator for automatically normalising paths."""
...@@ -82,12 +82,12 @@ def _fixpath(path): ...@@ -82,12 +82,12 @@ def _fixpath(path):
class _TahoeFS(FS): class _TahoeLAFS(FS):
"""FS providing raw access to a Tahoe Filesystem. """FS providing raw access to a Tahoe-LAFS Filesystem.
This class implements all the details of interacting with a Tahoe-backed This class implements all the details of interacting with a Tahoe-backed
filesystem, but you probably don't want to use it in practice. Use the filesystem, but you probably don't want to use it in practice. Use the
TahoeFS class instead, which has some internal caching to improve TahoeLAFS class instead, which has some internal caching to improve
performance. performance.
""" """
...@@ -100,7 +100,7 @@ class _TahoeFS(FS): ...@@ -100,7 +100,7 @@ class _TahoeFS(FS):
def __init__(self, dircap, largefilesize=10*1024*1024, webapi='http://127.0.0.1:3456'): def __init__(self, dircap, largefilesize=10*1024*1024, webapi='http://127.0.0.1:3456'):
'''Creates instance of TahoeFS. '''Creates instance of TahoeLAFS.
:param dircap: special hash allowing user to work with TahoeLAFS directory. :param dircap: special hash allowing user to work with TahoeLAFS directory.
:param largefilesize: - Create placeholder file for files larger than this treshold. :param largefilesize: - Create placeholder file for files larger than this treshold.
...@@ -112,10 +112,10 @@ class _TahoeFS(FS): ...@@ -112,10 +112,10 @@ class _TahoeFS(FS):
self.largefilesize = largefilesize self.largefilesize = largefilesize
self.connection = Connection(webapi) self.connection = Connection(webapi)
self.tahoeutil = TahoeUtil(webapi) self.tahoeutil = TahoeUtil(webapi)
super(_TahoeFS, self).__init__(thread_synchronize=_thread_synchronize_default) super(_TahoeLAFS, self).__init__(thread_synchronize=_thread_synchronize_default)
def __str__(self): def __str__(self):
return "<TahoeFS: %s>" % self.dircap return "<TahoeLAFS: %s>" % self.dircap
@classmethod @classmethod
def createdircap(cls, webapi='http://127.0.0.1:3456'): def createdircap(cls, webapi='http://127.0.0.1:3456'):
...@@ -124,7 +124,7 @@ class _TahoeFS(FS): ...@@ -124,7 +124,7 @@ class _TahoeFS(FS):
def getmeta(self,meta_name,default=NoDefaultMeta): def getmeta(self,meta_name,default=NoDefaultMeta):
if meta_name == "read_only": if meta_name == "read_only":
return self.dircap.startswith('URI:DIR2-RO') return self.dircap.startswith('URI:DIR2-RO')
return super(_TahoeFS,self).getmeta(meta_name,default) return super(_TahoeLAFS,self).getmeta(meta_name,default)
@_fix_path @_fix_path
def open(self, path, mode='r', **kwargs): def open(self, path, mode='r', **kwargs):
...@@ -317,14 +317,14 @@ class _TahoeFS(FS): ...@@ -317,14 +317,14 @@ class _TahoeFS(FS):
if self.getmeta("read_only"): if self.getmeta("read_only"):
raise errors.UnsupportedError('read only filesystem') raise errors.UnsupportedError('read only filesystem')
# FIXME: this is out of date; how to do native tahoe copy? # FIXME: this is out of date; how to do native tahoe copy?
# FIXME: Workaround because isfile() not exists on _TahoeFS # FIXME: Workaround because isfile() not exists on _TahoeLAFS
FS.copy(self, src, dst, overwrite, chunk_size) FS.copy(self, src, dst, overwrite, chunk_size)
def copydir(self, src, dst, overwrite=False, ignore_errors=False, chunk_size=16384): def copydir(self, src, dst, overwrite=False, ignore_errors=False, chunk_size=16384):
if self.getmeta("read_only"): if self.getmeta("read_only"):
raise errors.UnsupportedError('read only filesystem') raise errors.UnsupportedError('read only filesystem')
# FIXME: this is out of date; how to do native tahoe copy? # FIXME: this is out of date; how to do native tahoe copy?
# FIXME: Workaround because isfile() not exists on _TahoeFS # FIXME: Workaround because isfile() not exists on _TahoeLAFS
FS.copydir(self, src, dst, overwrite, ignore_errors, chunk_size) FS.copydir(self, src, dst, overwrite, ignore_errors, chunk_size)
...@@ -369,7 +369,7 @@ class _TahoeFS(FS): ...@@ -369,7 +369,7 @@ class _TahoeFS(FS):
if size > self.largefilesize: if size > self.largefilesize:
self.connection.put(u'/uri/%s%s' % (self.dircap, path), self.connection.put(u'/uri/%s%s' % (self.dircap, path),
"PyFilesystem.TahoeFS: Upload started, final size %d" % size) "PyFilesystem.TahoeLAFS: Upload started, final size %d" % size)
self.connection.put(u'/uri/%s%s' % (self.dircap, path), file, size=size) self.connection.put(u'/uri/%s%s' % (self.dircap, path), file, size=size)
...@@ -389,7 +389,7 @@ class _TahoeFS(FS): ...@@ -389,7 +389,7 @@ class _TahoeFS(FS):
class TahoeFS(CacheFSMixin,_TahoeFS): class TahoeLAFS(CacheFSMixin,_TahoeLAFS):
"""FS providing cached access to a Tahoe Filesystem. """FS providing cached access to a Tahoe Filesystem.
This class is the preferred means to access a Tahoe filesystem. It This class is the preferred means to access a Tahoe filesystem. It
...@@ -399,6 +399,6 @@ class TahoeFS(CacheFSMixin,_TahoeFS): ...@@ -399,6 +399,6 @@ class TahoeFS(CacheFSMixin,_TahoeFS):
def __init__(self, *args, **kwds): def __init__(self, *args, **kwds):
kwds.setdefault("cache_timeout",60) kwds.setdefault("cache_timeout",60)
super(TahoeFS,self).__init__(*args,**kwds) super(TahoeLAFS,self).__init__(*args,**kwds)
#!/usr/bin/python #!/usr/bin/python
""" """
Test the TahoeFS Test the TahoeLAFS
@author: Marek Palatinus <marek@palatinus.cz> @author: Marek Palatinus <marek@palatinus.cz>
""" """
...@@ -12,21 +12,21 @@ import unittest ...@@ -12,21 +12,21 @@ import unittest
from fs.base import FS from fs.base import FS
import fs.errors as errors import fs.errors as errors
from fs.tests import FSTestCases, ThreadingTestCases from fs.tests import FSTestCases, ThreadingTestCases
from fs.contrib.tahoefs import TahoeFS, Connection from fs.contrib.tahoefs import TahoeLAFS, Connection
logging.getLogger().setLevel(logging.DEBUG) logging.getLogger().setLevel(logging.DEBUG)
logging.getLogger('fs.tahoefs').addHandler(logging.StreamHandler(sys.stdout)) logging.getLogger('fs.tahoefs').addHandler(logging.StreamHandler(sys.stdout))
WEBAPI = 'http://pubgrid.tahoe-lafs.org' WEBAPI = 'http://pubgrid.tahoe-lafs.org'
class TestTahoeFS(unittest.TestCase,FSTestCases,ThreadingTestCases): class TestTahoeLAFS(unittest.TestCase,FSTestCases,ThreadingTestCases):
# Disabled by default because it takes a *really* long time. # Disabled by default because it takes a *really* long time.
__test__ = False __test__ = False
def setUp(self): def setUp(self):
self.dircap = TahoeFS.createdircap(WEBAPI) self.dircap = TahoeLAFS.createdircap(WEBAPI)
self.fs = TahoeFS(self.dircap, timeout=0, webapi=WEBAPI) self.fs = TahoeLAFS(self.dircap, timeout=0, webapi=WEBAPI)
def tearDown(self): def tearDown(self):
self.fs.close() self.fs.close()
...@@ -36,11 +36,11 @@ class TestTahoeFS(unittest.TestCase,FSTestCases,ThreadingTestCases): ...@@ -36,11 +36,11 @@ class TestTahoeFS(unittest.TestCase,FSTestCases,ThreadingTestCases):
self.assert_(self.dircap.startswith('URI:DIR2:') and len(self.dircap) > 50) self.assert_(self.dircap.startswith('URI:DIR2:') and len(self.dircap) > 50)
def test_concurrent_copydir(self): def test_concurrent_copydir(self):
# makedir() on TahoeFS is currently not atomic # makedir() on TahoeLAFS is currently not atomic
pass pass
def test_makedir_winner(self): def test_makedir_winner(self):
# makedir() on TahoeFS is currently not atomic # makedir() on TahoeLAFS is currently not atomic
pass pass
def test_big_file(self): def test_big_file(self):
......
...@@ -571,17 +571,17 @@ class TahoeOpener(Opener): ...@@ -571,17 +571,17 @@ class TahoeOpener(Opener):
@classmethod @classmethod
def get_fs(cls, registry, fs_name, fs_name_params, fs_path, writeable, create_dir): def get_fs(cls, registry, fs_name, fs_name_params, fs_path, writeable, create_dir):
from fs.contrib.tahoefs import TahoeFS from fs.contrib.tahoefs import TahoeLAFS
if '/uri/' not in fs_path: if '/uri/' not in fs_path:
raise OpenerError("""Tahoe url should be in the form <url>/uri/<dicap>""") raise OpenerError("""Tahoe-LAFS url should be in the form <url>/uri/<dicap>""")
url, dircap = fs_path.split('/uri/') url, dircap = fs_path.split('/uri/')
path = '' path = ''
if '/' in dircap: if '/' in dircap:
dircap, path = dircap.split('/', 1) dircap, path = dircap.split('/', 1)
fs = TahoeFS(dircap, webapi=url) fs = TahoeLAFS(dircap, webapi=url)
if '/' in path: if '/' in path:
dirname, _resourcename = pathsplit(path) dirname, _resourcename = pathsplit(path)
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
DebugFS is a wrapper around filesystems to help developers DebugFS is a wrapper around filesystems to help developers
debug their work. I wrote this class mainly for debugging debug their work. I wrote this class mainly for debugging
TahoeFS and for fine tuning TahoeFS over Dokan with higher-level TahoeLAFS and for fine tuning TahoeLAFS over Dokan with higher-level
aplications like Total Comander, Winamp etc. Did you know aplications like Total Comander, Winamp etc. Did you know
that Total Commander need to open file before it delete them? :-) that Total Commander need to open file before it delete them? :-)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment