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


Python seaserv.get_commit函数代码示例

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


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

示例1: FileUpdateEventHandler

def FileUpdateEventHandler(session, msg):
    elements = msg.body.split('\t')
    if len(elements) != 3:
        logging.warning("got bad message: %s", elements)
        return

    repo_id = elements[1]
    commit_id = elements[2]

    org_id = get_org_id_by_repo_id(repo_id)

    commit = get_commit(repo_id, 1, commit_id)
    if commit is None:
        commit = get_commit(repo_id, 0, commit_id)
        if commit is None:
            return

    time = datetime.datetime.utcfromtimestamp(msg.ctime)

    #KEEPER:
    #logging.info("FILE UPDATE EVENT: %s, start generate_certificate", commit.desc)
    generate_certificate_by_commit(commit) 

    save_file_update_event(session, time, commit.creator_name, org_id, \
                           repo_id, commit_id, commit.desc)
开发者ID:MPDL,项目名称:KEEPER,代码行数:25,代码来源:handlers.py

示例2: 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

示例3: get_commit_before_new_merge

def get_commit_before_new_merge(commit):
    """Traverse parents of ``commit``, and get a commit which is not a new merge.

    Pre-condition: ``commit`` must be a new merge and not conflict.

    Arguments:
    - `commit`:
    """
    assert new_merge_with_no_conflict(commit) is True

    while(new_merge_with_no_conflict(commit)):
        p1 = seaserv.get_commit(commit.repo_id, commit.version, commit.parent_id)
        p2 = seaserv.get_commit(commit.repo_id, commit.version, commit.second_parent_id)
        commit = p1 if p1.ctime > p2.ctime else p2

    assert new_merge_with_no_conflict(commit) is False

    return commit
开发者ID:cherish24,项目名称:seahub,代码行数:18,代码来源:__init__.py

示例4: test_repo

def test_repo(repo_id):
    repo = seafile_api.get_repo(repo_id)
    print vars(repo)
    current_commit = seaserv.get_commit(repo.id, repo.version, repo.head_cmmt_id)
    print vars(current_commit)
    path = '/'
    file_list, dir_list = get_repo_dirents(repo, current_commit, path)
    for f in file_list:
        print vars(f)
开发者ID:goaxe,项目名称:lab,代码行数:9,代码来源:server_info.py

示例5: 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.
    """
    last_cmmt = None
    if repo.head_cmmt_id is not None:
        last_cmmt = seaserv.get_commit(repo.id, repo.version, repo.head_cmmt_id)
    return last_cmmt.ctime if last_cmmt else 0
开发者ID:GregoireGalland,项目名称:seafdav,代码行数:11,代码来源:seafile_dav_provider.py

示例6: 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 = seaserv.get_commit(repo.id, repo.version, repo.head_cmmt_id)
    else:
        logger = logging.getLogger(__name__)
        logger.info('[repo %s] head_cmmt_id is missing.' % repo.id)
        last_cmmt = seafile_api.get_commit_list(repo.id, 0, 1)[0]
    return last_cmmt.ctime if last_cmmt else 0
开发者ID:cherish24,项目名称:seahub,代码行数:14,代码来源:__init__.py

示例7: to_dict

 def to_dict(self):
     repo = seafile_api.get_repo(self.repo_id)
     if not repo:
         return None
     commit = seaserv.get_commit(repo.id, repo.revision, self.revision_id)
     email = commit.creator_name
     return  {"tag":self.tag.name,
              "tag_creator": self.username,
              "revision": {
                  "repo_id": self.repo_id,
                  "commit_id": self.revision_id,
                  "email": email,
                  "name": email2nickname(email),
                  "contact_email": email2contact_email(email),
                  "time": timestamp_to_isoformat_timestr(commit.ctime),
                  "description": commit.desc,
                  "link": reverse("repo_history_view", args=[self.repo_id])+"?commit_id=%s"%self.revision_id
                  }}
开发者ID:haiwen,项目名称:seahub,代码行数:18,代码来源:models.py

示例8: _get_events_inner

    def _get_events_inner(ev_session, username, start, limit, org_id=None):
        '''Read events from seafevents database, and remove events that are
        no longer valid

        Return 'limit' events or less than 'limit' events if no more events remain
        '''
        valid_events = []
        next_start = start
        while True:
            if org_id > 0:
                events = seafevents.get_org_user_events(ev_session, org_id,
                                                        username, next_start,
                                                        limit)
            else:
                events = seafevents.get_user_events(ev_session, username,
                                                    next_start, limit)
            if not events:
                break

            for ev in events:
                if ev.etype == 'repo-update':
                    repo = seafile_api.get_repo(ev.repo_id)
                    if not repo:
                        # delete the update event for repo which has been deleted
                        seafevents.delete_event(ev_session, ev.uuid)
                        continue
                    if repo.encrypted:
                        repo.password_set = seafile_api.is_password_set(
                            repo.id, username)
                    ev.repo = repo
                    ev.commit = seaserv.get_commit(repo.id, repo.version, ev.commit_id)

                valid_events.append(ev)
                if len(valid_events) == limit:
                    break

            if len(valid_events) == limit:
                break
            next_start = next_start + len(valid_events)

        return valid_events
开发者ID:cherish24,项目名称:seahub,代码行数:41,代码来源:__init__.py

示例9: _decorated

    def _decorated(view, request, *args, **kwargs):
        if request.method in ["POST", "PUT"]:
            repo_id = request.data.get('repo_id', '')
            commit_id =request.data.get('commit_id', '')
            tag_names = request.data.get('tag_names', None)
        if not repo_id:
            error_msg = "Repo can not be empty"
            return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
        repo = seafile_api.get_repo(repo_id)
        if not repo:
            error_msg = "Library %s not found" % repo_id
            return api_error(status.HTTP_400_BAD_REQUEST, error_msg)

        if not commit_id:
            commit_id = repo.head_cmmt_id
        commit = seaserv.get_commit(repo.id, repo.version, commit_id)
        if not commit:
            error_msg = "Commit %s not found" % commit_id
            return api_error(status.HTTP_400_BAD_REQUEST, error_msg)

        if tag_names is None:
            error_msg = "Tag can not be empty"
            return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
        names = []
        if not tag_names.strip():
            if request.method == "POST":
                error_msg = "Tag can not be empty"
                return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
        else:
            names = [name.strip() for name in tag_names.split(',')]
            for name in names:
                if not check_tagname(name):
                    error_msg = _("Tag can only contain letters, numbers, dot, hyphen or underscore.")
                    return api_error(status.HTTP_400_BAD_REQUEST, error_msg)

        if check_folder_permission(request, repo_id, '/') != 'rw':
            error_msg = 'Permission denied.'
            return api_error(status.HTTP_403_FORBIDDEN, error_msg)

        return func(view, request, repo_id, commit_id, names, *args, **kwargs)
开发者ID:haiwen,项目名称:seahub,代码行数:40,代码来源:revision_tag.py

示例10: get_commit

def get_commit(commit_id):
    return seaserv.get_commit(commit_id)
开发者ID:vIiRuS,项目名称:seahub,代码行数:2,代码来源:repo.py

示例11: view_history_file_common

def view_history_file_common(request, repo_id, ret_dict):
    username = request.user.username
    # check arguments
    repo = get_repo(repo_id)
    if not repo:
        raise Http404

    path = request.GET.get('p', '/')
    
    commit_id = request.GET.get('commit_id', '')
    if not commit_id:
        raise Http404

    obj_id = request.GET.get('obj_id', '')
    if not obj_id:
        raise Http404
    
    # construct some varibles
    u_filename = os.path.basename(path)
    current_commit = get_commit(commit_id)
    if not current_commit:
        raise Http404

    # Check whether user has permission to view file and get file raw path,
    # render error page if permission is deny.
    raw_path, user_perm = get_file_view_path_and_perm(request, repo_id,
                                                      obj_id, u_filename)
    request.user_perm = user_perm

    # get file type and extension
    filetype, fileext = get_file_type_and_ext(u_filename)

    if user_perm:
        # Check file size
        fsize = get_file_size(obj_id)
        if fsize > FILE_PREVIEW_MAX_SIZE:
            err = _(u'File size surpasses %s, can not be opened online.') % \
                filesizeformat(FILE_PREVIEW_MAX_SIZE)
            ret_dict['err'] = err

        elif filetype in (DOCUMENT, PDF) and HAS_OFFICE_CONVERTER and fsize > OFFICE_PREVIEW_MAX_SIZE:
            err = _(u'File size surpasses %s, can not be opened online.') % \
                filesizeformat(OFFICE_PREVIEW_MAX_SIZE)
            ret_dict['err'] = err
        else:
            """Choose different approach when dealing with different type of file."""
            if is_textual_file(file_type=filetype):
                handle_textual_file(request, filetype, raw_path, ret_dict)
            elif filetype == DOCUMENT:
                handle_document(raw_path, obj_id, fileext, ret_dict)
            elif filetype == PDF:
                handle_pdf(raw_path, obj_id, fileext, ret_dict)
            else:
                pass
    # populate return value dict
    ret_dict['repo'] = repo
    ret_dict['obj_id'] = obj_id
    ret_dict['file_name'] = u_filename
    ret_dict['path'] = path
    ret_dict['current_commit'] = current_commit
    ret_dict['fileext'] = fileext
    ret_dict['raw_path'] = raw_path
    if not ret_dict.has_key('filetype'):    
        ret_dict['filetype'] = filetype 
    ret_dict['use_pdfjs'] = USE_PDFJS

    if not repo.encrypted:
        ret_dict['search_repo_id'] = repo.id
开发者ID:viktorlindgren,项目名称:seahub,代码行数:68,代码来源:file.py

示例12: get_catalog

def get_catalog():

    catalog = []

    repos_all = seafile_api.get_repo_list(0, MAX_INT)
    #repos_all = [seafile_api.get_repo('a6d4ae75-b063-40bf-a3d9-dde74623bb2c')]

    for repo in repos_all:

        try:
            proj = {}
            proj["id"] = repo.id
            proj["name"] = repo.name
            email = get_repo_owner(repo.id)
            proj["owner"] = email
            user_name = get_user_name(email)
            if user_name != email:
                proj["owner_name"] = user_name 
            proj["in_progress"] = True

            commits = get_commits(repo.id, 0, 1)
            commit = get_commit(repo.id, repo.version, commits[0].id)
            dir = fs_mgr.load_seafdir(repo.id, repo.version, commit.root_id)
            file = dir.lookup(ARCHIVE_METADATA_TARGET)
            if file:
                md = parse_markdown(file.get_content())
                if md:
                    # Author
                    a = md.get("Author")
                    if a:
                        a_list = strip_uni(a.strip()).split('\n')
                        authors = []
                        for _ in a_list:
                            author = {}
                            aa = _.split(';')
                            author['name'] = aa[0]
                            if len(aa) > 1 and aa[1].strip():
                                author['affs'] = [x.strip() for x in aa[1].split('|')]
                                author['affs'] = [x for x in author['affs'] if x ]
                            authors.append(author)
                        if a:
                            proj["authors"] = authors

                    # Description
                    d = strip_uni(md.get("Description"))
                    if d:
                        proj["description"] = d

                    # Comments
                    c = strip_uni(md.get("Comments"))
                    if c:
                        proj["comments"] = c

                    #Title
                    t = strip_uni(md.get("Title"))
                    if t:
                        proj["title"] = t
                        del proj["in_progress"]
                    
                    proj["is_certified"] = is_certified_by_repo_id(repo.id)
            else:
                if DEBUG:
                    print "No %s for repo %s found" % (ARCHIVE_METADATA_TARGET, repo.name)
            catalog.append(proj)    

        except Exception as err:
            msg = "repo_name: %s, id: %s, err: %s" % ( repo.name, repo.id, str(err) ) 
            logging.error (msg)
            if DEBUG:
                print msg

    return catalog
开发者ID:MPDL,项目名称:KEEPER,代码行数:72,代码来源:catalog_manager.py

示例13: view_history_file_common

def view_history_file_common(request, repo_id, ret_dict):
    username = request.user.username
    # check arguments
    repo = get_repo(repo_id)
    if not repo:
        raise Http404

    path = request.GET.get("p", "/")

    commit_id = request.GET.get("commit_id", "")
    if not commit_id:
        raise Http404

    obj_id = request.GET.get("obj_id", "")
    if not obj_id:
        raise Http404

    # construct some varibles
    u_filename = os.path.basename(path)
    filename_utf8 = urllib2.quote(u_filename.encode("utf-8"))
    current_commit = get_commit(commit_id)
    if not current_commit:
        raise Http404

    # Check whether user has permission to view file and get file raw path,
    # render error page if permission is deny.
    raw_path, user_perm = get_file_view_path_and_perm(request, repo_id, obj_id, u_filename)
    request.user_perm = user_perm

    # get file type and extension
    filetype, fileext = get_file_type_and_ext(u_filename)

    if user_perm:
        # Check file size
        fsize = get_file_size(obj_id)
        if fsize > FILE_PREVIEW_MAX_SIZE:
            from django.template.defaultfilters import filesizeformat

            err = _(u"File size surpasses %s, can not be opened online.") % filesizeformat(FILE_PREVIEW_MAX_SIZE)
            ret_dict["err"] = err
        else:
            """Choose different approach when dealing with different type of file."""
            if is_textual_file(file_type=filetype):
                handle_textual_file(request, filetype, raw_path, ret_dict)
            elif filetype == DOCUMENT:
                handle_document(raw_path, obj_id, fileext, ret_dict)
            elif filetype == PDF:
                handle_pdf(raw_path, obj_id, fileext, ret_dict)
            else:
                pass
    # populate return value dict
    ret_dict["repo"] = repo
    ret_dict["obj_id"] = obj_id
    ret_dict["file_name"] = u_filename
    ret_dict["path"] = path
    ret_dict["current_commit"] = current_commit
    ret_dict["fileext"] = fileext
    ret_dict["raw_path"] = raw_path
    if not ret_dict.has_key("filetype"):
        ret_dict["filetype"] = filetype
    ret_dict["DOCUMENT_CONVERTOR_ROOT"] = DOCUMENT_CONVERTOR_ROOT
    ret_dict["use_pdfjs"] = USE_PDFJS
开发者ID:sonicby,项目名称:seahub,代码行数:62,代码来源:file.py

示例14: view_history_file_common

def view_history_file_common(request, repo_id, ret_dict):
    # check arguments
    repo = get_repo(repo_id)
    if not repo:
        raise Http404

    path = request.GET.get("p", "/")

    commit_id = request.GET.get("commit_id", "")
    if not commit_id:
        raise Http404

    obj_id = request.GET.get("obj_id", "")
    if not obj_id:
        raise Http404

    # construct some varibles
    u_filename = os.path.basename(path)
    current_commit = get_commit(repo.id, repo.version, commit_id)
    if not current_commit:
        raise Http404

    # Check whether user has permission to view file and get file raw path,
    # render error page if permission  deny.
    raw_path, inner_path, user_perm = get_file_view_path_and_perm(request, repo_id, obj_id, path)
    request.user_perm = user_perm

    # get file type and extension
    filetype, fileext = get_file_type_and_ext(u_filename)

    if user_perm:
        # Check file size
        fsize = get_file_size(repo.store_id, repo.version, obj_id)
        if fsize > FILE_PREVIEW_MAX_SIZE:
            err = _(u"File size surpasses %s, can not be opened online.") % filesizeformat(FILE_PREVIEW_MAX_SIZE)
            ret_dict["err"] = err

        elif filetype in (DOCUMENT, PDF) and HAS_OFFICE_CONVERTER and fsize > OFFICE_PREVIEW_MAX_SIZE:
            err = _(u"File size surpasses %s, can not be opened online.") % filesizeformat(OFFICE_PREVIEW_MAX_SIZE)
            ret_dict["err"] = err
        else:
            """Choose different approach when dealing with different type of file."""
            if is_textual_file(file_type=filetype):
                handle_textual_file(request, filetype, inner_path, ret_dict)
            elif filetype == DOCUMENT:
                handle_document(inner_path, obj_id, fileext, ret_dict)
            elif filetype == SPREADSHEET:
                handle_spreadsheet(inner_path, obj_id, fileext, ret_dict)
            elif filetype == OPENDOCUMENT:
                if fsize == 0:
                    ret_dict["err"] = _(u"Invalid file format.")
            elif filetype == PDF:
                handle_pdf(inner_path, obj_id, fileext, ret_dict)
            else:
                pass
    # populate return value dict
    ret_dict["repo"] = repo
    ret_dict["obj_id"] = obj_id
    ret_dict["file_name"] = u_filename
    ret_dict["path"] = path
    ret_dict["current_commit"] = current_commit
    ret_dict["fileext"] = fileext
    ret_dict["raw_path"] = raw_path
    if not ret_dict.has_key("filetype"):
        ret_dict["filetype"] = filetype
    ret_dict["use_pdfjs"] = USE_PDFJS
开发者ID:vikingliu,项目名称:seahub,代码行数:66,代码来源:file.py


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