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


Python Folder.father方法代码示例

本文整理汇总了Python中models.Folder.father方法的典型用法代码示例。如果您正苦于以下问题:Python Folder.father方法的具体用法?Python Folder.father怎么用?Python Folder.father使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在models.Folder的用法示例。


在下文中一共展示了Folder.father方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: compile_java

# 需要导入模块: from models import Folder [as 别名]
# 或者: from models.Folder import father [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

示例2: create_new_folder

# 需要导入模块: from models import Folder [as 别名]
# 或者: from models.Folder import father [as 别名]
def create_new_folder(user_id,father_id,name):
	root = MEDIA_ROOT
	user = User.objects.get(id=user_id)
	father = Folder.objects.get(id=father_id)
	directory = father.path +"/"+ name
	id_folder = 0
	print directory
	if not os.path.exists(directory):
		try:
			folder = Folder()
			folder.name = name
			folder.path = directory
			folder.user = user
			folder.father = father.id
			folder.active = True
			folder.save()
			id_folder = folder.id
			os.makedirs(directory)
		except Exception, e:
			return id_folder
		else:
			return id_folder
开发者ID:velasquezerik,项目名称:django-roles-test,代码行数:24,代码来源:files_manage.py


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