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