Пример #1
0
 def destroy(self):
     time.sleep(3)
     try:
         fuse.unmount(self.mount_directory)
         os.removedirs(self.mount_directory)
     except OSError: #Mounted in use, try again
         self.destroy()
Пример #2
0
 def tearDown(self):
     self.mount_proc.unmount()
     try:
         self.temp_fs.close()
     except OSError:
         # Sometimes FUSE hangs onto the mountpoint if mount_proc is
         # forcibly killed.  Shell out to fusermount to make sure.
         fuse.unmount(self.mount_point)
         self.temp_fs.close()
Пример #3
0
 def tearDown(self):
     self.mount_proc.unmount()
     try:
         self.temp_fs.close()
     except OSError:
         # Sometimes FUSE hangs onto the mountpoint if mount_proc is
         # forcibly killed.  Shell out to fusermount to make sure.
         fuse.unmount(self.mount_point)
         self.temp_fs.close()
Пример #4
0
    def do_run(self, options, args):
        
        windows = platform == "Windows"
                
        if options.unmount:

            if windows:
                
                try:                
                    mount_path = args[0][:1]
                except IndexError:
                    self.error('Driver letter required\n')
                    return 1
                
                from fs.expose import dokan
                mount_path = mount_path[:1].upper()
                self.output('unmounting %s:...\n' % mount_path, True)
                dokan.unmount(mount_path)                
                return
            
            else:                
                try:                
                    mount_path = args[0]
                except IndexError:
                    self.error(self.usage + '\n')
                    return 1                                
                
                from fs.expose import fuse
                self.output('unmounting %s...\n' % mount_path, True)
                fuse.unmount(mount_path)                
                return
        
        try:
            fs_url = args[0]
        except IndexError:
            self.error(self.usage + '\n')
            return 1
        
        try:                
            mount_path = args[1]
        except IndexError:
            if windows:
                mount_path = mount_path[:1].upper()
                self.error(self.usage + '\n')
            else:
                self.error(self.usage + '\n')
            return 1                    
            
        fs, path = self.open_fs(fs_url, create_dir=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 options.nocache:
            fs.cache_hint(True)
                
        if windows:
            from fs.expose import dokan
            
            if len(mount_path) > 1:
                self.error('Driver letter should be one character')
                return 1
            
            self.output("Mounting %s on %s:\n" % (fs, mount_path), True)
            flags = dokan.DOKAN_OPTION_REMOVABLE
            if options.debug:
                flags |= dokan.DOKAN_OPTION_DEBUG | dokan.DOKAN_OPTION_STDERR
                
            mp = dokan.mount(fs,
                             mount_path,
                             numthreads=5,
                             foreground=options.foreground,
                             flags=flags,
                             volname=str(fs))
            
        else:            
            if not os.path.exists(mount_path):
                try:
                    os.makedirs(mount_path)
                except:
                    pass
            
            from fs.expose import fuse
            self.output("Mounting %s on %s\n" % (fs, mount_path), True)
            
            if options.foreground:
                fuse_process = fuse.mount(fs,
                                          mount_path,                                          
                                          foreground=True)                                                    
            else:
                if not os.fork():
                    mp = fuse.mount(fs,
                                    mount_path,
                                    foreground=True)
                else:
                    fs.close = lambda:None
Пример #5
0
    def do_run(self, options, args):

        windows = platform == "Windows"

        if options.unmount:

            if windows:

                try:
                    mount_path = args[0][:1]
                except IndexError:
                    self.error('Driver letter required\n')
                    return 1

                from fs.expose import dokan
                mount_path = mount_path[:1].upper()
                self.output('unmounting %s:...\n' % mount_path, True)
                dokan.unmount(mount_path)
                return

            else:
                try:
                    mount_path = args[0]
                except IndexError:
                    self.error(self.usage + '\n')
                    return 1

                from fs.expose import fuse
                self.output('unmounting %s...\n' % mount_path, True)
                fuse.unmount(mount_path)
                return

        try:
            fs_url = args[0]
        except IndexError:
            self.error(self.usage + '\n')
            return 1

        try:
            mount_path = args[1]
        except IndexError:
            if windows:
                mount_path = mount_path[:1].upper()
                self.error(self.usage + '\n')
            else:
                self.error(self.usage + '\n')
            return 1

        fs, path = self.open_fs(fs_url, create_dir=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 options.nocache:
            fs.cache_hint(True)

        if windows:
            from fs.expose import dokan

            if len(mount_path) > 1:
                self.error('Driver letter should be one character')
                return 1

            self.output("Mounting %s on %s:\n" % (fs, mount_path), True)
            flags = dokan.DOKAN_OPTION_REMOVABLE
            if options.debug:
                flags |= dokan.DOKAN_OPTION_DEBUG | dokan.DOKAN_OPTION_STDERR

            mp = dokan.mount(fs,
                             mount_path,
                             numthreads=5,
                             foreground=options.foreground,
                             flags=flags,
                             volname=str(fs))

        else:
            if not os.path.exists(mount_path):
                try:
                    os.makedirs(mount_path)
                except:
                    pass

            from fs.expose import fuse
            self.output("Mounting %s on %s\n" % (fs, mount_path), True)

            if options.foreground:
                fuse_process = fuse.mount(fs, mount_path, foreground=True)
            else:
                if not os.fork():
                    mp = fuse.mount(fs, mount_path, foreground=True)
                else:
                    fs.close = lambda: None