在口译员中,urllib.request.urlretrieve'工作得很好:
Python 3.4.3+ (default, Oct 14 2015, 16:03:50)
[GCC 5.2.1 20151010] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import urllib.request
>>>urllib.request.urlretrieve('https://download.owncloud.org/download/repositories/stable/Ubuntu_15.10/Release.key', 'Release.key')
('Release.key', <http.client.HTTPMessage object at 0x7fa008f76518>)
在此功能中不起作用:
def owncloudI():
print(ok('Installing OwnCloud...\n'))
urllib.request.urlretrieve('https://download.owncloud.org/download/repositories/stable/Ubuntu_15.10/Release.key', 'Release.key') #<---- stuck here
call(['apt-key', 'add', 'Release.key'])
rep = open('/etc/apt/sources.list.d/owncloud.list', 'a')
print('deb http://download.owncloud.org/download/repositories/stable/Ubuntu_15.10/', file=rep)
rep.close()
call(['apt-get', 'update'])
call(['apt-get', 'install', 'owncloud'])
使用sudo启动代码并在/ tmp cat中执行,因此我认为权限都可以。也许有人解决了类似的问题。
答案 0 :(得分:0)
用
修复此问题with urllib.request.urlopen('https://download.owncloud.org/download/repositories/stable/Ubuntu_15.10/Release.key') as response, open('resp.key', 'wb') as out_file:
data = response.read()
out_file.write(data)