本文整理汇总了Python中models.File.status方法的典型用法代码示例。如果您正苦于以下问题:Python File.status方法的具体用法?Python File.status怎么用?Python File.status使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.File
的用法示例。
在下文中一共展示了File.status方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: RegisterFile
# 需要导入模块: from models import File [as 别名]
# 或者: from models.File import status [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 status [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))
示例3: csvUpload
# 需要导入模块: from models import File [as 别名]
# 或者: from models.File import status [as 别名]
def csvUpload(request):
global messages
messages = []
try:
template = 'fileupload.html'
form = SimpleFileForm()
if request.method == 'POST':
if 'file' in request.FILES:
#
# Final counters
#
numberWeeks = 0
numberTeamMembers = 0
numberActuals = 0
#
# Preprossesing file
#
csvfile = request.FILES['file']
fileName = csvfile.name
fileSize = csvfile.size
rawData = csvfile.read()
csvfile.seek(0)
csvData = csv.reader(csvfile)
fileDate = datetime.datetime.now()
#
# create file record
#
try:
f = File(name=fileName, uploadDate=fileDate, data=rawData,
status="This message means an internal error...")
f.save()
messages.append('Loaded file: "%s" [%d] on %s '% (fileName, fileSize, fileDate))
except:
messages.append('Error while saving csv file')
raise
#
# parse csv data
#
teamHead = []
teamData = {}
teamMemberHead = []
for row in csvData:
if not teamData:
if not teamHead:
#
# Working on Team and Metric Header
#
teamHead = row
#
# Testing team data
#
if len(teamHead)<2:
messages.append('Team Header row 1 has less than expected data')
if teamHead[teamName] != "Team Name":
messages.append('Expected Team Name Header not found')
if teamHead[metricName] != "Metric Name":
messages.append('Expected Metric Name Header not found')
else:
#
# Working on Team and Metric names
#
#
# testing team data
#
if len(row)<2:
messages.append('Error, Team Data has less than expected data')
raise
#
# Get Team and Metric objects
#
try:
team, created = Team.objects.get_or_create(name=row[0])
#team.save()
except:
messages.append('Error with team information')
raise
try:
metric, created = Metric.objects.get_or_create(team=team, name=row[1])
#metric.save()
except:
messages.append('Error with metric information')
raise
#.........这里部分代码省略.........