我想用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'
添加当前路径试试
repo_path = './Cocoa Touch Class.xctemplate'