Пример #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")
Пример #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")
Пример #3
0
    def update(self, full=False):
        data = github_get_pull_request_all_v3("sympy/sympy")
        if full:
            data += github_get_pull_request_all_v3("sympy/sympy", "closed")
        p = PullRequest.all()
        p.filter("state =", "open")
        open_list = [x.num for x in p]
        for pull in data:
            num = pull["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['html_url']
            p.state = pull["state"]
            p.title = pull["title"]
            p.body = pull["body"]
            created_at = pull["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["user"]["login"])
                u.put()
            p.author = u

            p.put()
            # Update the rest with a specific query to the pull request:
            if num not in open_list:
                # open_list pull requests will be updated below
                taskqueue.add(url="/worker", queue_name="github",
                        params={"type": "pullrequest", "num": num})
        for num in open_list:
            taskqueue.add(url="/worker", queue_name="github",
                    params={"type": "pullrequest", "num": num})
        if full:
            for u in User.all():
                taskqueue.add(url="/worker", queue_name="github",
                        params={"type": "user", "login": u.login})
Пример #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()
Пример #5
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()