本文整理汇总了Python中fuse.FuseOSError方法的典型用法代码示例。如果您正苦于以下问题:Python fuse.FuseOSError方法的具体用法?Python fuse.FuseOSError怎么用?Python fuse.FuseOSError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类fuse
的用法示例。
在下文中一共展示了fuse.FuseOSError方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: getattr
# 需要导入模块: import fuse [as 别名]
# 或者: from fuse import FuseOSError [as 别名]
def getattr(self, path, fh=None):
path = "".join([self.root, path.lstrip("/")]).rstrip("/")
try:
info = self.fs.info(path)
except FileNotFoundError:
raise FuseOSError(ENOENT)
data = {"st_uid": 1000, "st_gid": 1000}
perm = 0o777
if info["type"] != "file":
data["st_mode"] = stat.S_IFDIR | perm
data["st_size"] = 0
data["st_blksize"] = 0
else:
data["st_mode"] = stat.S_IFREG | perm
data["st_size"] = info["size"]
data["st_blksize"] = 5 * 2 ** 20
data["st_nlink"] = 1
data["st_atime"] = time.time()
data["st_ctime"] = time.time()
data["st_mtime"] = time.time()
return data
示例2: list_files
# 需要导入模块: import fuse [as 别名]
# 或者: from fuse import FuseOSError [as 别名]
def list_files(self, path):
p = KubePath().parse_path(path)
if not p.exists(self.client):
logger.info("path doesn't exist")
raise FuseOSError(errno.ENOENT)
if not p.is_dir():
logger.info("not a directory")
raise FuseOSError(errno.ENOTDIR)
if p.object_id is not None:
if p.resource_type != 'pod':
return p.SUPPORTED_ACTIONS
else:
return p.SUPPORTED_POD_ACTIONS
if p.resource_type is not None:
return self.client.get_entities(p.namespace, p.resource_type)
if p.namespace is not None:
return p.SUPPORTED_RESOURCE_TYPES
return self.client.get_namespaces() # + ['all']
示例3: getattr
# 需要导入模块: import fuse [as 别名]
# 或者: from fuse import FuseOSError [as 别名]
def getattr(self, path, fh=None):
path = self.remotepath(path)
attr = self.attributes.fetch(path)
if attr is not None:
if ENOENT == attr:
raise FuseOSError(ENOENT)
return attr
self.logger.info('sftp getattr {}'.format(path))
try:
attr = self.extract(self.sftp.lstat(path))
self.attributes.insert(path, attr)
return attr
except:
self.attributes.insert(path, ENOENT)
raise FuseOSError(ENOENT)
示例4: truncate
# 需要导入模块: import fuse [as 别名]
# 或者: from fuse import FuseOSError [as 别名]
def truncate(self, path, length, fh=None):
realpath = self.remotepath(path)
cachefile = self.cachefile(realpath)
if not os.path.exists(cachefile):
if self.empty_file(realpath):
self.create(path, 'wb')
else:
raise FuseOSError(ENOENT)
status = os.truncate(cachefile, length)
self.logger.info(self.extract(os.lstat(cachefile)))
self.attributes.insert(realpath, self.extract(os.lstat(cachefile)))
task = Task(xxhash.xxh64(realpath).intdigest(),
self._truncate, realpath, length)
self.taskpool.submit(task)
return status
示例5: write
# 需要导入模块: import fuse [as 别名]
# 或者: from fuse import FuseOSError [as 别名]
def write(self, path, data, offset, fh):
realpath = self.remotepath(path)
cachefile = self.cachefile(realpath)
if not os.path.exists(cachefile):
if self.empty_file(realpath):
self.create(path, 'wb')
else:
raise FuseOSError(ENOENT)
with open(cachefile, 'rb+') as outfile:
outfile.seek(offset, 0)
outfile.write(data)
self.attributes.insert(realpath, self.extract(os.lstat(cachefile)))
task = Task(xxhash.xxh64(realpath).intdigest(),
self._write, realpath, data, offset)
self.taskpool.submit(task)
return len(data)
示例6: chmod
# 需要导入模块: import fuse [as 别名]
# 或者: from fuse import FuseOSError [as 别名]
def chmod(self, path, mode):
"""
Executes chmod on the file at os level and then it commits the change.
"""
str_mode = ("%o" % mode)[-4:]
if str_mode not in ["0755", "0644"]:
raise FuseOSError(errno.EINVAL)
result = super(CurrentView, self).chmod(path, mode)
if os.path.isdir(self.repo._full_path(path)):
return result
message = "Chmod to {} on {}".format(str_mode, path)
self._stage(add=path, message=message)
log.debug("CurrentView: Change %s mode to %s", path, ("0%o" % mode)[-4:])
return result
示例7: getattr
# 需要导入模块: import fuse [as 别名]
# 或者: from fuse import FuseOSError [as 别名]
def getattr(self, path, fh=None):
"""
Returns a dictionary with keys identical to the stat C structure of
stat(2).
st_atime, st_mtime and st_ctime should be floats.
NOTE: There is an incombatibility between Linux and Mac OS X
concerning st_nlink of directories. Mac OS X counts all files inside
the directory, while Linux counts only the subdirectories.
"""
if path != "/":
raise FuseOSError(ENOENT)
attrs = super(IndexView, self).getattr(path, fh)
attrs.update({"st_mode": S_IFDIR | 0o555, "st_nlink": 2})
return attrs
示例8: check_args
# 需要导入模块: import fuse [as 别名]
# 或者: from fuse import FuseOSError [as 别名]
def check_args(self, f, methods_args):
to_check = []
args = inspect.getargspec(f)
for arg in self.check:
if arg in args[0]:
to_check.append(args[0].index(arg))
for index in to_check:
arg = methods_args[index - 1]
if self.look_at.cache.get(arg, False):
raise FuseOSError(errno.EACCES)
if self.look_at.check_key(arg):
self.look_at.cache[arg] = True
raise FuseOSError(errno.ENOENT)
self.look_at.cache[arg] = False
示例9: write_operation
# 需要导入模块: import fuse [as 别名]
# 或者: from fuse import FuseOSError [as 别名]
def write_operation(f):
@wraps(f)
def decorated(*args, **kwargs):
if not fetch_successful.is_set() or not push_successful.is_set():
raise FuseOSError(EROFS)
global writers
writers += 1
if syncing.is_set():
log.debug("WriteOperation: Wait until syncing is done")
sync_done.wait()
try:
result = f(*args, **kwargs)
finally:
writers -= 1
return result
return decorated
示例10: test_access_with_invalid_path
# 需要导入模块: import fuse [as 别名]
# 或者: from fuse import FuseOSError [as 别名]
def test_access_with_invalid_path(self):
mocked_repo = MagicMock()
mocked_validation = MagicMock()
mocked_commit = MagicMock()
mocked_commit.tree = "tree"
mocked_repo.revparse_single.return_value = mocked_commit
mocked_validation.return_value = False
with patch("gitfs.views.commit.split_path_into_components") as split:
split.return_value = "elements"
view = CommitView(repo=mocked_repo, commit_sha1="sha1")
view._validate_commit_path = mocked_validation
view.relative_path = "relative_path"
with pytest.raises(FuseOSError):
view.access("path", "mode")
split.assert_called_once_with("relative_path")
mocked_validation.assert_called_once_with("tree", "elements")
示例11: test_access
# 需要导入模块: import fuse [as 别名]
# 或者: from fuse import FuseOSError [as 别名]
def test_access(self):
mocked_access = MagicMock()
mocked_access.side_effect = [True, True, False]
with patch("gitfs.views.passthrough.os.access", mocked_access):
view = PassthroughView(repo=self.repo, repo_path=self.repo_path)
# normal, easy test
view.access("good/relative/path", 777)
# test if _full_path works
view.access("/good/relative/path", 777)
# test if proper exception is raised
with raises(FuseOSError):
view.access("/relative/path", 777)
asserted_calls = [
call("/the/root/path/good/relative/path", 777),
call("/the/root/path/good/relative/path", 777),
call("/the/root/path/relative/path", 777),
]
mocked_access.assert_has_calls(asserted_calls)
assert mocked_access.call_count == 3
示例12: translate_error
# 需要导入模块: import fuse [as 别名]
# 或者: from fuse import FuseOSError [as 别名]
def translate_error(event_bus, operation, path):
try:
yield
except FuseOSError:
raise
except FSLocalOperationError as exc:
raise FuseOSError(exc.errno) from exc
except FSRemoteOperationError as exc:
event_bus.send(CoreEvent.MOUNTPOINT_REMOTE_ERROR, exc=exc, operation=operation, path=path)
raise FuseOSError(exc.errno) from exc
except Exception as exc:
logger.exception("Unhandled exception in fuse mountpoint")
event_bus.send(
CoreEvent.MOUNTPOINT_UNHANDLED_ERROR, exc=exc, operation=operation, path=path
)
# Use EINVAL as fallback error code, since this is what fusepy does.
raise FuseOSError(errno.EINVAL) from exc
示例13: _get_path_entry
# 需要导入模块: import fuse [as 别名]
# 或者: from fuse import FuseOSError [as 别名]
def _get_path_entry(self, path):
root = self._fs.get_root_directory()
if path == "/":
g_logger.debug("asking for root")
entry = root
else:
_, __, rest = path.partition("/")
g_logger.debug("asking for: %s", rest)
try:
entry = root.get_path_entry(rest)
except ChildNotFoundError:
raise FuseOSError(errno.ENOENT)
return entry
# Filesystem methods
# ==================
示例14: getattr
# 需要导入模块: import fuse [as 别名]
# 或者: from fuse import FuseOSError [as 别名]
def getattr(self, path, fh=None):
#print 'getattr *',path
# 先看缓存中是否存在该文件
if not self.buffer.has_key(path):
print path,'未命中'
#print self.buffer
#print self.traversed_folder
jdata = json.loads(self.disk.meta([path]).content)
try:
if 'info' not in jdata:
raise FuseOSError(errno.ENOENT)
if jdata['errno'] != 0:
raise FuseOSError(errno.ENOENT)
file_info = jdata['info'][0]
self._add_file_to_buffer(path,file_info)
st = self.buffer[path].getDict()
return st
except:
raise FuseOSError(errno.ENOENT)
else:
#print path,'命中'
return self.buffer[path].getDict()
示例15: unlink
# 需要导入模块: import fuse [as 别名]
# 或者: from fuse import FuseOSError [as 别名]
def unlink(self, path):
fn = "".join([self.root, path.lstrip("/")])
try:
self.fs.rm(fn, False)
except (IOError, FileNotFoundError):
raise FuseOSError(EIO)