def update_pr(pr_number): logging.debug("Updating pull request %i" % pr_number) pr = Issue.get_or_create(pr_number) issue_response = raw_github_request(get_pulls_base() + '/%i' % pr_number, oauth_token=oauth_token, etag=pr.etag) if issue_response is None: logging.debug("PR %i hasn't changed since last visit; skipping" % pr_number) return "Done updating pull request %i (nothing changed)" % pr_number pr.pr_json = json.loads(issue_response.content) pr.etag = issue_response.headers["ETag"] pr.state = pr.pr_json['state'] pr.user = pr.pr_json['user']['login'] pr.updated_at = \ parse_datetime(pr.pr_json['updated_at']).astimezone(tz.tzutc()).replace(tzinfo=None) for issue_number in pr.parsed_title['jiras']: try: link_issue_to_pr("%s-%s" % (app.config['JIRA_PROJECT'], issue_number), pr) except: logging.exception("Exception when linking to JIRA issue %s-%s" % (app.config['JIRA_PROJECT'], issue_number)) try: start_issue_progress("%s-%s" % (app.config['JIRA_PROJECT'], issue_number)) except: logging.exception( "Exception when starting progress on JIRA issue %s-%s" % (app.config['JIRA_PROJECT'], issue_number)) pr.put() # Write our modifications back to the database subtasks = [".update_pr_comments", ".update_pr_review_comments", ".update_pr_files"] for task in subtasks: taskqueue.add(url=url_for(task, pr_number=pr_number), queue_name='fresh-prs') return "Done updating pull request %i" % pr_number
def update_pr(pr_number): logging.debug("Updating pull request %i" % pr_number) pr = Issue.get_or_create(pr_number) issue_response = raw_github_request(PULLS_BASE + '/%i' % pr_number, oauth_token=oauth_token, etag=pr.etag) if issue_response is None: logging.debug("PR %i hasn't changed since last visit; skipping" % pr_number) return "Done updating pull request %i (nothing changed)" % pr_number pr.pr_json = json.loads(issue_response.content) pr.etag = issue_response.headers["ETag"] pr.state = pr.pr_json['state'] pr.user = pr.pr_json['user']['login'] pr.updated_at = \ parse_datetime(pr.pr_json['updated_at']).astimezone(tz.tzutc()).replace(tzinfo=None) for issue_number in pr.parsed_title['jiras']: try: link_issue_to_pr("SPARK-%s" % issue_number, pr) except: logging.exception("Exception when linking to JIRA issue SPARK-%s" % issue_number) try: start_issue_progress("SPARK-%s" % issue_number) except: logging.exception( "Exception when starting progress on JIRA issue SPARK-%s" % issue_number) pr.put() # Write our modifications back to the database subtasks = [".update_pr_comments", ".update_pr_review_comments", ".update_pr_files"] for task in subtasks: taskqueue.add(url=url_for(task, pr_number=pr_number), queue_name='fresh-prs') return "Done updating pull request %i" % pr_number
def update(self, oauth_token): logging.debug("Updating pull request %i" % self.number) # Record basic information about this pull request issue_response = raw_github_request(PULLS_BASE + '/%i' % self.number, oauth_token=oauth_token, etag=self.etag) if issue_response is None: logging.debug("PR %i hasn't changed since last visit; skipping" % self.number) return self.pr_json = json.loads(issue_response.content) self.etag = issue_response.headers["ETag"] updated_at = \ parse_datetime(self.pr_json['updated_at']).astimezone(tz.tzutc()).replace(tzinfo=None) self.user = self.pr_json['user']['login'] self.updated_at = updated_at self.state = self.pr_json['state'] comments_response = paginated_github_request(ISSUES_BASE + '/%i/comments' % self.number, oauth_token=oauth_token, etag=self.comments_etag) if comments_response is not None: self.comments_json, self.comments_etag = comments_response pr_comments_response = paginated_github_request(PULLS_BASE + '/%i/comments' % self.number, oauth_token=oauth_token, etag=self.pr_comments_etag) if pr_comments_response is not None: self.pr_comments_json, self.pr_comments_etag = pr_comments_response files_response = paginated_github_request(PULLS_BASE + "/%i/files" % self.number, oauth_token=oauth_token, etag=self.files_etag) if files_response is not None: self.files_json, self.files_etag = files_response self.cached_last_jenkins_outcome = None self.last_jenkins_outcome # force recomputation of Jenkins outcome self.cached_commenters = self._compute_commenters() for issue_number in self.parsed_title['jiras']: try: link_issue_to_pr("SPARK-%s" % issue_number, self) except: logging.exception("Exception when linking to JIRA issue SPARK-%s" % issue_number) try: start_issue_progress("SPARK-%s" % issue_number) except: logging.exception( "Exception when starting progress on JIRA issue SPARK-%s" % issue_number) self.put() # Write our modifications back to the database