当前位置: 首页>>代码示例>>Python>>正文


Python Connector.rm方法代码示例

本文整理汇总了Python中connector.Connector.rm方法的典型用法代码示例。如果您正苦于以下问题:Python Connector.rm方法的具体用法?Python Connector.rm怎么用?Python Connector.rm使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在connector.Connector的用法示例。


在下文中一共展示了Connector.rm方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: CloudFS

# 需要导入模块: from connector import Connector [as 别名]
# 或者: from connector.Connector import rm [as 别名]

#.........这里部分代码省略.........
				fdNum = i
				break

		if fd == None:
			raise FuseOSError(ENOENT)

		fd['path'] = path
		fd['dirty'] = False
		fd['data'] = content

		return fdNum
	
	def read(self, path, size, offset, fh):
		if self.files[fh]['path'] == None:
			raise FuseOSError(ENOENT)

		return self.files[fh]['data'][offset:offset + size]
	
	def readdir(self, path, fh):
		paths = splitPath(path)

		if paths[0] == '':
			dents = self.conn.getConns()
		else:
			dents = self.conn.getDents(paths[0], paths[1])

		return ['.', '..'] + dents
	
	def readlink(self, path):
		# readlink is not allowed
		raise FuseOSError(EPERM)
	
	def removexattr(self, path, name):
		raise FuseOSError(EPERM)
	
	def rename(self, old, new):
		# rename is not allowed
		raise FuseOSError(EPERM)
	
	def rmdir(self, path):
		paths = splitPath(path)

		# cannot remove mounted dir
		if paths[1] == '':
			raise FuseOSError(EPERM)
		if self.conn.rm(paths[0], paths[1]) != True:
			raise FuseOSError(ENOENT)
	
	def setxattr(self, path, name, value, options, position=0):
		raise FuseOSError(EPERM)

	def statfs(self, path):
		raise FuseOSError(EPERM)
	
	def symlink(self, target, source):
		raise FuseOSError(EPERM)
	
	def truncate(self, path, length, fh=0):
		fd = self.files[self.open(path, 0)]
		fd['dirty'] = True
		fd['data'] = fd['data'][:length]
	
	def unlink(self, path):
		paths = splitPath(path)

		# cannot remove mounted dir
		if paths[1] == '':
			raise FuseOSError(EPERM)
		if self.conn.rm(paths[0], paths[1]) != True:
			raise FuseOSError(ENOENT)
	
	def utimens(self, path, times=None):
		raise FuseOSError(EPERM)

	def write(self, path, data, offset, fh):
		fd = self.files[fh]
		if fd['path'] == None:
			raise FuseOSError(ENOENT)

		# update data and set dirty bit
		fd['data'] = fd['data'][:offset] + data
		fd['dirty'] = True
		
		return len(data)

	def release(self, path, fh):
		fd = self.files[fh]
		if fd['path'] == None:
			raise FuseOSError(ENOENT)

		# write back if dirty is set
		if fd['dirty'] == True:
			print '### UPDATE ', path
			paths = splitPath(path)
			self.conn.push(paths[0], paths[1], fd['data'])

		# reset fd
		fd['path'] = None
		fd['dirty'] = False
		fd['data'] = None
开发者ID:sangla1,项目名称:CloudFS,代码行数:104,代码来源:cloudfs.py


注:本文中的connector.Connector.rm方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。