diff options
author | willmcgugan <willmcgugan@67cdc799-7952-0410-af00-57a81ceafa0f> | 2010-12-12 19:45:18 +0000 |
---|---|---|
committer | willmcgugan <willmcgugan@67cdc799-7952-0410-af00-57a81ceafa0f> | 2010-12-12 19:45:18 +0000 |
commit | e3e348612258dbafa195f88cde2d42c734755ef9 (patch) | |
tree | 84af17dc03a01eae8d0894d0ef555eb20d8ef83c /fs/commands | |
parent | 8d3bdaec3a50d8ef38a074958e92e77eea7ee563 (diff) | |
download | pyfilesystem-e3e348612258dbafa195f88cde2d42c734755ef9.tar.gz |
Added fsmount command, made memroyfs work with threads
git-svn-id: http://pyfilesystem.googlecode.com/svn/trunk@550 67cdc799-7952-0410-af00-57a81ceafa0f
Diffstat (limited to 'fs/commands')
-rw-r--r-- | fs/commands/fsmount | 6 | ||||
-rw-r--r-- | fs/commands/fsmount.py | 81 |
2 files changed, 87 insertions, 0 deletions
diff --git a/fs/commands/fsmount b/fs/commands/fsmount new file mode 100644 index 0000000..09ac738 --- /dev/null +++ b/fs/commands/fsmount @@ -0,0 +1,6 @@ +#!/usr/bin/env python +import sys +from fs.commands.fsmount import run +sys.exit(run()) + + diff --git a/fs/commands/fsmount.py b/fs/commands/fsmount.py new file mode 100644 index 0000000..d4ca830 --- /dev/null +++ b/fs/commands/fsmount.py @@ -0,0 +1,81 @@ +#!/usr/bin/env python + +from fs.opener import opener +from fs.commands.runner import Command +import sys +import platform +import os +import os.path +import time + +class FSMount(Command): + + usage = """fsmount [SYSTEM PATH] [FS] +or fsmount -u [SYSTEM PATH] +Mounts a file system on a system path""" + + version = "1.0" + + def get_optparse(self): + optparse = super(FSMount, self).get_optparse() + optparse.add_option('-f', '--foreground', dest='foreground', action="store_true", default=False, + help="run the mount process in the foreground", metavar="FOREGROUND") + optparse.add_option('-u', '--unmount', dest='unmount', action="store_true", default=False, + help="unmount path", metavar="UNMOUNT") + + return optparse + + + def do_run(self, options, args): + + if options.unmount: + try: + mount_path = args[0] + except IndexError: + self.error('Mount path required\n') + return 1 + from fs.expose import fuse + fuse.unmount(mount_path) + return + + try: + mount_path = args[0] + except IndexError: + self.error('Mount path required\n') + return 1 + try: + fs_url = args[1] + except IndexError: + self.error('FS required\n') + return 1 + + if platform.system() == 'Windows': + pass + else: + fs, path = self.open_fs(fs_url, create=True) + if path: + if not fs.isdir(path): + self.error('%s is not a directory on %s' % (fs_url. fs)) + return 1 + fs = fs.opendir(path) + path = '/' + if not os.path.exists(mount_path): + os.makedirs(mount_path) + from fs.expose import fuse + if options.foreground: + fuse_process = fuse.mount(fs, + mount_path, + foreground=True) + else: + mp = fuse.mount(fs, + mount_path, + foreground=False) + + + +def run(): + return FSMount().run() + +if __name__ == "__main__": + sys.exit(run()) +
\ No newline at end of file |