本文整理汇总了Python中fuse.FUSE属性的典型用法代码示例。如果您正苦于以下问题:Python fuse.FUSE属性的具体用法?Python fuse.FUSE怎么用?Python fuse.FUSE使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类fuse
的用法示例。
在下文中一共展示了fuse.FUSE属性的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: fuse_main
# 需要导入模块: import fuse [as 别名]
# 或者: from fuse import FUSE [as 别名]
def fuse_main(self, mount_point):
self.__class__.__name__ = 'oxfs'
if 'Darwin' == self.sys:
fuse = FUSE(self, mount_point, foreground=True, nothreads=True,
allow_other=True, auto_cache=True,
uid=os.getuid(), gid=os.getgid(),
defer_permissions=True, kill_on_unmount=True,
noappledouble=True, noapplexattr=True,
nosuid=True, nobrowse=True, volname=self.host)
elif 'Linux' == self.sys:
fuse = FUSE(self, mount_point, foreground=True, nothreads=True,
allow_other=True, auto_cache=True,
uid=os.getuid(), gid=os.getgid(),
auto_unmount=True)
else:
self.logger.error('not supported system, {}'.format(self.sys))
sys.exit()
示例2: init_b2fuse
# 需要导入模块: import fuse [as 别名]
# 或者: from fuse import FUSE [as 别名]
def init_b2fuse():
config = load_config("config.yaml")
os.makedirs("mountpoint")
filesystem = B2Fuse(
config["accountId"],
config["applicationKey"],
config["bucketId"],
config["enableHashfiles"],
config["memoryLimit"],
config["tempFolder"],
config["useDisk"],
)
fuse = FUSE(filesystem, "mountpoint", nothreads=True, foreground=False)
return fuse
示例3: main
# 需要导入模块: import fuse [as 别名]
# 或者: from fuse import FUSE [as 别名]
def main(argc, argv):
if (argc < 2):
print("USAGE: " + argv[0] + " <mount path>")
return 0
print("Running FUSE ...")
# logging.basicConfig(level=logging.DEBUG)
fuse = FUSE(Memory(), argv[1], foreground=False, nothreads=True)
print("Done!")
###############
# Entry Point #
###############
示例4: mount
# 需要导入模块: import fuse [as 别名]
# 或者: from fuse import FUSE [as 别名]
def mount(pool, mountpoint):
zf = ZFSFuse(pool)
fuse = FUSE(zf, mountpoint,
foreground=True,
rdonly=True,
nobrowse=True,
jail_symlinks=True,
nolocalcaches=True,
# debug=True,
)
示例5: __getattr__
# 需要导入模块: import fuse [as 别名]
# 或者: from fuse import FUSE [as 别名]
def __getattr__(self, attr_name):
"""
It will only be called by the `__init__` method from `fuse.FUSE` to
establish which operations will be allowed after mounting the
filesystem.
"""
methods = inspect.getmembers(FUSE, predicate=callable)
fuse_allowed_methods = set(elem[0] for elem in methods)
return attr_name in fuse_allowed_methods - set(["bmap", "lock"])
示例6: _bootstrap_mountpoint
# 需要导入模块: import fuse [as 别名]
# 或者: from fuse import FUSE [as 别名]
def _bootstrap_mountpoint(base_mountpoint_path: PurePath, workspace_fs) -> PurePath:
# Find a suitable path where to mount the workspace. The check we are doing
# here are not atomic (and the mount operation is not itself atomic anyway),
# hence there is still edgecases where the mount can crash due to concurrent
# changes on the mountpoint path
workspace_name = workspace_fs.get_workspace_name()
for tentative in count(1):
if tentative == 1:
dirname = workspace_name
else:
dirname = f"{workspace_name} ({tentative})"
mountpoint_path = base_mountpoint_path / dirname
try:
# On POSIX systems, mounting target must exists
trio_mountpoint_path = trio.Path(mountpoint_path)
await trio_mountpoint_path.mkdir(mode=0o700, exist_ok=True, parents=True)
base_st_dev = (await trio.Path(base_mountpoint_path).stat()).st_dev
initial_st_dev = (await trio_mountpoint_path.stat()).st_dev
if initial_st_dev != base_st_dev:
# mountpoint_path seems to already have a mountpoint on it,
# hence find another place to setup our own mountpoint
continue
if list(await trio_mountpoint_path.iterdir()):
# mountpoint_path not empty, cannot mount there
continue
return mountpoint_path, initial_st_dev
except OSError:
# In case of hard crash, it's possible the FUSE mountpoint is still
# mounted (but points to nothing). In such case just mount in
# another place
continue
示例7: space_usage_allocated
# 需要导入模块: import fuse [as 别名]
# 或者: from fuse import FUSE [as 别名]
def space_usage_allocated(space_usage):
'''Return the space usage allocation for an individual or team account as applicable.'''
return space_usage.allocation.get_individual().allocated if space_usage.allocation.is_individual() else space_usage.allocation.get_team().allocated
##################################
# Class: FUSE Dropbox operations #
##################################
示例8: readdir
# 需要导入模块: import fuse [as 别名]
# 或者: from fuse import FUSE [as 别名]
def readdir( self, path, fh ):
# we only need to return these special directories. FUSE automatically expands these and will not ask
# for paths like /../foo/./../bar, so we don't need to worry about cleaning such paths
yield '.'
yield '..'
files = self._getUnionMountListDir( path )
if files is not None:
for key in files:
yield key
return
# If no folder was found, check whether the special .versions folder was requested
result = self._decodeVersionsPathAPI( path )
if not result:
return
path, pathIsVersions, fileVersion = result
if not pathIsVersions:
files = self._getUnionMountListDir( path )
if files is not None:
for key in files:
yield key
return
# Print all available versions of the file at filePath as the contents of the special '.versions' folder
version = 0
for mountSource in self.mountSources:
if isinstance( mountSource, str ):
realPath = os.path.join( mountSource, path.lstrip( os.path.sep ) )
if os.path.lexists( realPath ):
version += 1
yield str( version )
else:
result = mountSource.getFileInfo( path, listVersions = True )
for x in result.keys():
version += 1
yield str( version )
示例9: cli
# 需要导入模块: import fuse [as 别名]
# 或者: from fuse import FUSE [as 别名]
def cli( args = None ):
tmpArgs = sys.argv if args is None else args
if '--version' in tmpArgs or '-v' in tmpArgs:
print( "ratarmount", __version__ )
return
args = parseArgs( args )
# Convert the comma separated list of key[=value] options into a dictionary for fusepy
fusekwargs = dict( [ option.split( '=', 1 ) if '=' in option else ( option, True )
for option in args.fuse.split( ',' ) ] ) if args.fuse else {}
if args.prefix:
fusekwargs['modules'] = 'subdir'
fusekwargs['subdir'] = args.prefix
if args.mount_point in args.mount_source:
fusekwargs['nonempty'] = True
global printDebug
printDebug = args.debug
fuseOperationsObject = TarMount(
pathToMount = args.mount_source,
clearIndexCache = args.recreate_index,
recursive = args.recursive,
gzipSeekPointSpacing = args.gzip_seek_point_spacing,
mountPoint = args.mount_point )
fuse.FUSE( operations = fuseOperationsObject,
mountpoint = args.mount_point,
foreground = args.foreground,
nothreads = True, # Can't access SQLite database connection object from multiple threads
**fusekwargs )
示例10: main
# 需要导入模块: import fuse [as 别名]
# 或者: from fuse import FUSE [as 别名]
def main(router):
if len(sys.argv) != 3:
print('usage: %s <host> <mountpoint>' % sys.argv[0])
sys.exit(1)
kwargs = {}
if sys.platform == 'darwin':
kwargs['volname'] = '%s (Mitogen)' % (sys.argv[1],)
fuse.FUSE(
operations=Operations(sys.argv[1]),
mountpoint=sys.argv[2],
foreground=True,
**kwargs
)
示例11: run
# 需要导入模块: import fuse [as 别名]
# 或者: from fuse import FUSE [as 别名]
def run(fs, path, mount_point, foreground=True, threads=False):
""" Mount stuff in a local directory
This uses fusepy to make it appear as if a given path on an fsspec
instance is in fact resident within the local file-system.
This requires that fusepy by installed, and that FUSE be available on
the system (typically requiring a package to be installed with
apt, yum, brew, etc.).
Parameters
----------
fs: file-system instance
From one of the compatible implementations
path: str
Location on that file-system to regard as the root directory to
mount. Note that you typically should include the terminating "/"
character.
mount_point: str
An empty directory on the local file-system where the contents of
the remote path will appear
foreground: bool
Whether or not calling this function will block. Operation will
typically be more stable if True.
threads: bool
Whether or not to create threads when responding to file operations
within the mounter directory. Operation will typically be more
stable if False.
"""
func = lambda: FUSE(
FUSEr(fs, path), mount_point, nothreads=not threads, foreground=True
)
if foreground is False:
th = threading.Thread(target=func)
th.daemon = True
th.start()
return th
else: # pragma: no cover
try:
func()
except KeyboardInterrupt:
pass
示例12: _decodeVersionsPathAPI
# 需要导入模块: import fuse [as 别名]
# 或者: from fuse import FUSE [as 别名]
def _decodeVersionsPathAPI( self, filePath ):
"""
Do a loop over the parent path parts to resolve possible versions in parent folders.
Note that multiple versions of a folder always are union mounted. So, for the path to a file
inside those folders the exact version of a parent folder can simply be removed for lookup.
Therefore, translate something like: /foo.version/3/bar.version/2/mimi.version/1 into
/foo/bar/mimi.version/1
This is possibly time-costly but requesting a different version from the most recent should
be a rare occurence and FUSE also checks all parent parts before accessing a file so it
might only slow down access by roughly factor 2.
"""
# @todo make it work for files ending with '.versions'.
# Currently, this feature would be hidden by those files. But, I think this should be quite rare.
# I could allow arbitrary amounts of dots like '....versions' but then it wouldn't be discernible
# for ...versions whether the versions of ..versions or .versions file was requested. I could add
# a rule for the decision, like ...versions shows the versions of .versions and ....versions for
# ..versions, however, all of this might require an awful lot of file existence checking.
# My first idea was to use hidden subfolders for each file like path/to/file/.versions/1 but FUSE
# checks the parents in a path that they are directories first, so getattr or readdir is not even
# called for path/to/file/.versions if path/to/file is not a directory.
# Another alternative might be one hidden folder at the root for a parallel file tree, like
# /.versions/path/to/file/3 but that runs into similar problems when trying to specify the file
# version or if a .versions root directory exists.
filePathParts = filePath.lstrip( '/' ).split( '/' )
filePath = ''
pathIsVersions = False
fileVersion = None # Not valid if None or parentIsVersions is True
for part in filePathParts:
# Skip over the exact version specified
if pathIsVersions:
try:
fileVersion = int( part )
assert str( fileVersion ) == part
except:
return None
pathIsVersions = False
continue
# Simply append normal existing folders
tmpFilePath = '/'.join( [ filePath, part ] )
if self._getUnionMountFileInfo( tmpFilePath ):
filePath = tmpFilePath
fileVersion = 0
continue
# If current path does not exist, check if it is a special versions path
if part.endswith( '.versions' ) and len( part ) > len( '.versions' ):
pathIsVersions = True
filePath = tmpFilePath[:-len( '.versions' )]
continue
# Parent path does not exist and is not a versions path, so any subpaths also won't exist either
return None
return filePath, pathIsVersions, ( None if pathIsVersions else fileVersion )