diff --git a/bin/euscan b/bin/euscan index 86c31f0..d41b079 100755 --- a/bin/euscan +++ b/bin/euscan @@ -37,8 +37,8 @@ def setupSignals(): def exithandler(signum,frame): signal.signal(signal.SIGINT, signal.SIG_IGN) signal.signal(signal.SIGTERM, signal.SIG_IGN) - print () - sys.exit(errno.EINTR) + print () + sys.exit(errno.EINTR) signal.signal(signal.SIGINT, exithandler) signal.signal(signal.SIGTERM, exithandler) @@ -74,37 +74,37 @@ def printUsage(_error=None, help=None): print( white("Usage:"), file=out) if _error in ('global-options', 'packages',) or help == 'all': print( " "+turquoise(__productname__), - yellow("[options]"), - green(""), file=out) + yellow("[options]"), + green(""), file=out) if _error in ('global-options',) or help == 'all': - print( " "+turquoise(__productname__), - yellow("[--help, --version]"), file=out) + print( " "+turquoise(__productname__), + yellow("[--help, --version]"), file=out) print(file=out) if _error in ('global-options',) or help: print( "Available ", yellow("options")+":", file=out) - print( yellow(" -C, --nocolor")+ - " - turn off colors on output", file=out) + print( yellow(" -C, --nocolor")+ + " - turn off colors on output", file=out) print( yellow(" -q, --quiet")+ - " - be as quiet as possible", file=out) - print( yellow(" -h, --help")+ \ - " - display the help screen", file=out) + " - be as quiet as possible", file=out) + print( yellow(" -h, --help")+ \ + " - display the help screen", file=out) print( yellow(" -V, --version")+ - " - display version info", file=out) + " - display version info", file=out) print( file=out) print( yellow(" -1, --oneshot")+ - " - stop as soon as a new version is found", file=out) + " - stop as soon as a new version is found", file=out) print( yellow(" -b, --brute-force=")+ - " - define the brute force "+yellow("")+" (default: 2)\n" + - " " * 29 + "bigger levels will generate more versions numbers\n" + - " " * 29 + "0 means disabled", file=out) + " - define the brute force "+yellow("")+" (default: 2)\n" + + " " * 29 + "bigger levels will generate more versions numbers\n" + + " " * 29 + "0 means disabled", file=out) print( file=out) if _error in ('packages',) or help: - print( green(" package")+ - " - the package (or ebuild) you want to scan", file=out) + print( green(" package")+ + " - the package (or ebuild) you want to scan", file=out) print( file=out) - '''print( "More detailed instruction can be found in", - turquoise("`man %s`" % __productname__), file=out)''' + '''print( "More detailed instruction can be found in", + turquoise("`man %s`" % __productname__), file=out)''' class ParseArgsException(Exception): diff --git a/pym/euscan/scan.py b/pym/euscan/scan.py index 1eb7bf9..2d937a4 100644 --- a/pym/euscan/scan.py +++ b/pym/euscan/scan.py @@ -2,18 +2,9 @@ from __future__ import print_function import os import sys -import re -import time -import getopt -import random -import urllib2 -import StringIO - -import pkg_resources import portage -import portage.versions -from portage import dep + from portage.dbapi import porttree from portage.output import white, yellow, turquoise, green, teal, red, EOutput @@ -83,22 +74,22 @@ def scan_upstream(query): sys.stderr.write(pp.warn("No package matching '%s'" % pp.pkgquery(query))) return [] - matches = sorted(matches) + matches = sorted(matches) pkg = matches.pop() - if '9999' in pkg.version: - if len(matches) == 0: - sys.stderr.write(pp.warn("Package '%s' only have a dev version (9999)" % pp.pkgquery(pkg.cp))) - return [] - else: - pkg = matches.pop() + if '9999' in pkg.version: + if len(matches) == 0: + sys.stderr.write(pp.warn("Package '%s' only have a dev version (9999)" % pp.pkgquery(pkg.cp))) + return [] + else: + pkg = matches.pop() - if pkg.cp in BLACKLIST_PACKAGES: - sys.stderr.write(pp.warn("Package '%s' is blacklisted" % pp.pkgquery(pkg.cp))) + if pkg.cp in BLACKLIST_PACKAGES: + sys.stderr.write(pp.warn("Package '%s' is blacklisted" % pp.pkgquery(pkg.cp))) return [] pp.uprint(" * %s [%s]" % (pp.cpv(pkg.cpv), pp.section(pkg.repo_name()))) - pp.uprint() + pp.uprint() ebuild_path = pkg.ebuild_path() if ebuild_path: @@ -108,23 +99,23 @@ def scan_upstream(query): pp.uprint('Homepage: ' + pkg.environment("HOMEPAGE")) pp.uprint('Description: ' + pkg.environment("DESCRIPTION")) - cpv = pkg.cpv - metadata = { - "EAPI" : port_settings["EAPI"], - "SRC_URI" : pkg.environment("SRC_URI", False), - } - use = frozenset(port_settings["PORTAGE_USE"].split()) - try: - alist = porttree._parse_uri_map(cpv, metadata, use=use) - aalist = porttree._parse_uri_map(cpv, metadata) - except Exception as e: + cpv = pkg.cpv + metadata = { + "EAPI" : port_settings["EAPI"], + "SRC_URI" : pkg.environment("SRC_URI", False), + } + use = frozenset(port_settings["PORTAGE_USE"].split()) + try: + alist = porttree._parse_uri_map(cpv, metadata, use=use) + aalist = porttree._parse_uri_map(cpv, metadata) + except Exception as e: sys.stderr.write(pp.warn("%s\n" % str(e))) sys.stderr.write(pp.warn("Invalid SRC_URI for '%s'" % pp.pkgquery(cpv))) return [] - if "mirror" in portage.settings.features: - urls = aalist - else: - urls = alist + if "mirror" in portage.settings.features: + urls = aalist + else: + urls = alist - return scan_upstream_urls(pkg.cpv, urls) + return scan_upstream_urls(pkg.cpv, urls)