Exemple #1
0
 def post(self, url_path):
     last_row = UploadURL.all().order("-created_at").get()
     if last_row:
         if last_row.url_path == url_path:
             try:
                 payload = json.loads(self.request.get("payload"))
                 logging.info(payload)
             except json.JSONDecodeError:
                 self.error(400)
                 self.response.out.write("Incorrect request format\n")
             user_repo = payload["repository"]["full_name"]
             # Download complete pull request with information about mergeability
             pull_request = github_get_pull_request(user_repo,
                                                    payload["number"])
             num = payload["number"]
             # Get the old entity or create a new one:
             p = PullRequest.all()
             p.filter("num =", int(num))
             p = p.get()
             if p is None:
                 p = PullRequest(num=num)
             # Update all data that we can from GitHub:
             p.url = pull_request["html_url"]
             p.state = pull_request["state"]
             p.title = pull_request["title"]
             p.body = pull_request["body"]
             p.mergeable = pull_request["mergeable"]
             if pull_request["head"]["repo"]:
                 p.repo = pull_request["head"]["repo"]["url"]
             p.branch = pull_request["head"]["ref"]
             p.author_name = pull_request["user"].get("name", "")
             p.author_email = pull_request["user"].get("email", "")
             created_at = pull_request["created_at"]
             created_at = datetime.strptime(created_at,
                                            "%Y-%m-%dT%H:%M:%SZ")
             p.created_at = created_at
             u = User.all()
             u.filter("login ="******"user"]["login"])
             u = u.get()
             if u is None:
                 u = User(login=pull_request["user"]["login"])
                 u.id = pull_request["user"]["id"]
                 u.avatar_url = pull_request["user"]['avatar_url']
                 u.url = pull_request["user"]["url"]
                 u.put()
             p.author = u
             p.put()
         else:
             self.error(404)
             self.response.out.write("Requesting URL doesn't exist\n")
     else:
         self.error(500)
         self.response.out.write("URL for posting data not defined yet\n")
Exemple #2
0
 def post(self, url_path):
     last_row = UploadURL.all().order("-created_at").get()
     if last_row:
         if last_row.url_path == url_path:
             try:
                 payload = json.loads(self.request.get("payload"))
                 logging.info(payload)
             except json.JSONDecodeError:
                 self.error(400)
                 self.response.out.write("Incorrect request format\n")
             user_repo = payload["repository"]["full_name"]
             # Download complete pull request with information about mergeability
             pull_request = github_get_pull_request(user_repo, payload["number"])
             num = payload["number"]
             # Get the old entity or create a new one:
             p = PullRequest.all()
             p.filter("num =", int(num))
             p = p.get()
             if p is None:
                 p = PullRequest(num=num)
             # Update all data that we can from GitHub:
             p.url = pull_request["html_url"]
             p.state = pull_request["state"]
             p.title = pull_request["title"]
             p.body = pull_request["body"]
             p.mergeable = pull_request["mergeable"]
             if pull_request["head"]["repo"]:
                 p.repo = pull_request["head"]["repo"]["url"]
             p.branch = pull_request["head"]["ref"]
             p.author_name = pull_request["user"].get("name", "")
             p.author_email = pull_request["user"].get("email", "")
             created_at = pull_request["created_at"]
             created_at = datetime.strptime(created_at, "%Y-%m-%dT%H:%M:%SZ")
             p.created_at = created_at
             u = User.all()
             u.filter("login ="******"user"]["login"])
             u = u.get()
             if u is None:
                 u = User(login=pull_request["user"]["login"])
                 u.id = pull_request["user"]["id"]
                 u.avatar_url = pull_request["user"]['avatar_url']
                 u.url = pull_request["user"]["url"]
                 u.put()
             p.author = u
             p.put()
         else:
             self.error(404)
             self.response.out.write("Requesting URL doesn't exist\n")
     else:
         self.error(500)
         self.response.out.write("URL for posting data not defined yet\n")
Exemple #3
0
    def post(self):
        user_repo = polled_user + "/" + polled_repo
        payload = github_get_pull_request_all_v3(user_repo)
        # checkout mergeability
        for pos in xrange(len(payload)):
            pull = github_get_pull_request(user_repo, payload[pos]["number"])
            payload[pos]["mergeable"] = pull["mergeable"]
        # Process each pull request from payload
        for pull in payload:
            p = PullRequest.all()
            num = pull["number"]
            p.filter("num =", num)
            p = p.get()
            if p is None:
                p = PullRequest(num=num)
            p.url = pull["html_url"]
            p.state = pull["state"]
            p.title = pull["title"]
            p.body = pull["body"]
            p.mergeable = pull["mergeable"]
            if pull["head"]["repo"]:
                p.repo = pull["head"]["repo"]["url"]
            p.branch = pull["head"]["ref"]
            created_at = pull["created_at"]
            created_at = datetime.strptime(created_at, "%Y-%m-%dT%H:%M:%SZ")
            p.created_at = created_at

            # Collect public information about user
            u = User.all()
            login = pull["user"]["login"]
            u.filter("login ="******"user"]["id"]
            u.avatar_url = pull["user"]["avatar_url"]
            u.url = pull["user"]["url"]
            u.put()

            p.author = u
            p.put()
Exemple #4
0
    def post(self):
        user_repo = polled_user + "/" + polled_repo
        payload = github_get_pull_request_all_v3(user_repo)
        # checkout mergeability
        for pos in xrange(len(payload)):
            pull = github_get_pull_request(user_repo, payload[pos]["number"])
            payload[pos]["mergeable"] = pull["mergeable"]
        # Process each pull request from payload
        for pull in payload:
            p = PullRequest.all()
            num = pull["number"]
            p.filter("num =", num)
            p = p.get()
            if p is None:
                p = PullRequest(num=num)
            p.url = pull["html_url"]
            p.state = pull["state"]
            p.title = pull["title"]
            p.body = pull["body"]
            p.mergeable = pull["mergeable"]
            if pull["head"]["repo"]:
                p.repo = pull["head"]["repo"]["url"]
            p.branch = pull["head"]["ref"]
            created_at = pull["created_at"]
            created_at = datetime.strptime(created_at, "%Y-%m-%dT%H:%M:%SZ")
            p.created_at = created_at

            # Collect public information about user
            u = User.all()
            login = pull["user"]["login"]
            u.filter("login ="******"user"]["id"]
            u.avatar_url = pull["user"]["avatar_url"]
            u.url = pull["user"]["url"]
            u.put()

            p.author = u
            p.put()
Exemple #5
0
 def txn():
     assert _type == "pullrequest"
     _num = int(self.request.get("num"))
     pull = github_get_pull_request("sympy/sympy", _num)
     p = PullRequest.all()
     p.filter("num =", int(_num))
     p = p.get()
     if p is None:
         p = PullRequest(num=_num)
     p.url = pull['html_url']
     p.state = pull["state"]
     p.title = pull["title"]
     p.body = pull["body"]
     p.mergeable = pull["mergeable"]
     if pull['head']['repo']:
         p.repo = pull['head']['repo']['url']
     p.branch = pull['head']['ref']
     p.author_name = pull["user"].get("name", "")
     p.author_email = pull["user"].get("email", "")
     created_at = pull["created_at"]
     created_at = datetime.strptime(created_at, "%Y-%m-%dT%H:%M:%SZ")
     p.created_at = created_at
     p.put()