Merge branch 'develop'
This commit is contained in:
commit
153620a700
|
@ -0,0 +1,18 @@
|
||||||
|
# Generated by Django 2.0.6 on 2018-09-04 10:31
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('projects', '0015_auto_20180824_1655'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='file',
|
||||||
|
name='path',
|
||||||
|
field=models.CharField(max_length=255, verbose_name='文件路径'),
|
||||||
|
),
|
||||||
|
]
|
|
@ -0,0 +1,18 @@
|
||||||
|
# Generated by Django 2.0.6 on 2018-09-04 10:36
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('projects', '0016_auto_20180904_1031'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='file',
|
||||||
|
name='path',
|
||||||
|
field=models.CharField(max_length=512, verbose_name='文件路径'),
|
||||||
|
),
|
||||||
|
]
|
|
@ -0,0 +1,23 @@
|
||||||
|
# Generated by Django 2.0.6 on 2018-09-04 10:55
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('projects', '0017_auto_20180904_1036'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='filesummary',
|
||||||
|
name='current_path',
|
||||||
|
field=models.CharField(default='', max_length=512, verbose_name='文件路径'),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='filesummary',
|
||||||
|
name='parent_path',
|
||||||
|
field=models.CharField(default='', max_length=512, verbose_name='父文件夹路径'),
|
||||||
|
),
|
||||||
|
]
|
|
@ -64,7 +64,7 @@ class File(models.Model):
|
||||||
('3', '即将上线'),
|
('3', '即将上线'),
|
||||||
]
|
]
|
||||||
name = models.CharField(max_length=255, verbose_name='文件名称')
|
name = models.CharField(max_length=255, verbose_name='文件名称')
|
||||||
path = models.CharField(max_length=200, verbose_name='文件路径')
|
path = models.CharField(max_length=512, verbose_name='文件路径')
|
||||||
super_path = models.ForeignKey("self", null=True, blank=True, verbose_name='上级目录', on_delete=models.CASCADE)
|
super_path = models.ForeignKey("self", null=True, blank=True, verbose_name='上级目录', on_delete=models.CASCADE)
|
||||||
project = models.ForeignKey(Project, verbose_name='工程名称', on_delete=models.CASCADE)
|
project = models.ForeignKey(Project, verbose_name='工程名称', on_delete=models.CASCADE)
|
||||||
type = models.CharField(max_length=3, choices=TYPE_CHOICE, default='0')
|
type = models.CharField(max_length=3, choices=TYPE_CHOICE, default='0')
|
||||||
|
@ -152,11 +152,11 @@ class FileSummary(models.Model):
|
||||||
anno_num = models.IntegerField(default=0, verbose_name='注释总数')
|
anno_num = models.IntegerField(default=0, verbose_name='注释总数')
|
||||||
isuue_num = models.IntegerField(default=0, verbose_name='系统问题总数')
|
isuue_num = models.IntegerField(default=0, verbose_name='系统问题总数')
|
||||||
question_num = models.IntegerField(default=0, verbose_name='用户提问总数')
|
question_num = models.IntegerField(default=0, verbose_name='用户提问总数')
|
||||||
parent_path = models.CharField(default="",max_length=255, verbose_name='父文件夹路径')
|
parent_path = models.CharField(default="",max_length=512, verbose_name='父文件夹路径')
|
||||||
line_num = models.IntegerField(default=0, verbose_name='代码总数')
|
line_num = models.IntegerField(default=0, verbose_name='代码总数')
|
||||||
method_num = models.IntegerField(default=0, verbose_name='方法总数')
|
method_num = models.IntegerField(default=0, verbose_name='方法总数')
|
||||||
file_num = models.IntegerField(default=0, verbose_name='文件总数')
|
file_num = models.IntegerField(default=0, verbose_name='文件总数')
|
||||||
current_path = models.CharField(default="",max_length=255, verbose_name='文件路径')
|
current_path = models.CharField(default="",max_length=512, verbose_name='文件路径')
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
db_table = 'File_Summary'
|
db_table = 'File_Summary'
|
||||||
|
|
|
@ -40,18 +40,22 @@ def gci(path, depth, project_id, root_path):
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging.info(str(datetime.now()) + ' 导入' + str(child) + '失败,错误原因是:' + str(e))
|
logging.info(str(datetime.now()) + ' 导入' + str(child) + '失败,错误原因是:' + str(e))
|
||||||
logging.info(str(datetime.now()) + '开始删除导入本工程文件,稍后重新导入')
|
logging.info(str(datetime.now()) + '开始删除导入本工程文件,稍后重新导入')
|
||||||
File.objects.filter(project_id=project_id).delete()
|
print(str(datetime.now()) + ' 导入' + str(child) + '失败,错误原因是:' + str(e))
|
||||||
|
# print(str(datetime.now()) + '删除完成稍后重新导入')
|
||||||
|
# File.objects.filter(project_id=project_id).delete()
|
||||||
logging.info(str(datetime.now()) + '删除完成稍后重新导入')
|
logging.info(str(datetime.now()) + '删除完成稍后重新导入')
|
||||||
|
|
||||||
|
|
||||||
def import_project(project_id, rel_path):
|
def import_project(project_id, rel_path):
|
||||||
logging.info(str(datetime.now()) + '准备导入工程主文件夹')
|
logging.info(str(datetime.now()) + '准备导入工程主文件夹')
|
||||||
|
print("准备导入工程主文件夹")
|
||||||
file = File()
|
file = File()
|
||||||
file.name = rel_path
|
file.name = rel_path
|
||||||
file.owner = 1
|
file.owner = 1
|
||||||
file.type = 1
|
file.type = 1
|
||||||
file.project_id = project_id
|
file.project_id = project_id
|
||||||
file.save()
|
file.save()
|
||||||
|
print(str(datetime.now()) + '导入' + str(file.path) + '工程主文件夹成功,准备递归导入子文件夹')
|
||||||
logging.info(str(datetime.now()) + '导入' + str(file.path) + '工程主文件夹成功,准备递归导入子文件夹')
|
logging.info(str(datetime.now()) + '导入' + str(file.path) + '工程主文件夹成功,准备递归导入子文件夹')
|
||||||
root_path = os.path.join(source_path, rel_path)
|
root_path = os.path.join(source_path, rel_path)
|
||||||
gci(root_path, 0, project_id, root_path)
|
gci(root_path, 0, project_id, root_path)
|
|
@ -31,7 +31,7 @@ class NewProjectView(View):
|
||||||
# print(Project.objects.filter(name=project_form.name))
|
# print(Project.objects.filter(name=project_form.name))
|
||||||
# if len(Project.objects.filter(name=project_form.name))>0:
|
# if len(Project.objects.filter(name=project_form.name))>0:
|
||||||
# return HttpResponse("导入失败,项目名字已存在,请联系管理员更换后台名字")
|
# return HttpResponse("导入失败,项目名字已存在,请联系管理员更换后台名字")
|
||||||
# logging.info('开始尝试导入工程')
|
logging.info('开始尝试导入工程')
|
||||||
project = project_form.save(commit=False)
|
project = project_form.save(commit=False)
|
||||||
print(project)
|
print(project)
|
||||||
# project.path = project.name
|
# project.path = project.name
|
||||||
|
@ -40,30 +40,32 @@ class NewProjectView(View):
|
||||||
project_id = project.id
|
project_id = project.id
|
||||||
root_path = project.path
|
root_path = project.path
|
||||||
try:
|
try:
|
||||||
# logging.info(str(datetime.now()) + '准备导入工程')
|
logging.info(str(datetime.now()) + '准备导入工程')
|
||||||
|
print("import_project start")
|
||||||
import_project(project_id, root_path)
|
import_project(project_id, root_path)
|
||||||
|
print("import_project done")
|
||||||
# scanner_project
|
# scanner_project
|
||||||
|
print("scanner_project start")
|
||||||
scanner_project_obj = scanner_project.Scanner_Project_Object()
|
scanner_project_obj = scanner_project.Scanner_Project_Object()
|
||||||
scanner_project_obj.get_anno_issue_summary("/opt/opengrok/source/"+project.name, project.id)
|
scanner_project_obj.get_anno_issue_summary("/opt/opengrok/source/"+project.name, project.id)
|
||||||
|
print("scanner_project done")
|
||||||
# 设置默认的权限,默认为所有人都可以看见
|
# 设置默认的权限,默认为所有人都可以看见
|
||||||
stragegy = AnnotationStrategy()
|
stragegy = AnnotationStrategy()
|
||||||
stragegy.project = project
|
stragegy.project = project
|
||||||
stragegy.choice = 1
|
stragegy.choice = 1
|
||||||
stragegy.save()
|
stragegy.save()
|
||||||
|
print("set annotationStrategy done")
|
||||||
# logging.info(str(datetime.now()) + '导入工程完成')
|
|
||||||
all_projects = Project.objects.all()
|
|
||||||
# return render(request, 'projects/list.html', locals())
|
# return render(request, 'projects/list.html', locals())
|
||||||
return HttpResponse("New Project Done!!")
|
return HttpResponse("New Project Done!!")
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(str(e))
|
print(str(e))
|
||||||
# logging.error(str(datetime.now()) + ' 导入' + str(project.name) + '失败,错误原因是:' + str(e) + '准备删除工程')
|
# # logging.error(str(datetime.now()) + ' 导入' + str(project.name) + '失败,错误原因是:' + str(e) + '准备删除工程')
|
||||||
# logging.info(str(datetime.now()) + '开始删除导入本工程,稍后重新导入')
|
# # logging.info(str(datetime.now()) + '开始删除导入本工程,稍后重新导入')
|
||||||
project.delete()
|
# project.delete()
|
||||||
# logging.info(str(datetime.now()) + '删除完成稍后重新导入')
|
# logging.info(str(datetime.now()) + '删除完成稍后重新导入')
|
||||||
error_msg = '导入失败,请查看日志发现错误后重新导入'
|
# error_msg = '导入失败,请查看日志发现错误后重新导入'
|
||||||
return render(request, 'projects/new.html', locals())
|
# return render(request, 'projects/new.html', locals())
|
||||||
|
|
||||||
class RemoveProjectView(View):
|
class RemoveProjectView(View):
|
||||||
def get(self, request):
|
def get(self, request):
|
||||||
|
|
|
@ -41,7 +41,7 @@ class Scanner_Project_Object:
|
||||||
self.fileid_issuenum_map = self.getFileIssueInfo(project_id)
|
self.fileid_issuenum_map = self.getFileIssueInfo(project_id)
|
||||||
self.fileid_questionnum_map = self.getFileQuestionInfo(project_id)
|
self.fileid_questionnum_map = self.getFileQuestionInfo(project_id)
|
||||||
|
|
||||||
# print(self.filepath_id_map)
|
print(self.filepath_id_map)
|
||||||
projectAnnoNum,projectIssueNum,projectQuestionNum = self.deepSearch(project_path)
|
projectAnnoNum,projectIssueNum,projectQuestionNum = self.deepSearch(project_path)
|
||||||
projectMethods,projectFiles,projectLines = self.deepSearchForMethod(project_path)
|
projectMethods,projectFiles,projectLines = self.deepSearchForMethod(project_path)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue