本文整理汇总了Python中models.File.active方法的典型用法代码示例。如果您正苦于以下问题:Python File.active方法的具体用法?Python File.active怎么用?Python File.active使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.File
的用法示例。
在下文中一共展示了File.active方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: upload_file
# 需要导入模块: from models import File [as 别名]
# 或者: from models.File import active [as 别名]
def upload_file(name, folder_id, f):
root = MEDIA_ROOT
folder = Folder.objects.get(id=folder_id)
# create a file
with open(folder.path + "/" + name, 'w') as destination:
for chunk in f.chunks():
destination.write(chunk)
file = File()
file.name = name
file.folder = folder
file.active = True
file.save()
return file.id
示例2: create_file
# 需要导入模块: from models import File [as 别名]
# 或者: from models.File import active [as 别名]
def create_file(name, folder_id):
root = MEDIA_ROOT
folder = Folder.objects.get(id=folder_id)
# Open a file
f = open(folder.path + "/" + name, "w")
# Close opend file
f.close()
file = File()
file.name = name
file.folder = folder
file.active = True
file.save()
return file.id
示例3: compile_java
# 需要导入模块: from models import File [as 别名]
# 或者: from models.File import active [as 别名]
def compile_java(file_id):
#first traslate
traslate_java(file_id)
file = File.objects.get(id=file_id)
folder = file.folder
user = folder.user
galatea_code = GALATEA + "galatea.jar "
code = "javac -cp "+ galatea_code + folder.path + "/*.java"
#print code
value = subprocess.check_output([code], shell=True)
#print value
#get all the file in this folder
for root, dirs, files in os.walk(folder.path):
root_folder = Folder.objects.get(path=root, name = os.path.basename(root))
for dir in dirs:
folders = Folder.objects.filter(father=root_folder.id)
esta = False
for folder in folders:
if folder.name == dir:
esta = True
if not esta:
folder = Folder()
folder.name = dir
folder.path = root_folder.path + "/" + dir
folder.user = user
folder.father = root_folder.id
folder.active = True
folder.save()
#print dirs
for file in files:
files_folder = File.objects.filter(folder = root_folder.id)
esta = False
for f in files_folder:
if f.name == file:
esta = True
if not esta:
if (os.path.splitext(file)[1] != ".class"):
f = File()
f.name = file
f.folder = root_folder
f.active = True
f.save()
return value