本文整理汇总了Python中seaserv.get_commits函数的典型用法代码示例。如果您正苦于以下问题:Python get_commits函数的具体用法?Python get_commits怎么用?Python get_commits使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_commits函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: get_wiki_dirent
def get_wiki_dirent(repo_id, page_name):
file_name = page_name + ".md"
repo = seaserv.get_repo(repo_id)
if not repo:
raise WikiDoesNotExist
cmmt = seaserv.get_commits(repo.id, 0, 1)[0]
if cmmt is None:
raise WikiPageMissing
dirs = list_dir_by_path(cmmt, "/")
if dirs:
for e in dirs:
if stat.S_ISDIR(e.mode):
continue # skip directories
if normalize_page_name(file_name) == normalize_page_name(e.obj_name):
return e
raise WikiPageMissing
开发者ID:sebheitzmann,项目名称:seahub,代码行数:16,代码来源:utils.py
示例17: get
def get(self, request, repo_id):
repo = get_repo(repo_id)
resp = check_repo_access_permission(request, repo)
if resp:
return resp
current_commit = get_commits(repo_id, 0, 1)[0]
path = request.GET.get('p', '/')
if path[-1] != '/':
path = path + '/'
dir_id = None
try:
dir_id = seafserv_threaded_rpc.get_dirid_by_path(current_commit.id,
path.encode('utf-8'))
except SearpcError, e:
return api_error(request, "411", "SearpcError:" + e.msg)
开发者ID:hilerchyn,项目名称:seahub,代码行数:17,代码来源:views.py
示例18: 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 Response('success')
current_commit = get_commits(repo_id, 0, 1)[0]
if not current_commit:
return api_error('422')
try:
dir_id = seafserv_threaded_rpc.get_dirid_by_path(current_commit.id,
parent_dir.encode('utf-8'))
except SearpcError, e:
return api_error("411", "SearpcError:" + e.msg)
开发者ID:strogo,项目名称:seahub,代码行数:18,代码来源:views.py
示例19: view_file_via_shared_dir
def view_file_via_shared_dir(request, token):
assert token is not None # Checked by URLconf
fileshare = FileShare.objects.get_valid_file_link_by_token(token)
if fileshare is None:
raise Http404
shared_by = fileshare.username
repo_id = fileshare.repo_id
repo = get_repo(repo_id)
if not repo:
raise Http404
path = request.GET.get('p', '').rstrip('/')
if not path:
raise Http404
if not path.startswith(fileshare.path): # Can not view upper dir of shared dir
raise Http404
zipped = gen_path_link(path, '')
obj_id = seafile_api.get_file_id_by_path(repo_id, path)
if not obj_id:
return render_error(request, _(u'File does not exist'))
file_size = seafile_api.get_file_size(repo.store_id, repo.version, obj_id)
filename = os.path.basename(path)
filetype, fileext = get_file_type_and_ext(filename)
access_token = seafserv_rpc.web_get_access_token(repo.id, obj_id,
'view', '')
raw_path = gen_file_get_url(access_token, filename)
inner_path = gen_inner_file_get_url(access_token, filename)
img_prev = None
img_next = None
# get file content
ret_dict = {'err': '', 'file_content': '', 'encoding': '', 'file_enc': '',
'file_encoding_list': [], 'html_exists': False,
'filetype': filetype}
exceeds_limit, err_msg = file_size_exceeds_preview_limit(file_size, filetype)
if exceeds_limit:
ret_dict['err'] = err_msg
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 == PDF:
handle_pdf(inner_path, obj_id, fileext, ret_dict)
elif filetype == IMAGE:
current_commit = get_commits(repo_id, 0, 1)[0]
parent_dir = os.path.dirname(path)
dirs = seafile_api.list_dir_by_commit_and_path(current_commit.repo_id,
current_commit.id, parent_dir)
if not dirs:
raise Http404
img_list = []
for dirent in dirs:
if not stat.S_ISDIR(dirent.props.mode):
fltype, flext = get_file_type_and_ext(dirent.obj_name)
if fltype == 'Image':
img_list.append(dirent.obj_name)
if len(img_list) > 1:
img_list.sort(lambda x, y : cmp(x.lower(), y.lower()))
cur_img_index = img_list.index(filename)
if cur_img_index != 0:
img_prev = posixpath.join(parent_dir, img_list[cur_img_index - 1])
if cur_img_index != len(img_list) - 1:
img_next = posixpath.join(parent_dir, img_list[cur_img_index + 1])
# send statistic messages
if ret_dict['filetype'] != 'Unknown':
try:
send_message('seahub.stats', 'file-view\t%s\t%s\t%s\t%s' % \
(repo.id, shared_by, obj_id, file_size))
except SearpcError, e:
logger.error('Error when sending file-view message: %s' % str(e))
开发者ID:bits4beats,项目名称:seahub,代码行数:83,代码来源:file.py
示例20: view_shared_dir
def view_shared_dir(request, token):
assert token is not None # Checked by URLconf
fileshare = FileShare.objects.get_valid_dir_link_by_token(token)
if fileshare is None:
raise Http404
if fileshare.is_encrypted():
if not check_share_link_access(request.user.username, token):
d = {'token': token, 'view_name': 'view_shared_dir', }
if request.method == 'POST':
post_values = request.POST.copy()
post_values['enc_password'] = fileshare.password
form = SharedLinkPasswordForm(post_values)
d['form'] = form
if form.is_valid():
# set cache for non-anonymous user
if request.user.is_authenticated():
set_share_link_access(request.user.username, token)
else:
return render_to_response('share_access_validation.html', d,
context_instance=RequestContext(request))
else:
return render_to_response('share_access_validation.html', d,
context_instance=RequestContext(request))
username = fileshare.username
repo_id = fileshare.repo_id
path = request.GET.get('p', '')
path = fileshare.path if not path else path
if path[-1] != '/': # Normalize dir path
path += '/'
if not path.startswith(fileshare.path):
path = fileshare.path # Can not view upper dir of shared dir
repo = get_repo(repo_id)
if not repo:
raise Http404
dir_name = os.path.basename(path[:-1])
current_commit = seaserv.get_commits(repo_id, 0, 1)[0]
file_list, dir_list = get_repo_dirents(request, repo, current_commit,
path)
zipped = gen_path_link(path, '')
if path == fileshare.path: # When user view the shared dir..
# increase shared link view_cnt,
fileshare = FileShare.objects.get(token=token)
fileshare.view_cnt = F('view_cnt') + 1
fileshare.save()
traffic_over_limit = user_traffic_over_limit(fileshare.username)
return render_to_response('view_shared_dir.html', {
'repo': repo,
'token': token,
'path': path,
'username': username,
'dir_name': dir_name,
'file_list': file_list,
'dir_list': dir_list,
'zipped': zipped,
'traffic_over_limit': traffic_over_limit,
}, context_instance=RequestContext(request))
开发者ID:thecosmicfrog,项目名称:seahub,代码行数:65,代码来源:repo.py
注:本文中的seaserv.get_commits函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论