def post(self): user = users.get_current_user() name = cgi.escape(self.request.get('name')) description = cgi.escape(self.request.get('description')) project = Project(name= name, description= description) project.users.append(user) project.put() self.response.out.write('ok')
def load_project(project_id): """loads a project by the provided ID""" with app.app_context(): location = app.config.get("LIBINTEL_DATA_DIR") path_to_file = location + '/out/' + project_id + '.json' with open(path_to_file) as json_file: project = json.load(json_file) json_file.close() return Project(**project)
def get_all_project_names(sig_list): logger.info("Start to get all project names.") for sig in sig_list: url = URL_SIG + sig.get_name() + PATH_PROJECT print("Start to get projects for sig " + sig.get_name()) names = get_all_pattern_strings_from_a_url(url, PATTERN_PROJECT) for name in names: project = Project(name) sig.add_project(project) print("End to get projects for sig " + sig.get_name()) logger.info("End to get all project names.")
def post(self, project_key): project_key = cgi.escape(project_key) project = Project.get(project_key) print project name = cgi.escape(self.request.get('name')) print name description = cgi.escape(self.request.get('description')) print description item = Item(name= name, description= description, project= project) item.put() self.response.out.write('ok')
def get(self): user = users.get_current_user() projects = Project.all(keys_only=False) projects.filter('users =', user) projects.run() json = jsonize() projects_list = [] for project in projects: projects_list.append(json.to_dict(project)) self.response.headers['Content-Type'] = 'application/json' self.response.out.write(projects_list)
def post(self): user = users.get_current_user() key = cgi.escape(self.request.get('key')) project = Project.get(key) if (user in project.users): user_mail = cgi.escape(self.request.get('userMail')) user = users.User(user_mail) project.users.append(user) project.put() self.response.out.write('ok') else: self.response.out.write('fail')
def get(self, project_key): project_key = cgi.escape(project_key) project = Project.get(project_key) print project items = Item.all() items.filter('project =', project) items.run() json = jsonize() items_list = [] for item in items: items_list.append(json.to_dict(item)) self.response.headers['Content-Type'] = 'application/json' self.response.out.write(items_list)
def post(self): user = users.get_current_user() key = Key(cgi.escape(self.request.get('key'))) projects = Project.all() projects.filter('users =', user) projects.filter('__key__ = ', key) projects.run() project = projects.fetch(1) if project: project[0].delete() self.response.out.write('ok') else: self.response.out.write('fail')
def main(): # load arguments arguments = argumentsParser() # filter logs if (not arguments.debug): logger.remove() # filter arguments filterArgument(arguments) # starter program initMenu() # init object project project = Project().initProject(arguments) # carrega o menu da solution solutionMenu(project) # fltra as respostas do menu filterAnswerMenu(project)
def load_all_projects(): """loads all available projects""" with app.app_context(): location = app.config.get("LIBINTEL_DATA_DIR") projects = ProjectList(None) list_filenames = os.listdir(location + '/out/') for filename in list_filenames: if filename.endswith('.json'): path_to_file = location + '/out/' + filename try: with open(path_to_file) as json_file: project = json.load(json_file) json_file.close() projects.add_project(Project(**project)) except FileNotFoundError: continue except TypeError: continue return projects
def post(self, project_key): project_key = cgi.escape(project_key) project = Project.get(project_key) ItemKey = cgi.escape(self.request.get('ItemKey')) items = Item.all() Items.filter('project =', project) Items.filter('__key__= ', ItemKey) Items.run() item = Items.fetch(1) if item: item[0].delete() self.response.out.write('ok') else: self.response.out.write('fail')
def create_new_project(): """ creates the project folder if it not exists :return: the newly created or updated project. returns 500 if errors occurs on writing the project to disc. """ project_json = request.get_json(silent=True) project = Project(**project_json) if re.match('\d+', project.project_id) or re.match( '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\Z', project.project_id): print('valid ID') try: project_service.create_project(project) app.logger.info('project {}: created'.format(project.project_id)) return json.dumps(project, default=lambda o: o.__getstate__()) except IOError: app.logger.error('project {}: could not create project'.format( project.project_id)) return Response("could not create project", status=500) else: app.logger.error('project {}: invalid ID'.format(project.project_id)) return Response("could not create project", status=500)
logger.info("Start to get all issues of a project.") issues = [] patten_issue = FORMAT_ISSUE.format(project.get_name()) issue_strings = get_all_pattern_strings_from_a_url( SRC_OPENEULER + project.get_name() + "/issues", patten_issue) for e in issue_strings: issue = Issue('', GITEE + e, IssueStatus.OPEN) issues.append(issue) logger.info("End to get all issues of a project.") return issues @staticmethod def get_all_prs(project): logger.info("Start to get all pull requests of a project.") prs = [] patten_pr = FORMAT_PULLREQUEST.format(project.get_name()) pr_strings = get_all_pattern_strings_from_a_url( SRC_OPENEULER + project.get_name() + "/pulls", patten_pr) for e in pr_strings: pr = PullRequest('', GITEE + e, PullRequestStatus.OPEN) prs.append(pr) logger.info("End to get all pull requests of a project.") return prs if __name__ == '__main__': from model.Project import Project project = Project("tensorflow") prs = ProjectHelp.get_all_prs(project) print(prs)