def collect(self): tc = self._create_team_city_connection() MetricsCollector.logger.info("Getting projects from TeamCity") projects = tc.get_projects() MetricsCollector.logger.info("Got %s projects from TeamCity", len(projects["project"])) filtering = CollectorFilter() root = Project("_Root", "Root Project") for p in filter(lambda p: p["id"] != root.id, projects["project"]): project = Project.from_dict(p) if not filtering.include(project): MetricsCollector.logger.debug( "Ignoring project {}".format(project)) continue parent = root.find(p["parentProjectId"]) MetricsCollector.logger.info("Adding '%s' to the project '%s'", project.name, parent.name) parent.append(project) self.threads = [] root.walk(self._collect) self._wait_for_population_to_complete() return root
def api_get_project(*, id): project = yield from Project.find(id) charts = yield from Chart.findAll('project_id=?', [id], orderBy='created_at desc') for chart in charts: chart.option = json.loads(chart.option) return dict(project=project, charts=charts)
def api_save_project(request, *, id, title, summary): if not title or not title.strip(): raise APIValueError('title', 'title cannot be empty.') if not summary or not summary.strip(): raise APIValueError('summary', 'summary cannot be empty.') project = yield from Project.find(id) project.status = True project.title = title project.summary = summary yield from project.update() return project
def api_save_project(request, *, id, title, summary): if not title or not title.strip(): raise APIValueError('title', 'title cannot be empty.') if not summary or not summary.strip(): raise APIValueError('summary', 'summary cannot be empty.') project = yield from Project.find(id) project.status = True project.title = title project.summary =summary yield from project.update() return project
def getAllProject(): projectList = [] for item in Project.find(): project = { 'id' : item['id'], 'name' : item['name'], 'description' : item['description'], } projectList.append(project) return projectList
def api_delete_project(project_id, request): logging.info("====>api_delete_project:删除的项目ID为:%s" % project_id) # # 先检查是否是管理员操作,只有管理员才有删除评论权限 # check_admin(request) # # 查询一下评论id是否有对应的评论 p = yield from Project.find(project_id) # 没有的话抛出错误 if p is None: raise APIResourceNotFoundError('Project') # 有的话删除 yield from p.remove() return dict(project_id=project_id)
def get_project(project_id): # 根据博客id查询该条信息 project = yield from Project.find(project_id) # # 根据博客id查询该条博客的评论 # comments = yield from Comment.findAll('blog_id=?', [project_id], orderBy='created_at desc') # # markdown2是个扩展模块,这里把博客正文和评论套入到markdonw2中 # for c in comments: # c.html_content = text2html(c.content) # project.html_content = markdown2.markdown(project.content) # 返回页面 return { '__template__': 'manage_project_query.html', 'project': project #'comments': comments }
def api_modify_project(request, *, project_id,project_name,project_level,project_status,project_stage,project_docFlag,**kwargs): logging.info("====>api_modify_project:修改的项目编号为:%s", project_id) # name,id,level 不能为空 if not project_name or not project_name.strip(): raise APIValueError('name', 'name cannot be empty') if not project_level or not project_level.strip(): raise APIValueError('level', 'level cannot be empty') if not project_id or not project_id.strip(): raise APIValueError('project_id', 'project_id cannot be empty') # 获取指定id的project数据 project_r = yield from Project.find(project_id) project_r.project_name = project_name project_r.project_level = project_level project_r.project_id = project_id project_r.project_status = project_status project_r.project_stage = project_stage project_r.project_docFlag = project_docFlag # 保存 yield from project_r.update() return project_r
def api_get_project(*, project_id): # 获取某条项目的信息 project = yield from Project.find(project_id) return project
def api_delete_project(request, *, id): check_admin(request) project = yield from Project.find(id) yield from project.remove() return dict(id=id)