From: Zac Medico Date: Sun, 22 Apr 2012 21:58:55 +0000 (-0700) Subject: portageq: use return instead of sys.exit X-Git-Tag: v2.2.0_alpha101~2 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=bb4113adef8e412c7dfa934cbaf0123f08a071e1;p=portage.git portageq: use return instead of sys.exit --- diff --git a/bin/portageq b/bin/portageq index dc465d211..280fe94c2 100755 --- a/bin/portageq +++ b/bin/portageq @@ -86,7 +86,7 @@ def has_version(argv): """ if (len(argv) < 2): print("ERROR: insufficient parameters!") - sys.exit(2) + return 2 warnings = [] @@ -116,11 +116,11 @@ def has_version(argv): try: mylist = portage.db[argv[0]]["vartree"].dbapi.match(atom) if mylist: - sys.exit(0) + return 0 else: - sys.exit(1) + return 1 except KeyError: - sys.exit(1) + return 1 except portage.exception.InvalidAtom: portage.writemsg("ERROR: Invalid atom: '%s'\n" % argv[1], noiselevel=-1) @@ -134,7 +134,7 @@ def best_version(argv): """ if (len(argv) < 2): print("ERROR: insufficient parameters!") - sys.exit(2) + return 2 warnings = [] @@ -165,7 +165,7 @@ def best_version(argv): mylist = portage.db[argv[0]]["vartree"].dbapi.match(atom) print(portage.best(mylist)) except KeyError: - sys.exit(1) + return 1 best_version.uses_root = True @@ -175,19 +175,19 @@ def mass_best_version(argv): """ if (len(argv) < 2): print("ERROR: insufficient parameters!") - sys.exit(2) + return 2 try: for pack in argv[1:]: mylist=portage.db[argv[0]]["vartree"].dbapi.match(pack) print(pack+":"+portage.best(mylist)) except KeyError: - sys.exit(1) + return 1 mass_best_version.uses_root = True def metadata(argv): if (len(argv) < 4): print("ERROR: insufficient parameters!", file=sys.stderr) - sys.exit(2) + return 2 eroot, pkgtype, pkgspec = argv[0:3] metakeys = argv[3:] @@ -197,7 +197,7 @@ def metadata(argv): "installed":"vartree"} if pkgtype not in type_map: print("Unrecognized package type: '%s'" % pkgtype, file=sys.stderr) - sys.exit(1) + return 1 trees = portage.db repo = portage.dep.dep_getrepo(pkgspec) pkgspec = portage.dep.remove_slot(pkgspec) @@ -207,7 +207,7 @@ def metadata(argv): writemsg_stdout(''.join('%s\n' % x for x in values), noiselevel=-1) except KeyError: print("Package not found: '%s'" % pkgspec, file=sys.stderr) - sys.exit(1) + return 1 metadata.__doc__ = """ []+ @@ -524,7 +524,7 @@ def mass_best_visible(argv): if (len(argv) < 2): print("ERROR: insufficient parameters!") - sys.exit(2) + return 2 try: root = argv.pop(0) pkgtype = "ebuild" @@ -534,7 +534,7 @@ def mass_best_visible(argv): writemsg_stdout("%s:" % pack, noiselevel=-1) best_visible([root, pkgtype, pack]) except KeyError: - sys.exit(1) + return 1 mass_best_visible.uses_root = True @@ -563,7 +563,7 @@ def match(argv): """ if len(argv) != 2: print("ERROR: expected 2 parameters, got %d!" % len(argv)) - sys.exit(2) + return 2 root, atom = argv if not atom: atom = "*/*" @@ -718,7 +718,7 @@ def envvar(argv): if len(argv) == 0: print("ERROR: insufficient parameters!") - sys.exit(2) + return 2 for arg in argv: if verbose: @@ -732,7 +732,7 @@ def get_repos(argv): """ if len(argv) < 1: print("ERROR: insufficient parameters!") - sys.exit(2) + return 2 print(" ".join(portage.db[argv[0]]["porttree"].dbapi.getRepositories())) get_repos.uses_root = True @@ -743,7 +743,7 @@ def get_repo_path(argv): """ if len(argv) < 2: print("ERROR: insufficient parameters!") - sys.exit(2) + return 2 for arg in argv[1:]: path = portage.db[argv[0]]["porttree"].dbapi.getRepositoryPath(arg) if path is None: @@ -761,7 +761,7 @@ def list_preserved_libs(argv): if len(argv) != 1: print("ERROR: wrong number of arguments") - sys.exit(2) + return 2 mylibs = portage.db[argv[0]]["vartree"].dbapi._plib_registry.getPreservedLibs() rValue = 1 msg = []