From 9a8b8afe8fd54e8aff3c2af4a2a600bff58fd827 Mon Sep 17 00:00:00 2001 From: genone Date: Tue, 15 Nov 2005 21:20:49 +0000 Subject: [PATCH] - Moving lots of stuff from stdout to stderr - Replace all "print" calls with matching write() calls - add new "affected" target - add support for a EMERGE_OPTS env var - check that GLSA_DIR exists - add --cve option requested by solar - show title on --test --verbose - better exception handling svn path=/; revision=258 --- trunk/src/glsa-check/glsa-check | 160 ++++++++++++++++++-------------- 1 file changed, 90 insertions(+), 70 deletions(-) diff --git a/trunk/src/glsa-check/glsa-check b/trunk/src/glsa-check/glsa-check index a922a51..d680d62 100644 --- a/trunk/src/glsa-check/glsa-check +++ b/trunk/src/glsa-check/glsa-check @@ -11,7 +11,7 @@ from getopt import getopt,GetoptError __program__ = "glsa-check" __author__ = "Marius Mauch " -__version__ = "0.5" +__version__ = "0.6" optionmap = [ ["-l", "--list", "list all unapplied GLSA"], @@ -23,23 +23,24 @@ optionmap = [ ["-n", "--nocolor", "disable colors (option)"], ["-h", "--help", "show this help message"], ["-V", "--version", "some information about this tool"], -["-v", "--verbose", "print more messages (option)"], +["-v", "--verbose", "print more information (option)"], +["-c", "--cve", "show CAN ids n listing mode (option)"], ] -# print a warning as this is beta code -sys.stderr.write("WARNING: This tool is completely new and not very tested, so it should not be\n") -sys.stderr.write("used on production systems. It's mainly a test tool for the new GLSA release\n") -sys.stderr.write("and distribution system, it's functionality will later be merged into emerge\n") -sys.stderr.write("and equery.\n") -sys.stderr.write("Please read http://www.gentoo.org/proj/en/portage/glsa-integration.xml\n") -sys.stderr.write("before using this tool AND before reporting a bug.\n\n") +# print a warning as this is beta code (but proven by now, so no more warning) +#sys.stderr.write("WARNING: This tool is completely new and not very tested, so it should not be\n") +#sys.stderr.write("used on production systems. It's mainly a test tool for the new GLSA release\n") +#sys.stderr.write("and distribution system, it's functionality will later be merged into emerge\n") +#sys.stderr.write("and equery.\n") +#sys.stderr.write("Please read http://www.gentoo.org/proj/en/portage/glsa-integration.xml\n") +#sys.stderr.write("before using this tool AND before reporting a bug.\n\n") # option parsing args = [] params = [] try: - args, params = getopt(sys.argv[1:], "dplfchinvVt", \ - ["dump", "print", "list", "pretend", "fix", "inject", "help", "info", "version", "test", "nocolor"]) + args, params = getopt(sys.argv[1:], "dplfchinvVtc", \ + ["dump", "print", "list", "pretend", "fix", "inject", "help", "info", "version", "test", "nocolor", "cve"]) args = [a for a,b in args] for option in ["--nocolor", "-n"]: @@ -53,12 +54,18 @@ try: verbose = True args.remove(option) + list_cve = False + for option in ["--cve", "-c"]: + if option in args: + list_cve = True + args.remove(option) + # sanity checking if len(args) <= 0: - print "no option given: what should I do ?" + sys.stderr.write("no option given: what should I do ?\n") mode="help" elif len(args) > 1: - print "please use only one command per call" + sys.stderr.write("please use only one command per call\n") mode = "help" else: # in what mode are we ? @@ -68,50 +75,41 @@ try: mode = m[1][2:] except GetoptError, e: - print "unknown option given:", e + sys.stderr.write("unknown option given: ") + sys.stderr.write(str(e)+"\n") mode = "help" # we need a set of glsa for most operation modes if len(params) <= 0 and mode in ["fix", "test", "pretend", "dump", "inject"]: - print - print "no GLSA given, so we'll do nothing for now. " - print "If you want to run on all GLSA please tell me so " - print "(specify \"all\" as parameter)" - print + sys.stderr.write("\nno GLSA given, so we'll do nothing for now. \n") + sys.stderr.write("If you want to run on all GLSA please tell me so \n") + sys.stderr.write("(specify \"all\" as parameter)\n\n") mode = "help" elif len(params) <= 0 and mode == "list": params.append("new") # show help message if mode == "help": - print - print "Syntax: glsa-check