[yum-commits] 7 commits - reposync.py repotrack.py yum-utils.spec
Tim Lauridsen
timlau at osuosl.org
Thu Mar 27 12:32:59 UTC 2014
reposync.py | 116 +++++++++++++++++++++++++--------------------------------
repotrack.py | 12 -----
yum-utils.spec | 2
3 files changed, 54 insertions(+), 76 deletions(-)
New commits:
commit f2f96900562f85d52ba61d25ef2978cea41bf45a
Author: Miroslav Suchý <msuchy at redhat.com>
Date: Wed Mar 26 13:57:29 2014 +0100
get rid of python 2.4 compat
python 2.4 is used in el5 and new yum-utils are build only for el6+, where is newer python
diff --git a/reposync.py b/reposync.py
index 225423b..6500db6 100755
--- a/reposync.py
+++ b/reposync.py
@@ -50,16 +50,6 @@ import logging
from urlgrabber.progress import TextMeter, TextMultiFileMeter
import urlgrabber
-# for yum 2.4.X compat
-def sortPkgObj(pkg1, pkg2):
- """sorts a list of yum package objects by name"""
- if pkg1.name > pkg2.name:
- return 1
- elif pkg1.name == pkg2.name:
- return 0
- else:
- return -1
-
class RepoSync(yum.YumBase):
def __init__(self, opts):
yum.YumBase.__init__(self)
@@ -289,7 +279,7 @@ def main():
if hasattr(urlgrabber.progress, 'text_meter_total_size'):
urlgrabber.progress.text_meter_total_size(remote_size)
- download_list.sort(sortPkgObj)
+ download_list.sort(key=lambda pkg: pkg.name)
if opts.urls:
for pkg in download_list:
print urljoin(pkg.repo.urls[0], pkg.relativepath)
diff --git a/repotrack.py b/repotrack.py
index 6c6a18c..8dd8b9c 100755
--- a/repotrack.py
+++ b/repotrack.py
@@ -38,16 +38,6 @@ from yum.constants import *
from yum.packages import parsePackages
from yum.packageSack import ListPackageSack
-# for yum 2.4.X compat
-def sortPkgObj(pkg1 ,pkg2):
- """sorts a list of yum package objects by name"""
- if pkg1.name > pkg2.name:
- return 1
- elif pkg1.name == pkg2.name:
- return 0
- else:
- return -1
-
class RepoTrack(yum.YumBase):
def __init__(self, opts):
yum.YumBase.__init__(self)
@@ -224,7 +214,7 @@ def main():
this_sack.addList(download_list)
download_list = this_sack.returnNewestByNameArch()
- download_list.sort(sortPkgObj)
+ download_list.sort(key=lambda pkg: pkg.name)
for pkg in download_list:
repo = my.repos.getRepo(pkg.repoid)
remote = pkg.returnSimple('relativepath')
diff --git a/yum-utils.spec b/yum-utils.spec
index de6fbfd..dd206b3 100644
--- a/yum-utils.spec
+++ b/yum-utils.spec
@@ -20,7 +20,7 @@ BuildArch: noarch
# For new findRepos() API.
Requires: yum >= 3.4.3-96
Requires: python-kitchen
-BuildRequires: python-devel >= 2.4
+BuildRequires: python-devel
BuildRequires: gettext
BuildRequires: intltool
Provides: yum-utils-translations = %{version}-%{release}
commit b4fc450d0d0133fbe262d50a325b5ea830ce6fe4
Author: Miroslav Suchý <msuchy at redhat.com>
Date: Wed Mar 26 13:36:20 2014 +0100
add i18n to reposync
diff --git a/reposync.py b/reposync.py
index a675542..225423b 100755
--- a/reposync.py
+++ b/reposync.py
@@ -40,6 +40,8 @@ import stat
from optparse import OptionParser
from urlparse import urljoin
+from yumutils.i18n import _
+
import yum
import yum.Errors
from yum.packageSack import ListPackageSack
@@ -83,47 +85,47 @@ def localpkgs(directory):
return cache
def parseArgs():
- usage = """
+ usage = _("""
Reposync is used to synchronize a remote yum repository to a local
directory using yum to retrieve the packages.
%s [options]
- """ % sys.argv[0]
+ """) % sys.argv[0]
parser = OptionParser(usage=usage)
parser.add_option("-c", "--config", default='/etc/yum.conf',
- help='config file to use (defaults to /etc/yum.conf)')
+ help=_('config file to use (defaults to /etc/yum.conf)'))
parser.add_option("-a", "--arch", default=None,
- help='act as if running the specified arch (default: current arch, note: does not override $releasever. x86_64 is a superset for i*86.)')
+ help=_('act as if running the specified arch (default: current arch, note: does not override $releasever. x86_64 is a superset for i*86.)'))
parser.add_option("--source", default=False, dest="source", action="store_true",
- help='operate on source packages')
+ help=_('operate on source packages'))
parser.add_option("-r", "--repoid", default=[], action='append',
- help="specify repo ids to query, can be specified multiple times (default is all enabled)")
+ help=_("specify repo ids to query, can be specified multiple times (default is all enabled)"))
parser.add_option("-e", "--cachedir",
- help="directory in which to store metadata")
+ help=_("directory in which to store metadata"))
parser.add_option("-t", "--tempcache", default=False, action="store_true",
- help="Use a temp dir for storing/accessing yum-cache")
+ help=_("Use a temp dir for storing/accessing yum-cache"))
parser.add_option("-d", "--delete", default=False, action="store_true",
- help="delete local packages no longer present in repository")
+ help=_("delete local packages no longer present in repository"))
parser.add_option("-p", "--download_path", dest='destdir',
- default=os.getcwd(), help="Path to download packages to: defaults to current dir")
+ default=os.getcwd(), help=_("Path to download packages to: defaults to current dir"))
parser.add_option("--norepopath", dest='norepopath', default=False, action="store_true",
- help="Don't add the reponame to the download path. Can only be used when syncing a single repository (default is to add the reponame)")
+ help=_("Don't add the reponame to the download path. Can only be used when syncing a single repository (default is to add the reponame)"))
parser.add_option("-g", "--gpgcheck", default=False, action="store_true",
- help="Remove packages that fail GPG signature checking after downloading")
+ help=_("Remove packages that fail GPG signature checking after downloading"))
parser.add_option("-u", "--urls", default=False, action="store_true",
- help="Just list urls of what would be downloaded, don't download")
+ help=_("Just list urls of what would be downloaded, don't download"))
parser.add_option("-n", "--newest-only", dest='newest', default=False, action="store_true",
- help="Download only newest packages per-repo")
+ help=_("Download only newest packages per-repo"))
parser.add_option("-q", "--quiet", default=False, action="store_true",
- help="Output as little as possible")
+ help=_("Output as little as possible"))
parser.add_option("-l", "--plugins", default=False, action="store_true",
- help="enable yum plugin support")
+ help=_("enable yum plugin support"))
parser.add_option("-m", "--downloadcomps", default=False, action="store_true",
- help="also download comps.xml")
+ help=_("also download comps.xml"))
parser.add_option("", "--download-metadata", dest="downloadmd",
default=False, action="store_true",
- help="download all the non-default metadata")
+ help=_("download all the non-default metadata"))
(opts, args) = parser.parse_args()
return (opts, args)
@@ -135,11 +137,11 @@ def main():
try:
os.makedirs(opts.destdir)
except OSError, e:
- print >> sys.stderr, "Error: Cannot create destination dir %s" % opts.destdir
+ print >> sys.stderr, _("Error: Cannot create destination dir %s") % opts.destdir
sys.exit(1)
if not os.access(opts.destdir, os.W_OK) and not opts.urls:
- print >> sys.stderr, "Error: Cannot write to destination dir %s" % opts.destdir
+ print >> sys.stderr, _("Error: Cannot write to destination dir %s") % opts.destdir
sys.exit(1)
my = RepoSync(opts=opts)
@@ -152,7 +154,7 @@ def main():
if opts.tempcache:
if not my.setCacheDir(force=True, reuse=False):
- print >> sys.stderr, "Error: Could not make cachedir, exiting"
+ print >> sys.stderr, _("Error: Could not make cachedir, exiting")
sys.exit(50)
my.conf.uid = 1 # force locking of user cache
elif opts.cachedir:
@@ -163,7 +165,7 @@ def main():
try:
my.doLock()
except yum.Errors.LockError, e:
- print >> sys.stderr, "Error: %s" % e
+ print >> sys.stderr, _("Error: %s") % e
sys.exit(50)
# Use progress bar display when downloading repo metadata
@@ -179,12 +181,12 @@ def main():
for glob in opts.repoid:
add_repos = my.repos.findRepos(glob)
if not add_repos:
- print >> sys.stderr, "Warning: cannot find repository %s" % glob
+ print >> sys.stderr, _("Warning: cannot find repository %s") % glob
continue
myrepos.extend(add_repos)
if not myrepos:
- print >> sys.stderr, "No repositories found"
+ print >> sys.stderr, _("No repositories found")
sys.exit(1)
# disable them all
@@ -197,7 +199,7 @@ def main():
# --norepopath can only be sensibly used with a single repository:
if len(my.repos.listEnabled()) > 1 and opts.norepopath:
- print >> sys.stderr, "Error: Can't use --norepopath with multiple repositories"
+ print >> sys.stderr, _("Error: Can't use --norepopath with multiple repositories")
sys.exit(1)
try:
@@ -206,7 +208,7 @@ def main():
arches += ['src']
my.doSackSetup(arches)
except yum.Errors.RepoError, e:
- print >> sys.stderr, "Error setting up repositories: %s" % e
+ print >> sys.stderr, _("Error setting up repositories: %s") % e
# maybe this shouldn't be entirely fatal
sys.exit(1)
commit 064f5567668a78152630ee326d2ef811edd4b9fa
Author: Miroslav Suchý <msuchy at redhat.com>
Date: Wed Mar 26 13:11:28 2014 +0100
codestyle changes
addressing:
C: 52, 0: No space allowed before comma
def sortPkgObj(pkg1 ,pkg2):
^ (bad-whitespace)
C: 52, 0: Exactly one space required after comma
def sortPkgObj(pkg1 ,pkg2):
^ (bad-whitespace)
C: 60, 0: Trailing whitespace (trailing-whitespace)
C: 82, 0: No space allowed after bracket
cache[name] = { 'path': fn, 'size': st.st_size, 'device': st.st_dev }
^ (bad-whitespace)
C: 82, 0: No space allowed before bracket
cache[name] = { 'path': fn, 'size': st.st_size, 'device': st.st_dev }
^ (bad-whitespace)
C:104, 0: Trailing whitespace (trailing-whitespace)
C:108, 0: Trailing whitespace (trailing-whitespace)
C:114, 0: Trailing whitespace (trailing-whitespace)
C:116, 0: Trailing whitespace (trailing-whitespace)
C:118, 0: Trailing whitespace (trailing-whitespace)
C:120, 0: Trailing whitespace (trailing-whitespace)
C:124, 0: Trailing whitespace (trailing-whitespace)
C:124, 0: Exactly one space required after comma
parser.add_option("","--download-metadata", dest="downloadmd",
^ (bad-whitespace)
C:125, 0: Trailing whitespace (trailing-whitespace)
C:133, 0: Trailing whitespace (trailing-whitespace)
C:140, 0: Trailing whitespace (trailing-whitespace)
C:144, 0: Trailing whitespace (trailing-whitespace)
C:177, 0: Trailing whitespace (trailing-whitespace)
C:189, 0: Trailing whitespace (trailing-whitespace)
C:193, 0: Trailing whitespace (trailing-whitespace)
C:206, 0: Exactly one space required after assignment
arches += ['src']
^^ (bad-whitespace)
C:212, 0: Trailing whitespace (trailing-whitespace)
C:221, 0: Trailing whitespace (trailing-whitespace)
C:256, 0: Trailing whitespace (trailing-whitespace)
C:269, 0: Exactly one space required before assignment
basename = os.path.basename(resultfile)
^ (bad-whitespace)
C:273, 0: Exactly one space required after comma
except yum.Errors.RepoMDError,e :
^ (bad-whitespace)
C:273, 0: No space allowed before :
except yum.Errors.RepoMDError,e :
^ (bad-whitespace)
C:276, 0: Trailing whitespace (trailing-whitespace)
C:335, 0: Trailing whitespace (trailing-whitespace)
diff --git a/reposync.py b/reposync.py
index 8f38adc..a675542 100755
--- a/reposync.py
+++ b/reposync.py
@@ -49,7 +49,7 @@ from urlgrabber.progress import TextMeter, TextMultiFileMeter
import urlgrabber
# for yum 2.4.X compat
-def sortPkgObj(pkg1 ,pkg2):
+def sortPkgObj(pkg1, pkg2):
"""sorts a list of yum package objects by name"""
if pkg1.name > pkg2.name:
return 1
@@ -57,7 +57,7 @@ def sortPkgObj(pkg1 ,pkg2):
return 0
else:
return -1
-
+
class RepoSync(yum.YumBase):
def __init__(self, opts):
yum.YumBase.__init__(self)
@@ -79,7 +79,7 @@ def localpkgs(directory):
for pkg in subcache.keys():
cache[pkg] = subcache[pkg]
elif stat.S_ISREG(st.st_mode) and name.endswith(".rpm"):
- cache[name] = { 'path': fn, 'size': st.st_size, 'device': st.st_dev }
+ cache[name] = {'path': fn, 'size': st.st_size, 'device': st.st_dev}
return cache
def parseArgs():
@@ -101,28 +101,28 @@ def parseArgs():
help="specify repo ids to query, can be specified multiple times (default is all enabled)")
parser.add_option("-e", "--cachedir",
help="directory in which to store metadata")
- parser.add_option("-t", "--tempcache", default=False, action="store_true",
+ parser.add_option("-t", "--tempcache", default=False, action="store_true",
help="Use a temp dir for storing/accessing yum-cache")
parser.add_option("-d", "--delete", default=False, action="store_true",
help="delete local packages no longer present in repository")
- parser.add_option("-p", "--download_path", dest='destdir',
+ parser.add_option("-p", "--download_path", dest='destdir',
default=os.getcwd(), help="Path to download packages to: defaults to current dir")
parser.add_option("--norepopath", dest='norepopath', default=False, action="store_true",
help="Don't add the reponame to the download path. Can only be used when syncing a single repository (default is to add the reponame)")
parser.add_option("-g", "--gpgcheck", default=False, action="store_true",
help="Remove packages that fail GPG signature checking after downloading")
- parser.add_option("-u", "--urls", default=False, action="store_true",
+ parser.add_option("-u", "--urls", default=False, action="store_true",
help="Just list urls of what would be downloaded, don't download")
- parser.add_option("-n", "--newest-only", dest='newest', default=False, action="store_true",
+ parser.add_option("-n", "--newest-only", dest='newest', default=False, action="store_true",
help="Download only newest packages per-repo")
- parser.add_option("-q", "--quiet", default=False, action="store_true",
+ parser.add_option("-q", "--quiet", default=False, action="store_true",
help="Output as little as possible")
- parser.add_option("-l", "--plugins", default=False, action="store_true",
+ parser.add_option("-l", "--plugins", default=False, action="store_true",
help="enable yum plugin support")
parser.add_option("-m", "--downloadcomps", default=False, action="store_true",
help="also download comps.xml")
- parser.add_option("","--download-metadata", dest="downloadmd",
- default=False, action="store_true",
+ parser.add_option("", "--download-metadata", dest="downloadmd",
+ default=False, action="store_true",
help="download all the non-default metadata")
(opts, args) = parser.parse_args()
return (opts, args)
@@ -130,18 +130,18 @@ def parseArgs():
def main():
(opts, dummy) = parseArgs()
-
+
if not os.path.exists(opts.destdir) and not opts.urls:
try:
os.makedirs(opts.destdir)
except OSError, e:
print >> sys.stderr, "Error: Cannot create destination dir %s" % opts.destdir
sys.exit(1)
-
+
if not os.access(opts.destdir, os.W_OK) and not opts.urls:
print >> sys.stderr, "Error: Cannot write to destination dir %s" % opts.destdir
sys.exit(1)
-
+
my = RepoSync(opts=opts)
my.doConfigSetup(fn=opts.config, init_plugins=opts.plugins)
@@ -174,7 +174,7 @@ def main():
if len(opts.repoid) > 0:
myrepos = []
-
+
# find the ones we want
for glob in opts.repoid:
add_repos = my.repos.findRepos(glob)
@@ -186,11 +186,11 @@ def main():
if not myrepos:
print >> sys.stderr, "No repositories found"
sys.exit(1)
-
+
# disable them all
for repo in my.repos.repos.values():
repo.disable()
-
+
# enable the ones we like
for repo in myrepos:
repo.enable()
@@ -203,13 +203,13 @@ def main():
try:
arches = rpmUtils.arch.getArchList(opts.arch)
if opts.source:
- arches += ['src']
+ arches += ['src']
my.doSackSetup(arches)
except yum.Errors.RepoError, e:
print >> sys.stderr, "Error setting up repositories: %s" % e
# maybe this shouldn't be entirely fatal
sys.exit(1)
-
+
exit_code = 0
for repo in my.repos.listEnabled():
reposack = ListPackageSack(my.pkgSack.returnPackages(repoid=repo.id))
@@ -218,7 +218,7 @@ def main():
download_list = reposack.returnNewestByNameArch()
else:
download_list = list(reposack)
-
+
if opts.norepopath:
local_repo_path = opts.destdir
else:
@@ -253,7 +253,7 @@ def main():
if opts.downloadcomps:
wanted_types = ['group']
-
+
if opts.downloadmd:
wanted_types = repo.repoXML.fileTypes()
@@ -266,14 +266,14 @@ def main():
try:
resultfile = repo.retrieveMD(ftype)
- basename = os.path.basename(resultfile)
+ basename = os.path.basename(resultfile)
if ftype == 'group' and opts.downloadcomps: # for compat with how --downloadcomps saved the comps file always as comps.xml
basename = 'comps.xml'
shutil.copyfile(resultfile, "%s/%s" % (local_repo_path, basename))
- except yum.Errors.RepoMDError,e :
+ except yum.Errors.RepoMDError, e:
if not opts.quiet:
my.logger.error("Unable to fetch metadata: %s" % e)
-
+
remote_size = 0
if not opts.urls:
for pkg in download_list:
@@ -332,4 +332,3 @@ def main():
if __name__ == "__main__":
main()
-
commit ab75511dfc4bff374751782fffe33ec29694236f
Author: Miroslav Suchý <msuchy at redhat.com>
Date: Wed Mar 26 13:05:14 2014 +0100
W: 45, 0: Unused import getCacheDir (unused-import)
diff --git a/reposync.py b/reposync.py
index 135e2b5..8f38adc 100755
--- a/reposync.py
+++ b/reposync.py
@@ -42,7 +42,6 @@ from urlparse import urljoin
import yum
import yum.Errors
-from yum.misc import getCacheDir
from yum.packageSack import ListPackageSack
import rpmUtils.arch
import logging
commit 9e1a5fac0aceb615eedfea6b8350016f5b25b893
Author: Miroslav Suchý <msuchy at redhat.com>
Date: Wed Mar 26 13:04:31 2014 +0100
remove unused wildcard import
diff --git a/reposync.py b/reposync.py
index c9c23e3..135e2b5 100755
--- a/reposync.py
+++ b/reposync.py
@@ -43,7 +43,6 @@ from urlparse import urljoin
import yum
import yum.Errors
from yum.misc import getCacheDir
-from yum.constants import *
from yum.packageSack import ListPackageSack
import rpmUtils.arch
import logging
commit 08f3f794d750ad1650dff95f4b4934040cd29108
Author: Miroslav Suchý <msuchy at redhat.com>
Date: Wed Mar 26 13:00:27 2014 +0100
W:280, 8: Unused variable local_size (unused-variable)
diff --git a/reposync.py b/reposync.py
index c4b4f7e..c9c23e3 100755
--- a/reposync.py
+++ b/reposync.py
@@ -277,7 +277,6 @@ def main():
my.logger.error("Unable to fetch metadata: %s" % e)
remote_size = 0
- local_size = 0
if not opts.urls:
for pkg in download_list:
remote = pkg.returnSimple('relativepath')
commit d6f7405f5ede8ddf0f42f7bd2f62333e7efd74a0
Author: Miroslav Suchý <msuchy at redhat.com>
Date: Wed Mar 26 12:59:35 2014 +0100
W:134,11: Unused variable junk (unused-variable)
diff --git a/reposync.py b/reposync.py
index cc4798d..c4b4f7e 100755
--- a/reposync.py
+++ b/reposync.py
@@ -131,7 +131,7 @@ def parseArgs():
def main():
- (opts, junk) = parseArgs()
+ (opts, dummy) = parseArgs()
if not os.path.exists(opts.destdir) and not opts.urls:
try:
More information about the Yum-commits
mailing list