本文整理汇总了Python中models.Folder.path方法的典型用法代码示例。如果您正苦于以下问题:Python Folder.path方法的具体用法?Python Folder.path怎么用?Python Folder.path使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Folder
的用法示例。
在下文中一共展示了Folder.path方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: compile_java
# 需要导入模块: from models import Folder [as 别名]
# 或者: from models.Folder import path [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
示例2: create_root_folder
# 需要导入模块: from models import Folder [as 别名]
# 或者: from models.Folder import path [as 别名]
def create_root_folder(user_id):
root = MEDIA_ROOT
user = User.objects.get(id=user_id)
directory = root +"/"+ user.username
print directory
if not os.path.exists(directory):
try:
folder = Folder()
folder.name = user.username
folder.path = directory
folder.user = user
folder.save()
os.makedirs(directory)
except Exception, e:
return False
else:
return True
示例3: create_new_folder
# 需要导入模块: from models import Folder [as 别名]
# 或者: from models.Folder import path [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