当前位置: 首页>>代码示例>>Python>>正文


Python File.active方法代码示例

本文整理汇总了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
开发者ID:velasquezerik,项目名称:django-roles-test,代码行数:17,代码来源:files_manage.py

示例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
开发者ID:velasquezerik,项目名称:django-roles-test,代码行数:17,代码来源:files_manage.py

示例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
开发者ID:velasquezerik,项目名称:django-roles-test,代码行数:48,代码来源:galatea_manage.py


注:本文中的models.File.active方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。