本文整理汇总了Python中models.File.ufid方法的典型用法代码示例。如果您正苦于以下问题:Python File.ufid方法的具体用法?Python File.ufid怎么用?Python File.ufid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.File
的用法示例。
在下文中一共展示了File.ufid方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: RegisterFile
# 需要导入模块: from models import File [as 别名]
# 或者: from models.File import ufid [as 别名]
def RegisterFile(Service=None, FileName=None, ProvisionedSpace="10G"):
if Service is None:
raise StorageError('RegisterFile(): Service can not be None')
if FileName is None:
raise StorageError('RegisterFile(): FileName can not be None')
vfilespace = StringSizeToBytes(ProvisionedSpace)
if Service.freespace - vfilespace > 0:
NewFile = File()
NewFile.vfilename = FileName
NewFile.ufid = GetUniqueFileID(FileName)
NewFile.pfilesize = 0
NewFile.vfilesize = vfilespace
NewFile.service = Service
NewFile.pfilename = GetPhysicalFileName(Service.localpath, FileName)
NewFile.status = 'O'
NewFile.save()
SFreeSpace = CalculateFreeSpace(Service)
Service.freespace = SFreeSpace
Service.save()
return NewFile
else:
raise StorageError('RegisterFile(): No have left space')
示例2: TakeOwnership
# 需要导入模块: from models import File [as 别名]
# 或者: from models.File import ufid [as 别名]
def TakeOwnership(Service=None, FileName=None):
if Service is None:
raise StorageError('TakeOwnership(): Service can not be None')
if FileName is None:
raise StorageError('TakeOwnership(): FileName can not be None')
if FileExist(Service.localpath,FileName,True):
NewFile = File()
NewFile.vfilename = FileName
NewFile.pfilename = FileName
NewFile.ufid = GetUniqueFileID(FileName)
NewFile.service = Service
NewFile.status = 'O'
NewFile.vfilesize = 0
NewFile.pfilesize = 0
NewFile.save()
CloseFile(NewFile.ufid)
return NewFile
else:
raise StorageError('TakeOwnership(): File not exit [%s%s]' % (Service.localpath+FileName))