当前位置: 首页>>代码示例>>Python>>正文


Python seaserv.get_commits函数代码示例

本文整理汇总了Python中seaserv.get_commits函数的典型用法代码示例。如果您正苦于以下问题:Python get_commits函数的具体用法?Python get_commits怎么用?Python get_commits使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了get_commits函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get

    def get(self, request, repo_id, format=None):
        repo = get_repo(repo_id)
        if not repo:
            return api_error(status.HTTP_404_NOT_FOUND, 'Repo not found.')

        # check whether user is repo owner
        if validate_owner(request, repo_id):
            owner = "self"
        else:
            owner = "share"

        last_commit = get_commits(repo.id, 0, 1)[0]
        repo.latest_modify = last_commit.ctime if last_commit else None

        # query repo infomation
        repo.size = seafserv_threaded_rpc.server_repo_size(repo_id)
        current_commit = get_commits(repo_id, 0, 1)[0]
        root_id = current_commit.root_id if current_commit else None

        repo_json = {
            "type":"repo",
            "id":repo.id,
            "owner":owner,
            "name":repo.name,
            "desc":repo.desc,
            "mtime":repo.latest_modify,
            "size":repo.size,
            "encrypted":repo.encrypted,
            "root":root_id,
            }

        return Response(repo_json)
开发者ID:viktorlindgren,项目名称:seahub,代码行数:32,代码来源:views.py

示例2: get

    def get(self, request, repo_id, format=None):
        # check whether user can view repo
        repo = get_repo(repo_id)
        if not repo:
            return api_error('404')

        # if not can_access_repo(request, repo.id):
        #     return api_error('403')

        # check whether use is repo owner
        if validate_owner(request, repo_id):
            owner = "self"
        else:
            owner = "share"

        last_commit = get_commits(repo.id, 0, 1)[0].ctime
        repo.latest_modify = last_commit.ctime if last_commit else None

        # query repo infomation
        repo.size = seafserv_threaded_rpc.server_repo_size(repo_id)
        current_commit = get_commits(repo_id, 0, 1)[0]
        root_id = current_commit.root_id if current_commit else None

        # generate download url for client
        ccnet_applet_root = get_ccnetapplet_root()
        relay_id = get_session_info().id
        addr, port = get_ccnet_server_addr_port ()
        email = quote(request.user.username)
        token = get_repo_token_nonnull(repo_id, request.user.username)
        quote_repo_name = quote(repo.name.encode('utf-8'))
        enc = 1 if repo.encrypted else ''

        url = ccnet_applet_root + "/repo/download/"
        url += "?relay_id=%s&relay_addr=%s&relay_port=%s" % (relay_id, addr, port)
        url += "&email=%s&token=%s" % (email, token)
        url += "&repo_id=%s&repo_name=%s&encrypted=%s" % (repo_id, quote_repo_name, enc)
        
        repo_json = {
            "type":"repo",
            "id":repo.id,
            "owner":owner,
            "name":repo.name,
            "desc":repo.desc,
            "mtime":repo.lastest_modify,
            "size":repo.size,
            "encrypted":repo.encrypted,
            "root":root_id,
            "download_url": url,
            }

        return Response(repo_json)
开发者ID:strogo,项目名称:seahub,代码行数:51,代码来源:views.py

示例3: calculate_repo_last_modify

def calculate_repo_last_modify(repo_list):
    """
    Get last modify time for repo. 
    
    """
    for repo in repo_list:
        repo.latest_modify = get_commits(repo.id, 0, 1)[0].ctime
开发者ID:chuyskywalker,项目名称:seahub,代码行数:7,代码来源:__init__.py

示例4: check_filename_with_rename

def check_filename_with_rename(repo_id, parent_dir, filename):
    cmmts = get_commits(repo_id, 0, 1)
    latest_commit = cmmts[0] if cmmts else None
    if not latest_commit:
        return ''
    # TODO: what if parrent_dir does not exist?
    dirents = seafile_api.list_dir_by_commit_and_path(repo_id, latest_commit.id,
                                                      parent_dir.encode('utf-8'))

    def no_duplicate(name):
        for dirent in dirents:
            if dirent.obj_name == name:
                return False
        return True

    def make_new_name(filename, i):
        base, ext = os.path.splitext(filename)
        if ext:
            new_base = "%s (%d)" % (base, i)
            return new_base + ext
        else:
            return "%s (%d)" % (filename, i)

    if no_duplicate(filename):
        return filename
    else:
        i = 1
        while True:
            new_name = make_new_name (filename, i)
            if no_duplicate(new_name):
                return new_name
            else:
                i += 1
开发者ID:jamjr,项目名称:seahub,代码行数:33,代码来源:__init__.py

示例5: calculate_repo_info

def calculate_repo_info(repo_list, username):
    """
    Get some info for repo.

    """
    for repo in repo_list:
        try:
            commit = get_commits(repo.id, 0, 1)[0]
            repo.latest_modify = commit.ctime
            repo.root = commit.root_id
            repo.size = seafserv_threaded_rpc.server_repo_size(repo.id)
            if not repo.size :
                repo.size = 0;

            password_need = False
            if repo.encrypted:
                try:
                    ret = seafserv_rpc.is_passwd_set(repo.id, username)
                    if ret != 1:
                        password_need = True
                except SearpcErroe, e:
                    pass
            repo.password_need = password_need
        except Exception,e:
            repo.latest_modify = 0
            repo.commit = None
            repo.size = -1
            repo.password_need = None
开发者ID:hilerchyn,项目名称:seahub,代码行数:28,代码来源:views.py

示例6: check_filename_with_rename

def check_filename_with_rename(repo_id, parent_dir, filename):
    latest_commit = get_commits(repo_id, 0, 1)[0]
    if not latest_commit:
        return ''
    dirents = seafserv_threaded_rpc.list_dir_by_path(latest_commit.id,
                                         parent_dir.encode('utf-8'))

    def no_duplicate(name):
        for dirent in dirents:
            if dirent.obj_name == name:
                return False
        return True

    def make_new_name(filename, i):
        base, ext = os.path.splitext(filename)
        if ext:
            new_base = "%s (%d)" % (base, i)
            return new_base + ext
        else:
            return "%s (%d)" % (filename, i)

    if no_duplicate(filename):
        return filename
    else:
        i = 1
        while True:
            new_name = make_new_name (filename, i)
            if no_duplicate(new_name):
                return new_name
            else:
                i += 1
开发者ID:strogo,项目名称:seahub,代码行数:31,代码来源:utils.py

示例7: calculate_repo_last_modify

def calculate_repo_last_modify(repo_list):
    """
    Get last modify time for repo. 
    
    """
    for repo in repo_list:
        cmmts = get_commits(repo.id, 0, 1)
        repo.latest_modify = cmmts[0].ctime if cmmts else 0
开发者ID:bearstech,项目名称:seahub,代码行数:8,代码来源:__init__.py

示例8: get_current_commit

 def get_current_commit(self):
     commit_id = self.request.GET.get('commit_id', '')
     if not commit_id:
         return HttpResponseRedirect(reverse('repo', args=[self.repo.id]))
     current_commit = get_commit(commit_id)
     if not current_commit:
         current_commit = get_commits(self.repo.id, 0, 1)[0]
     return current_commit
开发者ID:orymate,项目名称:seahub,代码行数:8,代码来源:repo.py

示例9: calculate_repo_info

def calculate_repo_info(repo_list, username):
    """
    Get some info for repo.

    """
    for repo in repo_list:
        commit = get_commits(repo.id, 0, 1)[0]
        if not commit:
            continue
        repo.latest_modify = commit.ctime
        repo.root = commit.root_id
        repo.size = server_repo_size(repo.id)
开发者ID:jamjr,项目名称:seahub,代码行数:12,代码来源:utils.py

示例10: check_has_subdir

    def check_has_subdir(repo):
        latest_commit = seaserv.get_commits(repo.id, 0, 1)[0]
        if not latest_commit:
            return False
        if latest_commit.root_id == EMPTY_SHA1:
            return False

        try:
            dirs = seafile_api.list_dir_by_commit_and_path(latest_commit.id, '/')
        except Exception, e:
            logger.error(e)
            return False
开发者ID:jjjasont,项目名称:seahub,代码行数:12,代码来源:repo.py

示例11: reloaddir

def reloaddir(request, repo_id, parent_dir):
    current_commit = get_commits(repo_id, 0, 1)[0]
    if not current_commit:
        return api_error(status.HTTP_500_INTERNAL_SERVER_ERROR,
                         'Failed to get current commit of repo %s.' % repo_id)

    try:
        dir_id = seafserv_threaded_rpc.get_dirid_by_path(current_commit.id,
                                                         parent_dir.encode('utf-8'))
    except SearpcError, e:
        return api_error(HTTP_520_OPERATION_FAILED,
                         "Failed to get dir id by path")
开发者ID:viktorlindgren,项目名称:seahub,代码行数:12,代码来源:views.py

示例12: check_has_subdir

    def check_has_subdir(repo):
        latest_commit = get_commits(repo.id, 0, 1)[0]
        if not latest_commit:
            return False
        if latest_commit.root_id == EMPTY_SHA1:
            return False

        dirs = seafserv_threaded_rpc.list_dir_by_path(latest_commit.id, '/')

        for dirent in dirs:
            if stat.S_ISDIR(dirent.props.mode):
                return True
        return False
开发者ID:bearstech,项目名称:seahub,代码行数:13,代码来源:__init__.py

示例13: get_repo_last_modify

def get_repo_last_modify(repo):
    """ Get last modification time for a repo.

    If head commit id of a repo is provided, we use that commit as last commit,
    otherwise falls back to getting last commit of a repo which is time
    consuming.
    """
    if repo.head_cmmt_id is not None:
        last_cmmt = seafserv_threaded_rpc.get_commit(repo.id, repo.version, repo.head_cmmt_id)
    else:
        logger.info('[repo %s] head_cmmt_id is missing.' % repo.id)
        last_cmmt = get_commits(repo.id, 0, 1)[0]
    return last_cmmt.ctime if last_cmmt else 0
开发者ID:jamjr,项目名称:seahub,代码行数:13,代码来源:__init__.py

示例14: get_repo_info

    def get_repo_info(request, repo_id):
        # check whether user can view repo
        repo = get_repo(repo_id)
        if not repo:
            return api_error(request, '404')

        if not can_access_repo(request, repo.id):
            return api_error(request, '403')

        # check whether use is repo owner
        if validate_owner(request, repo_id):
            owner = "self"
        else:
            owner = "share"

        try:
            repo.latest_modify = get_commits(repo.id, 0, 1)[0].ctime
        except:
            repo.latest_modify = None

        # query repo infomation
        repo.size = seafserv_threaded_rpc.server_repo_size(repo_id)
        current_commit = get_commits(repo_id, 0, 1)[0]
        repo_json = {
            "type":"repo",
            "id":repo.id,
            "owner":owner,
            "name":repo.name,
            "desc":repo.desc,
            "mtime":repo.lastest_modify,
            "size":repo.size,
            "encrypted":r.encrypted,
            "root":current_commit.root_id,
            "password_need":repo.password_need,
            }

        response = Response(200, repo_json)
        return self.render(response)
开发者ID:hilerchyn,项目名称:seahub,代码行数:38,代码来源:views.py

示例15: reloaddir_if_neccessary

def reloaddir_if_neccessary (request, repo_id, parent_dir):
    reloaddir = False
    s = request.GET.get('reloaddir', None)
    if s and s.lower() == 'true':
        reloaddir = True

    if not reloaddir:
        return HttpResponse(json.dumps('success'), status='200',
                            content_type=json_content_type)

    current_commit = get_commits(repo_id, 0, 1)[0]
    try:
        dir_id = seafserv_threaded_rpc.get_dirid_by_path(current_commit.id,
                                                         parent_dir.encode('utf-8'))
    except SearpcError, e:
        return api_error(request, "411", "SearpcError:" + e.msg)
开发者ID:hilerchyn,项目名称:seahub,代码行数:16,代码来源:views.py


注:本文中的seaserv.get_commits函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。