[yum-git] 3 commits - plugins/fastestmirror
James Antill
james at linux.duke.edu
Wed Jul 2 12:57:03 UTC 2008
plugins/fastestmirror/fastestmirror.py | 24 ++++++++++++++++++++++--
1 file changed, 22 insertions(+), 2 deletions(-)
New commits:
commit 8da358badb352e4addde1d91aa98d335d0dac02d
Author: James Antill <james at and.org>
Date: Tue Jul 1 13:03:51 2008 -0400
Don't skip just because the file doesn't exist, stupid os.access()
diff --git a/plugins/fastestmirror/fastestmirror.py b/plugins/fastestmirror/fastestmirror.py
index f21e4bd..13a35d2 100644
--- a/plugins/fastestmirror/fastestmirror.py
+++ b/plugins/fastestmirror/fastestmirror.py
@@ -110,6 +110,16 @@ def clean_hook(conduit):
# Get the hostname from a url, stripping away any usernames/passwords
host = lambda mirror: mirror.split('/')[2].split('@')[-1]
+def _can_write_results(fname):
+ if not os.path.exists(fname):
+ try:
+ hostfile = file(hostfilepath, 'w')
+ return True
+ except:
+ return False
+
+ return os.access(fname, os.W_OK)
+
def postreposetup_hook(conduit):
"""
This function is called after Yum has initiliazed all the repository information.
@@ -132,7 +142,7 @@ def postreposetup_hook(conduit):
global loadcache, exclude
opts, commands = conduit.getCmdLine()
- if conduit._base.conf.cache or not os.access(hostfilepath, os.W_OK):
+ if conduit._base.conf.cache or not _can_write_results(hostfilepath):
return
if loadcache:
commit ae315112172fd1429945bcc630f3e7871fff25f0
Author: James Antill <james at and.org>
Date: Tue Jul 1 13:00:10 2008 -0400
Do as much parallelism as possible on testing URLs
diff --git a/plugins/fastestmirror/fastestmirror.py b/plugins/fastestmirror/fastestmirror.py
index a0e512c..f21e4bd 100644
--- a/plugins/fastestmirror/fastestmirror.py
+++ b/plugins/fastestmirror/fastestmirror.py
@@ -142,6 +142,17 @@ def postreposetup_hook(conduit):
conduit.info(2, "Determining fastest mirrors")
repomirrors = {}
repos = conduit.getRepos()
+
+ # First do all of the URLs as one big list, this way we get as much
+ # parallelism as possible (if we need to do the network tests).
+ all_urls = []
+ for repo in repos.listEnabled():
+ if len(repo.urls) == 1:
+ continue
+ all_urls.extend(repo.urls)
+ all_urls = FastestMirror(all_urls).get_mirrorlist()
+
+ # This should now just be looking up the cached times.
for repo in repos.listEnabled():
if len(repo.urls) == 1:
continue
commit bb371d10abcb3e2acf915990601b5f435a5dd535
Author: James Antill <james at and.org>
Date: Tue Jul 1 12:38:23 2008 -0400
Use _base.conf.cache not the option, works in yumm/yumex/pirut
diff --git a/plugins/fastestmirror/fastestmirror.py b/plugins/fastestmirror/fastestmirror.py
index 9e4786c..a0e512c 100644
--- a/plugins/fastestmirror/fastestmirror.py
+++ b/plugins/fastestmirror/fastestmirror.py
@@ -132,8 +132,7 @@ def postreposetup_hook(conduit):
global loadcache, exclude
opts, commands = conduit.getCmdLine()
- if ((hasattr(opts, 'cacheonly') and opts.cacheonly) or
- not os.access(hostfilepath, os.W_OK)):
+ if conduit._base.conf.cache or not os.access(hostfilepath, os.W_OK):
return
if loadcache:
More information about the Yum-cvs-commits
mailing list