mirror of
https://github.com/openSUSE/osc.git
synced 2024-12-27 02:16:12 +01:00
- yet another fix for #477690: build: use a cookie when fetching the binaries
This commit is contained in:
parent
7bd970716c
commit
9935faf3ba
@ -21,7 +21,7 @@ try:
|
||||
except ImportError:
|
||||
import cElementTree as ET
|
||||
|
||||
from conf import config
|
||||
from conf import config, cookiejar
|
||||
|
||||
change_personality = {
|
||||
'i686': 'linux32',
|
||||
@ -390,7 +390,8 @@ def main(opts, argv):
|
||||
fetcher = Fetcher(cachedir = config['packagecachedir'],
|
||||
urllist = urllist,
|
||||
api_host_options = config['api_host_options'],
|
||||
http_debug = config['http_debug'])
|
||||
http_debug = config['http_debug'],
|
||||
cookiejar=cookiejar)
|
||||
|
||||
# now update the package cache
|
||||
fetcher.run(bi)
|
||||
|
@ -1477,7 +1477,8 @@ def http_request(method, url, headers={}, data=None, file=None):
|
||||
try:
|
||||
fd = urllib2.urlopen(req, data=data)
|
||||
finally:
|
||||
conf.cookiejar.save(ignore_discard=True)
|
||||
if hasattr(conf.cookiejar, 'save'):
|
||||
conf.cookiejar.save(ignore_discard=True)
|
||||
|
||||
if filefd: filefd.close()
|
||||
|
||||
|
@ -23,7 +23,7 @@ def join_url(self, base_url, rel_url):
|
||||
|
||||
|
||||
class Fetcher:
|
||||
def __init__(self, cachedir = '/tmp', api_host_options = {}, urllist = [], http_debug = False):
|
||||
def __init__(self, cachedir = '/tmp', api_host_options = {}, urllist = [], http_debug = False, cookiejar = None):
|
||||
|
||||
__version__ = '0.1'
|
||||
__user_agent__ = 'osbuild/%s' % __version__
|
||||
@ -42,10 +42,12 @@ class Fetcher:
|
||||
passmgr = urllib2.HTTPPasswordMgrWithDefaultRealm()
|
||||
for host in api_host_options.keys():
|
||||
passmgr.add_password(None, host, api_host_options[host]['user'], api_host_options[host]['pass'])
|
||||
authhandler = urllib2.HTTPBasicAuthHandler(passmgr)
|
||||
openers = (urllib2.HTTPBasicAuthHandler(passmgr), )
|
||||
if cookiejar:
|
||||
openers += (urllib2.HTTPCookieProcessor(cookiejar), )
|
||||
self.gr = URLGrabber(user_agent=__user_agent__,
|
||||
keepalive=1,
|
||||
opener = urllib2.build_opener(authhandler),
|
||||
opener = urllib2.build_opener(*openers),
|
||||
progress_obj=self.progress_obj,
|
||||
failure_callback=(self.failureReport,(),{}),
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user