Exemple #1
0
 def _do_event(self, event):
     username = event['username']
     reponame = event['reponame']
     remote_git_url = event['remote_git_url']
     local_user = GsuserManager.get_user_by_name(username)
     local_repo = RepoManager.get_repo_by_name(username, reponame)
     if local_user is None or local_repo is None or local_repo.status == 0:
         return
     local_repo_path = local_repo.get_abs_repopath()
     if os.path.exists(local_repo_path):
         return
     args = ['/bin/bash', '/opt/bin/git-import-remote-repo.sh'
             ] + [local_repo_path, remote_git_url]
     try:
         popen = Popen(args, stdout=PIPE, shell=False, close_fds=True)
         output = popen.communicate()[0].strip()
         returncode = popen.returncode
         if returncode == 0:
             RepoManager.check_export_ok_file(local_repo)
             diff_size = long(output)
             RepoManager.update_user_repo_quote(local_user, local_repo,
                                                diff_size)
             local_repo.status = 0
             local_repo.save()
         else:
             local_repo.status = 500
             local_repo.save()
     except Exception, e:
         local_repo.status = 500
         local_repo.save()
         logger.exception(e)
Exemple #2
0
 def _do_event(self, event):
     username = event['username']
     reponame = event['reponame']
     remote_git_url = event['remote_git_url']
     local_user = GsuserManager.get_user_by_name(username)
     local_repo = RepoManager.get_repo_by_name(username, reponame)
     if local_user is None or local_repo is None or local_repo.status == 0:
         return
     local_repo_path = local_repo.get_abs_repopath()
     if os.path.exists(local_repo_path):
         return
     args = ['/bin/bash', '/opt/bin/git-import-remote-repo.sh'] + [local_repo_path, remote_git_url]
     try:
         popen = Popen(args, stdout=PIPE, shell=False, close_fds=True)
         output = popen.communicate()[0].strip()
         returncode = popen.returncode
         if returncode == 0:
             RepoManager.check_export_ok_file(local_repo)
             diff_size = long(output)
             RepoManager.update_user_repo_quote(local_user, local_repo, diff_size)
             local_repo.status = 0
             local_repo.save()
         else:
             local_repo.status = 500
             local_repo.save()
     except Exception, e:
         local_repo.status = 500
         local_repo.save()
         logger.exception(e)
Exemple #3
0
def update_quote(user, userprofile, repo, repopath, parameters):
    args = ['/opt/bin/diff-tree-blob-size.sh', repopath]
    args.extend(parameters)
    popen = Popen(args, stdout=PIPE, shell=False, close_fds=True)
    result = popen.communicate()[0].strip()
    diff_size = 0
    if popen.returncode == 0:
        if result.startswith('+') or result.startswith('-'):
            diff_size = int(result)
        else:
            diff_size = int(result) - repo.used_quote
    RepoManager.update_user_repo_quote(userprofile, repo, diff_size)
Exemple #4
0
def update_quote(user, userprofile, repo, repopath, parameters):
    args = ['/opt/bin/diff-tree-blob-size.sh', repopath]
    args.extend(parameters)
    popen = Popen(args, stdout=PIPE, shell=False, close_fds=True)
    result = popen.communicate()[0].strip()
    diff_size = 0
    if popen.returncode == 0:
        if result.startswith('+') or result.startswith('-'):
            diff_size = int(result)
        else:
            diff_size = int(result) - repo.used_quote
    RepoManager.update_user_repo_quote(userprofile, repo, diff_size)