diff options
author | Terence Honles <terence@honles.com> | 2016-03-15 19:14:53 -0700 |
---|---|---|
committer | Terence Honles <terence@honles.com> | 2016-03-15 19:14:53 -0700 |
commit | 4237e01d96bf7beb45c4046a022c64f0c86ff66d (patch) | |
tree | fa5b023cee4ccfe1e888ac252132f45ed21d51a0 | |
parent | ad8964c72190c1c6c579b988ee9fda91c561472b (diff) | |
parent | 81dbe030707551b4455f67fa3e1c96f6c7a9ba95 (diff) | |
download | fusepy-4237e01d96bf7beb45c4046a022c64f0c86ff66d.tar.gz |
Merge pull request #45 from eestrada/masterv2.0.3
use Python 3 compatible code with future imports
-rwxr-xr-x | examples/context.py | 5 | ||||
-rwxr-xr-x | examples/loopback.py | 5 | ||||
-rwxr-xr-x | examples/memory.py | 3 | ||||
-rwxr-xr-x | examples/memoryll.py | 28 | ||||
-rwxr-xr-x | examples/sftp.py | 5 | ||||
-rw-r--r-- | fuse.py | 2 | ||||
-rw-r--r-- | fusell.py | 3 |
7 files changed, 35 insertions, 16 deletions
diff --git a/examples/context.py b/examples/context.py index 40fa168..6e7bb58 100755 --- a/examples/context.py +++ b/examples/context.py @@ -1,4 +1,7 @@ #!/usr/bin/env python +from __future__ import print_function, absolute_import, division + +import logging from errno import ENOENT from stat import S_IFDIR, S_IFREG @@ -62,4 +65,6 @@ if __name__ == '__main__': print('usage: %s <mountpoint>' % argv[0]) exit(1) + logging.basicConfig(level=logging.DEBUG) + fuse = FUSE(Context(), argv[1], foreground=True, ro=True) diff --git a/examples/loopback.py b/examples/loopback.py index 1b5b6ed..c424fb7 100755 --- a/examples/loopback.py +++ b/examples/loopback.py @@ -1,6 +1,7 @@ #!/usr/bin/env python +from __future__ import print_function, absolute_import, division -from __future__ import with_statement +import logging from errno import EACCES from os.path import realpath @@ -99,4 +100,6 @@ if __name__ == '__main__': print('usage: %s <root> <mountpoint>' % argv[0]) exit(1) + logging.basicConfig(level=logging.DEBUG) + fuse = FUSE(Loopback(argv[1]), argv[2], foreground=True) diff --git a/examples/memory.py b/examples/memory.py index b2b2a5d..e8148ad 100755 --- a/examples/memory.py +++ b/examples/memory.py @@ -1,4 +1,5 @@ #!/usr/bin/env python +from __future__ import print_function, absolute_import, division import logging @@ -132,5 +133,5 @@ if __name__ == '__main__': print('usage: %s <mountpoint>' % argv[0]) exit(1) - logging.getLogger().setLevel(logging.DEBUG) + logging.basicConfig(level=logging.DEBUG) fuse = FUSE(Memory(), argv[1], foreground=True) diff --git a/examples/memoryll.py b/examples/memoryll.py index 7482f86..57be97a 100755 --- a/examples/memoryll.py +++ b/examples/memoryll.py @@ -1,4 +1,7 @@ #!/usr/bin/env python +from __future__ import print_function, absolute_import, division + +import logging from collections import defaultdict from errno import ENOENT, EROFS @@ -27,7 +30,7 @@ class Memory(FUSELL): forget = None def getattr(self, req, ino, fi): - print 'getattr:', ino + print('getattr:', ino) attr = self.attr[ino] if attr: self.reply_attr(req, attr, 1.0) @@ -35,7 +38,7 @@ class Memory(FUSELL): self.reply_err(req, ENOENT) def lookup(self, req, parent, name): - print 'lookup:', parent, name + print('lookup:', parent, name) children = self.children[parent] ino = children.get(name, 0) attr = self.attr[ino] @@ -47,7 +50,7 @@ class Memory(FUSELL): self.reply_err(req, ENOENT) def mkdir(self, req, parent, name, mode): - print 'mkdir:', parent, name + print('mkdir:', parent, name) ino = self.create_ino() ctx = self.req_ctx(req) now = time() @@ -70,7 +73,7 @@ class Memory(FUSELL): self.reply_entry(req, entry) def mknod(self, req, parent, name, mode, rdev): - print 'mknod:', parent, name + print('mknod:', parent, name) ino = self.create_ino() ctx = self.req_ctx(req) now = time() @@ -93,16 +96,16 @@ class Memory(FUSELL): self.reply_entry(req, entry) def open(self, req, ino, fi): - print 'open:', ino + print('open:', ino) self.reply_open(req, fi) def read(self, req, ino, size, off, fi): - print 'read:', ino, size, off + print('read:', ino, size, off) buf = self.data[ino][off:(off + size)] self.reply_buf(req, buf) def readdir(self, req, ino, size, off, fi): - print 'readdir:', ino + print('readdir:', ino) parent = self.parent[ino] entries = [('.', {'st_ino': ino, 'st_mode': S_IFDIR}), ('..', {'st_ino': parent, 'st_mode': S_IFDIR})] @@ -111,14 +114,14 @@ class Memory(FUSELL): self.reply_readdir(req, size, off, entries) def rename(self, req, parent, name, newparent, newname): - print 'rename:', parent, name, newparent, newname + print('rename:', parent, name, newparent, newname) ino = self.children[parent].pop(name) self.children[newparent][newname] = ino self.parent[ino] = newparent self.reply_err(req, 0) def setattr(self, req, ino, attr, to_set, fi): - print 'setattr:', ino, to_set + print('setattr:', ino, to_set) a = self.attr[ino] for key in to_set: if key == 'st_mode': @@ -130,13 +133,16 @@ class Memory(FUSELL): self.reply_attr(req, a, 1.0) def write(self, req, ino, buf, off, fi): - print 'write:', ino, off, len(buf) + print('write:', ino, off, len(buf)) self.data[ino] = self.data[ino][:off] + buf self.attr[ino]['st_size'] = len(self.data[ino]) self.reply_write(req, len(buf)) if __name__ == '__main__': if len(argv) != 2: - print 'usage: %s <mountpoint>' % argv[0] + print('usage: %s <mountpoint>' % argv[0]) exit(1) + + logging.basicConfig(level=logging.DEBUG) + fuse = Memory(argv[1]) diff --git a/examples/sftp.py b/examples/sftp.py index 6f512bd..6f5af82 100755 --- a/examples/sftp.py +++ b/examples/sftp.py @@ -1,4 +1,7 @@ #!/usr/bin/env python +from __future__ import print_function, absolute_import, division + +import logging from sys import argv, exit from time import time @@ -91,4 +94,6 @@ if __name__ == '__main__': print('usage: %s <host> <mountpoint>' % argv[0]) exit(1) + logging.basicConfig(level=logging.DEBUG) + fuse = FUSE(SFTP(argv[1]), argv[2], foreground=True, nothreads=True) @@ -13,7 +13,7 @@ # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -from __future__ import division +from __future__ import print_function, absolute_import, division from ctypes import * from ctypes.util import find_library @@ -11,8 +11,7 @@ # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -from __future__ import division +from __future__ import print_function, absolute_import, division from ctypes import * from ctypes.util import find_library |