本文整理汇总了Python中API.create方法的典型用法代码示例。如果您正苦于以下问题:Python API.create方法的具体用法?Python API.create怎么用?Python API.create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类API
的用法示例。
在下文中一共展示了API.create方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run
# 需要导入模块: import API [as 别名]
# 或者: from API import create [as 别名]
def run(self):
self.lock.acquire()
self.data = fL.recv(self.connection)
dataSplit = self.data.split('|')
print self.data
msg = dataSplit[0]
if(msg == "CREATE"):
create = API.create(dataSplit[1])
if(create == 1):
self.connection.send("CREATE|1")
elif(msg == "APPEND"):
print "append"
append = API.append(dataSplit[1], dataSplit[2], True)
if(append):
self.connection.send("1")
print "1 sent for append"
elif(msg == "READ"):
read = API.read(dataSplit[1], 0, -1, "/var/www/fileshare/download/"+dataSplit[1])
if(read):
self.connection.send("1")
elif(msg == "STREAM"):
stream = API.stream(dataSplit[1], 0, -1, "/var/www/fileshare/download/"+dataSplit[1])
if(stream):
self.connection.send("1")
elif(msg == "FILELIST"):
filelist = API.fileList()
filelist = filelist[1:-1]
split = filelist.split(', ')
string = ""
for i in split:
string += str(i[1:-1]) + "|"
if(filelist):
self.connection.send(string)
#elif(msg == "DELETE"):
self.connection.close()
self.lock.release()
示例2: API
# 需要导入模块: import API [as 别名]
# 或者: from API import create [as 别名]
#!/usr/bin/env python
import API,sys
from API import API
API = API()
try:
if (sys.argv[1] == "files"):
API.fileList()
elif sys.argv[1] == "create":
filename = sys.argv[2]
API.create(filename)
elif sys.argv[1] == "append":
filename = sys.argv[2]
newData = sys.argv[3]
API.append(filename, newData, True)
elif sys.argv[1] == "read":
filename = sys.argv[2]
byteOffSet = sys.argv[3]
bytesToRead = sys.argv[4]
newName = sys.argv[5]
API.read(filename, byteOffSet, bytesToRead, newName)
elif sys.argv[1] == "delete":
filename = sys.argv[2]
API.delete(filename)