fix: make username/password work for all remote files...

This commit is contained in:
Barış Metin
2006-06-27 08:13:43 +00:00
parent c9213c81c2
commit 318e2143ea
4 changed files with 19 additions and 20 deletions
+2
View File
@@ -377,10 +377,12 @@ def update_repo(repo, force=False):
index.read_uri_of_repo(repouri, repo, force = force) index.read_uri_of_repo(repouri, repo, force = force)
else: else:
return return
try: try:
index.check_signature(repouri, repo) index.check_signature(repouri, repo)
except pisi.file.NoSignatureFound, e: except pisi.file.NoSignatureFound, e:
ctx.ui.warning(e) ctx.ui.warning(e)
ctx.txn_proc(lambda txn : index.update_db(repo, txn=txn)) ctx.txn_proc(lambda txn : index.update_db(repo, txn=txn))
ctx.ui.info(_('* Package database updated.')) ctx.ui.info(_('* Package database updated.'))
else: else:
+9 -15
View File
@@ -96,7 +96,7 @@ class Builder:
#FIXME: this class and every other class must use URLs as paths! #FIXME: this class and every other class must use URLs as paths!
@staticmethod @staticmethod
def from_name(name, authinfo = None): def from_name(name):
# download package and return an installer object # download package and return an installer object
# find package in repository # find package in repository
sf, reponame = ctx.sourcedb.get_spec_repo(name) sf, reponame = ctx.sourcedb.get_spec_repo(name)
@@ -114,19 +114,15 @@ class Builder:
ctx.ui.debug(_("Source URI: %s") % src_path) ctx.ui.debug(_("Source URI: %s") % src_path)
return Builder(src_path, authinfo) return Builder(src_path)
else: else:
raise Error(_("Source %s not found in any active repository.") % name) raise Error(_("Source %s not found in any active repository.") % name)
def __init__(self, specuri, authinfo = None): def __init__(self, specuri):
# process args # process args
if not isinstance(specuri, URI): if not isinstance(specuri, URI):
specuri = URI(specuri) specuri = URI(specuri)
if authinfo:
specuri.set_auth_info(authinfo)
self.authinfo = authinfo
# read spec file, we'll need it :) # read spec file, we'll need it :)
self.set_spec_file(specuri) self.set_spec_file(specuri)
@@ -285,8 +281,6 @@ class Builder:
def download(self, uri, transferdir): def download(self, uri, transferdir):
# fix auth info and download # fix auth info and download
uri = File.make_uri(uri) uri = File.make_uri(uri)
if self.authinfo:
uri.set_auth_info(self.authinfo)
File.download(uri, transferdir) File.download(uri, transferdir)
def fetch_component(self): def fetch_component(self):
@@ -863,11 +857,11 @@ class Builder:
# build functions... # build functions...
def build(pspec, authinfo=None): def build(pspec):
if pspec.endswith('.xml'): if pspec.endswith('.xml'):
pb = Builder(pspec, authinfo) pb = Builder(pspec)
else: else:
pb = Builder.from_name(pspec, authinfo) pb = Builder.from_name(pspec)
return pb.build() return pb.build()
order = {"none": 0, order = {"none": 0,
@@ -907,11 +901,11 @@ def __buildState_buildpackages(pb, last):
__buildState_installaction(pb, last) __buildState_installaction(pb, last)
pb.build_packages() pb.build_packages()
def build_until(pspec, state, authinfo=None): def build_until(pspec, state):
if pspec.endswith('.xml'): if pspec.endswith('.xml'):
pb = Builder(pspec, authinfo) pb = Builder(pspec)
else: else:
pb = Builder.from_name(pspec, authinfo) pb = Builder.from_name(pspec)
pb.compile_action_script() pb.compile_action_script()
+5 -5
View File
@@ -130,15 +130,15 @@ class Command(object):
# someauthconfig.password) # someauthconfig.password)
# return # return
if username and password: if username and password:
self.authInfo = (username, password) self.options.authinfo = (username, password)
return return
if username and self.options.getpass: if username and self.options.getpass:
from getpass import getpass from getpass import getpass
password = getpass(_("Password: ")) password = getpass(_("Password: "))
self.authInfo = (username, password) self.options.authinfo = (username, password)
else: else:
self.authInfo = None self.options.authinfo = None
def init(self, database = True, write = True): def init(self, database = True, write = True):
"""initialize PiSi components""" """initialize PiSi components"""
@@ -424,9 +424,9 @@ unpack, setup, build, install, package.
for x in self.args: for x in self.args:
if ctx.get_option('until'): if ctx.get_option('until'):
pisi.api.build_until(x, ctx.get_option('until'), self.authInfo) pisi.api.build_until(x, ctx.get_option('until'))
else: else:
pisi.api.build(x, self.authInfo) pisi.api.build(x)
self.finalize() self.finalize()
+3
View File
@@ -63,6 +63,9 @@ class Fetcher:
if not isinstance(url, URI): if not isinstance(url, URI):
url = URI(url) url = URI(url)
if ctx.config.options.authinfo:
url.set_auth_info(ctx.config.options.authinfo)
self.resume = resume self.resume = resume
self.scheme = url.scheme() self.scheme = url.scheme()
self.url = url self.url = url