diff options
author | Elan Ruusamäe | 2011-02-10 12:56:59 (GMT) |
---|---|---|
committer | Elan Ruusamäe | 2011-02-10 12:56:59 (GMT) |
commit | 66a581323cf612cb544de5011995686eb3315a95 (patch) | |
tree | 96693e440ad6494ff8226853cec2e4455d101843 /bin | |
parent | 5a13eb89447da79cac01940ce3b13e26317e935d (diff) | |
download | pld-ftp-admin-66a581323cf612cb544de5011995686eb3315a95.zip pld-ftp-admin-66a581323cf612cb544de5011995686eb3315a95.tar.gz |
- add getopt support and -q option
Changed files:
bin/pfa-lintpkg -> 1.7
Diffstat (limited to 'bin')
-rw-r--r-- | bin/pfa-lintpkg | 45 |
1 files changed, 32 insertions, 13 deletions
diff --git a/bin/pfa-lintpkg b/bin/pfa-lintpkg index e603069..f0c0cdf 100644 --- a/bin/pfa-lintpkg +++ b/bin/pfa-lintpkg @@ -2,47 +2,63 @@ # vi: encoding=utf-8 ts=8 sts=4 sw=4 et import sys, os, re +import getopt import subprocess sys.path.insert(0, os.environ['HOME']+'/pld-ftp-admin/modules') import ftptree from common import checkdir import ftpio -if len(sys.argv) < 2: - print >>sys.stderr, "ERR: not enough parameters given" +try: + opts, args = getopt.getopt(sys.argv[1:], 'q', [ "quiet" ]) +except getopt.GetoptError: + print >>sys.stderr, "ERR: options error" + print >>sys.stderr, "rpmlint.py tree package1 [package2...]" + sys.exit(1) + +quiet = False +for o, a in opts: + if o == "-q" or o == "--quiet": + quiet = True + +if len(args) < 1: + print >>sys.stderr, "ERR: missing tree name" print >>sys.stderr, "rpmlint.py tree package1 [package2...]" sys.exit(1) -checkdir(sys.argv[1]) +treename = args[0] +packages = args[1:] + +checkdir(treename) ftpio.connect('rpmlint') -if not ftpio.lock(sys.argv[1], True): - print >>sys.stderr, "ERR: %s tree already locked" % sys.argv[1] +if not ftpio.lock(treename, True): + print >>sys.stderr, "ERR: %s tree already locked" % treename sys.exit(1) files = [] try: - if len(sys.argv) < 3: + if len(packages) < 1: loadall = True else: loadall = False # if no files specified, grab whole tree contents - tree = ftptree.FtpTree(sys.argv[1], loadall = loadall) + tree = ftptree.FtpTree(treename, loadall = loadall) if loadall: # this is hack, should be a param, not access private .loadedpkgs element tree.mark4moving(tree.loadedpkgs) else: - tree.mark4moving(sys.argv[2:]) + tree.mark4moving(packages) files = tree.rpmfiles(debugfiles = False, sourcefiles = False) except (ftptree.SomeError, KeyboardInterrupt), e: # In case of problems we need to unlock the tree before exiting - ftpio.unlock(sys.argv[1]) + ftpio.unlock(treename) sys.exit(1) -ftpio.unlock(sys.argv[1]) +ftpio.unlock(treename) class LintPkg: def __init__(self, cachedir): @@ -105,10 +121,13 @@ class LintPkg: rc = 1 return rc == 0 -print "rpmlint of %d files from %d packages" % (len(files), len(tree.loadedpkgs)) +if not quiet: + print "rpmlint of %d files from %d packages" % (len(files), len(tree.loadedpkgs)) lint = LintPkg("~/tmp/rpmlint") for file in files: lint.rpmlint(file) - lint.print_stats(file) + if not quiet: + lint.print_stats(file) -lint.print_stats() +if not quiet: + lint.print_stats() |