def GET(self):
     print 'Star'
     time1 = time.time()
     self.s = requests.Session()
     params = getInput(web.input())
     repos = params.get('githubs')
     repos = repos.replace('"','"')
     print repos
     _json_repos = json.loads(repos)
     username = params.get('username')
     self.s.cookies = read_cookies(username)
     self._repos = []
     threads = []
     self.repo_size = len(_json_repos)
     for repo in _json_repos:
         t = threading.Thread(target=self.status,args=(repo,))
         threads.append(t)
     for t in threads:
         t.setDaemon(True)
         t.start()
     while not self.repo_size == 0:
         pass
     
     _json_resp = json.dumps(self._repos)
     print _json_resp,time.time() - time1
     return _json_resp
Esempio n. 2
0
def GithubStarStatus(request):
    if 'githubs' in request.GET:
        t = int(time.time())
        model = Model()
        repos = request.GET['githubs']
        repos = repos.replace('"', '"')
        _json_repos = json.loads(repos)
        username = request.GET['username']
        model.s.cookies = read_cookies(username)
        threads = []
        model.repo_size = len(_json_repos)
        for repo in _json_repos:
            t = threading.Thread(target=status, args=(repo, model))
            threads.append(t)
        for t in threads:
            t.setDaemon(True)
            t.start()
        while model.repo_size is not 0 and (int(time.time()) - t < 6):
            pass
        if len(model._repos) < model.repo_size:
            print 'up 6 s time!!!!!!!!'

        print 'model._repos', model._repos
        _json_resp = json.dumps(model._repos)
        return HttpResponse(_json_resp)
def GithubStar(request):
    if 'github' in request.GET:
        s = requests.Session()
        repo = request.GET['github']
        username = request.GET['username']
        s.cookies = read_cookies(username)
        star = s.get('https://github.com/' + repo, verify=False)
        auto_token_content = re.findall(repo + '/star"(.*?)</div>', star.text)
        data = {
            'utf8': '%E2%9C%93',
            'authenticity_token': get_auth_token(auto_token_content[0])
        }
        s.headers.update({'X-Requested-With': 'XMLHttpRequest'})
        star_re = s.post('https://github.com/' + repo + '/star',
                         data=data,
                         verify=False)
        return HttpResponse(star_re.text)
def Follow(to_user, username):
    s = requests.Session()
    s.cookies = read_cookies(username)
    star = s.get('https://github.com/' + to_user, verify=False)
    # return star.text
    auto_token_content = re.findall('users/follow(.*?)</div>', star.text)
    print auto_token_content
    print auto_token_content
    data = {
        'utf8': '%E2%9C%93',
        'authenticity_token': get_auth_token(auto_token_content[0])
    }
    s.headers.update({'X-Requested-With': 'XMLHttpRequest'})
    follow_result = s.post('https://github.com/users/follow?target=' + to_user,
                           data=data,
                           verify=False)
    return follow_result.text
Esempio n. 5
0
 def GET(self):
     print 'Star'
     s = requests.Session()
     params = getInput(web.input())
     repo = params.get('github')
     username = params.get('username')
     s.cookies = read_cookies(username)
     star = s.get('https://github.com/' + repo,verify=False)
     auto_token_content = re.findall(repo + '/star"(.*?)</div>',star.text)
     print auto_token_content
     data = {
         'utf8':'%E2%9C%93',
         'authenticity_token':get_auth_token(auto_token_content[0])
     }
     s.headers.update({'X-Requested-With':'XMLHttpRequest'})
     star_re = s.post('https://github.com/' + repo + '/star',data=data,verify=False)
     return star_re.text