我想用python从gitlab上拉取文件,但是一直报"Permission denied"?
我想用python从gitlab上拉取文件,
用的库是gittle,代码如下
#!/usr/bin/env python
# Author: Cosinex
# FileName: template.py
import os
import sys
# setup tools
os.system('sudo easy_install pip')
os.system('sudo pip install gittle')
# download files
from gittle import Gittle
from gittle import GittleAuth
repo_path = '/Cocoa Touch Class.xctemplate'
repo_url = 'url'
auth = GittleAuth(pkey = open('/users/cosinex/.ssh/id_rsa'))
repo = Gittle.clone(repo_url, repo_path , auth)
url我给屏蔽了,gitlab的project我设置的也是public,不知道为什么,一直报
Traceback (most recent call last):
File "template.py", line 19, in <module>
repo = Gittle.clone(repo_url, repo_path , auth)
File "/Library/Python/2.7/site-packages/gittle/gittle.py", line 430, in clone
mkdir_safe(local_path)
File "/Library/Python/2.7/site-packages/gittle/gittle.py", line 36, in mkdir_safe
os.makedirs(path)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/os.py", line 157, in makedirs
mkdir(name, mode)
OSError: [Errno 13] Permission denied: '/Cocoa Touch Class.xctemplate'
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
添加当前路径试试
repo_path = './Cocoa Touch Class.xctemplate'
这里的“Permission denied”报错是因为建立本地目录'/Cocoa Touch Class.xctemplate'无权限
'/Cocoa Touch Class.xctemplate' 是绝对路径,最前面的'/'代表系统根目录
你的用户应该是没有权限在系统根目录建立'Cocoa Touch Class.xctemplate'目录的
下面的repo_path变量换个有权限的目录就可以了,例如: