Hi,
I'm new here btw .. I just started learning python and OOP, hope y'all
will guide me through
This plugin add a retry download functionality to yum when download
errors happen. Those that got a fast and stable internet seldom get
download timeout/checksum/no more mirrors error, but theres a lot of
ppl in 3rd world n developing countries have slow/unstable internet
and timeouts sometimes occurs too frequently. I wrote this plugin is
written to make yum retry downloading for a few more times before die.
If this plugin is a duplicate, pls tell me .. coz i couldn't find any
similar plugins
i've attached the plugin with this email
--
-----------------------------------------------
regards
Hikaru
-----------------------------------------------
Mohd Izhar Firdaus Bin Ismail
Amano Hikaru
天野晃 「あまの ひかる」
Universiti Teknologi PETRONAS
ICT 2nd Year 1st Semester
[EMAIL PROTECTED]
-----------------------------------------------
[EMAIL PROTECTED]
GPG: http://www.rootshell.be/~kagesens/public-key.asc
Blog: http://kagesenshi.blogspot.com
-----------------------------------------------
#!/usr/bin/python
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Library General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
# by Mohd Izhar Firdaus Ismail
from yum.plugins import PluginYumExit, TYPE_CORE
import os
import os.path
import yum.Errors
requires_api_version = '2.3'
plugin_type = (TYPE_CORE)
class KeepRetry(yum.YumBase):
def downloadPkgs(self, pkglist, callback=None):
# This method is simplified and
# modified from yum.YumBase.downloadPkgs
errors = {}
def adderror(po, msg):
errors.setdefault(po, []).append(msg)
remote_pkgs = []
for po in pkglist:
remote_pkgs.append(po)
i = 0
for po in remote_pkgs:
i += 1
dirstat = os.statvfs(po.repo.pkgdir)
try:
text = '(%s/%s): %s' % (i, len(remote_pkgs),
os.path.basename(po.localPkg()))
mylocal = po.repo.getPackage(po,
text=text,
)
except yum.Errors.RepoError, e:
adderror(po, str(e))
else:
po.localpath = mylocal
if errors.has_key(po):
del errors[po]
if (not po.verifyLocalPkg()):
print "package does not match checksum"
os.unlink(po.localPkg())
adderror(po,"Checksum does not match")
return errors
def config_hook(conduit):
parser = conduit.getOptParser()
parser.add_option('', '--keep-retry', dest='retries', action='store', default="0", help="Retry on \"No More Mirrors\" error.")
def postdownload_hook(conduit):
problems = conduit.getErrors()
# only run if have error
if (problems):
rd = KeepRetry()
opts, commands = conduit.getCmdLine()
try:
retrycount = int(opts.retries)
except:
print "Error in --keep-retry value. Skipping retry"
retrycount = 0
while (problems and retrycount > 0):
redownloads = []
print ""
print "============================================"
print "Retrying for these packages"
for po, err_msg in problems.iteritems():
print po
redownloads.append(po)
print 'Retries left : %s ' % (retrycount - 1)
print ""
problems = rd.downloadPkgs(redownloads)
retrycount -= 1
if (problems):
print ""
print ""
print "Failure : Remaining errors"
for po, err_msg in problems.iteritems():
for msg in err_msg:
print " " + str(msg)
print ""
raise PluginYumExit()
else:
# I have no idea on how to do this automatically
# so, juz let the user do it
print ""
print ""
print "All packages successfully downloaded"
print "please re-run yum to install the downloaded packages"
print ""
raise PluginYumExit()
_______________________________________________
Yum-devel mailing list
[email protected]
https://lists.dulug.duke.edu/mailman/listinfo/yum-devel