[yum-cvs] yum/yum config.py,1.43,1.44 repos.py,1.62,1.63
Seth Vidal
skvidal at login.linux.duke.edu
Thu Feb 17 07:16:48 UTC 2005
Update of /home/groups/yum/cvs/yum/yum
In directory login:/tmp/cvs-serv14156/yum
Modified Files:
config.py repos.py
Log Message:
allow undefining proxies in repo sections
use _none_ to disable proxy for a repo.
abstract out the repos classes from the config class
Index: config.py
===================================================================
RCS file: /home/groups/yum/cvs/yum/yum/config.py,v
retrieving revision 1.43
retrieving revision 1.44
diff -u -r1.43 -r1.44
--- config.py 11 Feb 2005 09:10:54 -0000 1.43
+++ config.py 17 Feb 2005 07:16:46 -0000 1.44
@@ -667,22 +667,66 @@
print line,
sys.exit(0)
- conf = yumconf(configfile = myfile)
+ conf = yumconf(configfile = myfile)
for option in conf.listConfigOptions():
print '%s = %s' % (option, conf.getConfigOption(option))
print '\n\n'
- repositories = conf.repos
- repolist = repositories.sort()
+
+ reposlist = []
+ # look through our repositories.
+ for section in conf.cfg.sections(): # loop through the list of sections
+ if section != 'main': # must be a repoid
+ try:
+ thisrepo = cfgParserRepo(section, conf, conf.cfg)
+ except (Errors.RepoError, Errors.ConfigError), e:
+ print >> sys.stderr, e
+ continue
+ else:
+ reposlist.append(thisrepo)
+
+ # reads through reposdir for *.repo
+ # does not read recursively
+ # read each of them in using confpp, then parse them same as any other repo
+ # section - as above.
+ reposdir = conf.reposdir
+ if os.path.exists(conf.installroot + '/' + reposdir):
+ reposdir = conf.installroot + '/' + reposdir
- for repo in repolist:
- print repo.dump()
-
+ reposglob = reposdir + '/*.repo'
+ if os.path.exists(reposdir) and os.path.isdir(reposdir):
+ repofn = glob.glob(reposglob)
+ repofn.sort()
+
+ for fn in repofn:
+ if not os.path.isfile(fn):
+ continue
+ try:
+ cfg, sections = parseDotRepo(fn)
+ except Errors.ConfigError, e:
+ print >> sys.stderr, e
+ continue
+
+ for section in sections:
+ try:
+ thisrepo = cfgParserRepo(section, conf, cfg)
+ except (Errors.RepoError, Errors.ConfigError), e:
+ print >> sys.stderr, e
+ continue
+ else:
+ reposlist.append(thisrepo)
+
+ # got our list of repo objects
+ reposlist.sort()
+ for thisrepo in reposlist:
+ try:
+ thisrepo.baseurlSetup()
+ except Errors.RepoError, e:
+ pass
+ print thisrepo.dump()
print ''
-
-
if __name__ == "__main__":
if len(sys.argv) < 2:
Index: repos.py
===================================================================
RCS file: /home/groups/yum/cvs/yum/yum/repos.py,v
retrieving revision 1.62
retrieving revision 1.63
diff -u -r1.62 -r1.63
--- repos.py 11 Feb 2005 09:10:54 -0000 1.62
+++ repos.py 17 Feb 2005 07:16:46 -0000 1.63
@@ -320,19 +320,20 @@
raise Errors.RepoError, 'Error opening file for checksum'
def dump(self):
- string = '[%s]\n' % self.id
- for attr in dir(self):
- if attr in ['name', 'bandwidth', 'enabled', 'enablegroups',
- 'gpgcheck', 'includepkgs', 'keepalive', 'proxy'
- 'proxy_password', 'proxy_username', 'excludes',
- 'retries', 'throttle', 'timeout']:
-
- string = string + '%s = %s\n' % (attr, getattr(self, attr))
- string = string + 'baseurl='
+ output = '[%s]\n' % self.id
+ vars = ['name', 'bandwidth', 'enabled', 'enablegroups',
+ 'gpgcheck', 'includepkgs', 'keepalive', 'proxy',
+ 'proxy_password', 'proxy_username', 'excludes',
+ 'retries', 'throttle', 'timeout', 'mirrorlistfn',
+ 'cachedir', 'gpgkey', 'pkgdir', 'hdrdir']
+ vars.sort()
+ for attr in vars:
+ output = output + '%s = %s\n' % (attr, getattr(self, attr))
+ output = output + 'baseurl ='
for url in self.urls:
- string = string + ' %s\n' % url
+ output = output + ' %s\n' % url
- return string
+ return output
def enable(self):
self.baseurlSetup()
@@ -367,7 +368,7 @@
return
self.proxy_dict = {} # zap it
- if self.proxy is not None:
+ if self.proxy is not None or self.proxy is not '_none_':
proxy_string = '%s' % self.proxy
if self.proxy_username is not None:
proxy_string = '%s@%s' % (self.proxy_username, self.proxy)
@@ -391,7 +392,7 @@
self.doProxyDict()
prxy = None
if self.proxy_dict:
- pryx = self.proxy_dict
+ prxy = self.proxy_dict
self.grabfunc = URLGrabber(keepalive=self.keepalive,
bandwidth=self.bandwidth,
@@ -478,7 +479,7 @@
self.doProxyDict()
prxy = None
if self.proxy_dict:
- pryx = self.proxy_dict
+ prxy = self.proxy_dict
if url is not None:
ug = URLGrabber(keepalive = self.keepalive,
More information about the Yum-cvs-commits
mailing list