euscan: better --quiet mode

Signed-off-by: Corentin Chary <corentincj@iksaif.net>
This commit is contained in:
Corentin Chary
2011-12-11 14:32:38 +01:00
parent e71e540d0d
commit 3569f1bb97
7 changed files with 108 additions and 85 deletions

View File

@ -29,7 +29,8 @@ from gentoolkit import pprinter as pp
from gentoolkit.eclean.search import (port_settings)
from gentoolkit.errors import GentoolkitException
from euscan import CONFIG, output
import euscan
from euscan import CONFIG
from euscan.scan import scan_upstream
""" Globals """
@ -198,7 +199,7 @@ def main():
sys.exit(errno.EINVAL)
""" Change euscan's output """
output = EOutput(CONFIG['quiet'])
euscan.output = EOutput(CONFIG['quiet'])
if CONFIG['verbose'] > 2:
httplib.HTTPConnection.debuglevel = 1
@ -208,29 +209,34 @@ def main():
try:
ret = scan_upstream(package)
except AmbiguousPackageName as e:
pkgs = e.args[0]
for candidate in pkgs:
print(candidate)
pkgs = e.args[0]
for candidate in pkgs:
print(candidate)
from os.path import basename # To get the short name
from os.path import basename # To get the short name
print(file=sys.stderr)
print(pp.error("The short ebuild name '%s' is ambiguous. Please specify" % basename(pkgs[0])),
file=sys.stderr, end="")
pp.die(1, "one of the above fully-qualified ebuild names instead.")
print(file=sys.stderr)
print(pp.error("The short ebuild name '%s' is ambiguous. Please specify" % basename(pkgs[0])),
file=sys.stderr, end="")
pp.die(1, "one of the above fully-qualified ebuild names instead.")
except GentoolkitException as err:
pp.die(1, str(err))
pp.die(1, str(err))
except Exception as err:
pp.die(1, str(err))
pp.die(1, str(err))
print ()
if not CONFIG['quiet']:
print ()
for url, version in ret:
print ("Upstream Version: "
+ pp.number("%s" % version)
+ pp.path(" %s" % url))
for cp, url, version in ret:
if not CONFIG['quiet']:
print ("Upstream Version: "
+ pp.number("%s" % version)
+ pp.path(" %s" % url))
else:
print (pp.cpv("%s-%s" % (cp, version))
+ ": " + pp.path(url))
if not len(ret):
if not len(ret) and not CONFIG['quiet']:
print (pp.warn("Didn't find any new version, "
+ "check package's homepage for "
+ "more informations"));