本文整理汇总了Python中connector.Connector.push方法的典型用法代码示例。如果您正苦于以下问题:Python Connector.push方法的具体用法?Python Connector.push怎么用?Python Connector.push使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类connector.Connector
的用法示例。
在下文中一共展示了Connector.push方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: CloudFS
# 需要导入模块: from connector import Connector [as 别名]
# 或者: from connector.Connector import push [as 别名]
class CloudFS(LoggingMixIn, Operations):
def __init__(self):
# initialize file table
self.maxFiles = 1024
# self.files = [dict(path=None, dirty=False, data=None)] * self.maxFiles
self.files = [None] * self.maxFiles
for i in range(0, self.maxFiles):
self.files[i] = dict(path=None, dirty=False, data=None)
self.conn = Connector()
def chmod(self, path, mode):
# chmod is not allowed
raise FuseOSError(EPERM)
def chown(self, path, uid, gid):
# chown is not allowed
raise FuseOSError(EPERM)
def create(self, path, mode):
# create file
paths = splitPath(path)
print path, paths
if paths[0] == '':
raise FuseOSError(EPERM)
# search available fd
fd = None
fdNum = -1
for i in range(0, self.maxFiles):
fd = self.files[i]
print i
if fd['path'] == None:
# print "MATCH!!!"
# print fdNum
fdNum = i
break
if fd == None:
raise FuseOSError(ENOENT)
fd['path'] = path
fd['dirty'] = True
fd['data'] = ''
paths = splitPath(path)
self.conn.push(paths[0], paths[1], fd['data'])
return fdNum
def getattr(self, path, fh=None):
now = time()
paths = splitPath(path)
# if root?
if paths[0] == '':
return dict(st_mode=(S_IFDIR | 0755), st_ctime=now, st_mtime=now, st_atime=now, st_nlink=2)
attr = self.conn.getAttr(paths[0], paths[1])
if attr != None:
return attr
else:
raise FuseOSError(ENOENT)
def getxattr(self, path, name, position=0):
return ''
def listxattr(self, path):
raise FuseOSError(EPERM)
def mkdir(self, path, mode):
paths = splitPath(path)
# mkdir is not allowed under root dir
if paths[1] == '':
raise FuseOSError(EPERM)
if self.conn.mkdir(paths[0], paths[1]) != True:
raise FuseOSError(EPERM)
def open(self, path, flags):
paths = splitPath(path)
# cannot open files under root dir
print path, paths
if paths[0] == '':
raise FuseOSError(EPERM)
# cache file content from storage
content = self.conn.pull(paths[0], paths[1])
if paths[0] == None:
raise FuseOSError(ENOENT)
# search available file
fd = None
fdNum = -1
for i in range(0, self.maxFiles):
fd = self.files[i]
if fd['path'] == None:
fdNum = i
break
if fd == None:
raise FuseOSError(ENOENT)
#.........这里部分代码省略.........