Пример #1
0
                    def highlight_violations(atom, version, use=[]):
                        """Colorize parts of an atom"""
                        atom_str = str(atom)
                        if version:
                            op = atom.operator
                            ver = cpv_getversion(atom.cpv)
                            slot = atom.slot
                            atom_str = atom_str.replace(
                                op, colorize("BAD", op), 1)

                            start = atom_str.rfind(ver)
                            end = start + len(ver)
                            atom_str = atom_str[:start] + \
                             colorize("BAD", ver) + \
                             atom_str[end+1:]
                            if slot:
                                atom_str = atom_str.replace(
                                    ":" + slot, colorize("BAD", ":" + slot))

                        if use and atom.use.tokens:
                            use_part_start = atom_str.find("[")
                            use_part_end = atom_str.find("]")

                            new_tokens = []
                            for token in atom.use.tokens:
                                if token.lstrip("-!").rstrip("=?") in use:
                                    new_tokens.append(colorize("BAD", token))
                                else:
                                    new_tokens.append(token)

                            atom_str = atom_str[:use_part_start] \
                             + "[%s]" % (",".join(new_tokens),) + \
                             atom_str[use_part_end+1:]

                        return atom_str
Пример #2
0
	def show_diff(s):
		output = ''

		for tag, i0, i1, j0, j1 in s.get_opcodes():

			if tag == 'equal':
				output += s.a[i0:i1]

			if tag in ('delete', 'replace'):
				o = s.a[i0:i1]
				if style == 'color-inline':
					o = colorize('bg_darkred', o)
				else:
					o = '-{%s}' % o
				output += o

			if tag in ('insert', 'replace'):
				o = s.b[j0:j1]
				if style == 'color-inline':
					o = colorize('bg_darkgreen', o)
				else:
					o = '+{%s}' % o
				output += o

		return output
Пример #3
0
	def pkgprint(pkg_str, pkg_info):
		"""Colorizes a string acording to pkg_info settings

		@param pkg_str: string
		@param pkg_info: dictionary
		@rtype colorized string
		"""
		if pkg_info.merge:
			if pkg_info.built:
				if pkg_info.system:
					return colorize("PKG_BINARY_MERGE_SYSTEM", pkg_str)
				elif pkg_info.world:
					return colorize("PKG_BINARY_MERGE_WORLD", pkg_str)
				else:
					return colorize("PKG_BINARY_MERGE", pkg_str)
			else:
				if pkg_info.system:
					return colorize("PKG_MERGE_SYSTEM", pkg_str)
				elif pkg_info.world:
					return colorize("PKG_MERGE_WORLD", pkg_str)
				else:
					return colorize("PKG_MERGE", pkg_str)
		elif pkg_info.operation == "uninstall":
			return colorize("PKG_UNINSTALL", pkg_str)
		else:
			if pkg_info.system:
				return colorize("PKG_NOMERGE_SYSTEM", pkg_str)
			elif pkg_info.world:
				return colorize("PKG_NOMERGE_WORLD", pkg_str)
			else:
				return colorize("PKG_NOMERGE", pkg_str)
Пример #4
0
	def _start(self):

		pkg = self.merge.pkg
		pkg_count = self.merge.pkg_count

		if pkg.installed:
			action_desc = "Uninstalling"
			preposition = "from"
			counter_str = ""
		else:
			action_desc = "Installing"
			preposition = "to"
			counter_str = "(%s of %s) " % \
				(colorize("MERGE_LIST_PROGRESS", str(pkg_count.curval)),
				colorize("MERGE_LIST_PROGRESS", str(pkg_count.maxval)))

		msg = "%s %s%s" % \
			(action_desc,
			counter_str,
			colorize("GOOD", pkg.cpv))

		if pkg.root != "/":
			msg += " %s %s" % (preposition, pkg.root)

		if not self.merge.build_opts.fetchonly and \
			not self.merge.build_opts.pretend and \
			not self.merge.build_opts.buildpkgonly:
			self.merge.statusMessage(msg)

		self.returncode = self.merge.merge()
		self.wait()
Пример #5
0
def _finalize():
	global _items
	printer = EOutput()
	for root, key, logentries, logfile in _items:
		print()
		if root == "/":
			printer.einfo(_("Messages for package %s:") %
				colorize("INFORM", key))
		else:
			printer.einfo(_("Messages for package %(pkg)s merged to %(root)s:") %
				{"pkg": colorize("INFORM", key), "root": root})
		if logfile is not None:
			printer.einfo(_("Log file: %s") % colorize("INFORM", logfile))
		print()
		for phase in EBUILD_PHASES:
			if phase not in logentries:
				continue
			for msgtype, msgcontent in logentries[phase]:
				fmap = {"INFO": printer.einfo,
						"WARN": printer.ewarn,
						"ERROR": printer.eerror,
						"LOG": printer.einfo,
						"QA": printer.ewarn}
				if isinstance(msgcontent, basestring):
					msgcontent = [msgcontent]
				for line in msgcontent:
					fmap[msgtype](line.strip("\n"))
	_items = []
	return
Пример #6
0
def deprecated_profile_check(settings=None):
	config_root = "/"
	if settings is not None:
		config_root = settings["PORTAGE_CONFIGROOT"]
	deprecated_profile_file = os.path.join(config_root,
		DEPRECATED_PROFILE_FILE)
	if not os.access(deprecated_profile_file, os.R_OK):
		return False
	dcontent = codecs.open(_unicode_encode(deprecated_profile_file,
		encoding=_encodings['fs'], errors='strict'), 
		mode='r', encoding=_encodings['content'], errors='replace').readlines()
	writemsg(colorize("BAD", _("\n!!! Your current profile is "
		"deprecated and not supported anymore.")) + "\n", noiselevel=-1)
	writemsg(colorize("BAD", _("!!! Use eselect profile to update your "
		"profile.")) + "\n", noiselevel=-1)
	if not dcontent:
		writemsg(colorize("BAD", _("!!! Please refer to the "
			"Gentoo Upgrading Guide.")) + "\n", noiselevel=-1)
		return True
	newprofile = dcontent[0]
	writemsg(colorize("BAD", _("!!! Please upgrade to the "
		"following profile if possible:")) + "\n", noiselevel=-1)
	writemsg(8*" " + colorize("GOOD", newprofile) + "\n", noiselevel=-1)
	if len(dcontent) > 1:
		writemsg(_("To upgrade do the following steps:\n"), noiselevel=-1)
		for myline in dcontent[1:]:
			writemsg(myline, noiselevel=-1)
		writemsg("\n\n", noiselevel=-1)
	return True
Пример #7
0
    def unlock(self):
        """
        Set GPG_TTY and run GPG unlock command.
        If gpg-keepalive is set, start keepalive thread.
        """
        if self.GPG_unlock_command and (
            self.settings.get("BINPKG_FORMAT", SUPPORTED_GENTOO_BINPKG_FORMATS[0])
            == "gpkg"
        ):
            try:
                os.environ["GPG_TTY"] = os.ttyname(sys.stdout.fileno())
            except OSError as e:
                # When run with no input/output tty, this will fail.
                # However, if the password is given by command,
                # GPG does not need to ask password, so can be ignored.
                writemsg(colorize("WARN", str(e)) + "\n")

            cmd = shlex_split(varexpand(self.GPG_unlock_command, mydict=self.settings))
            return_code = subprocess.Popen(cmd).wait()

            if return_code == os.EX_OK:
                writemsg_stdout(colorize("GOOD", "unlocked") + "\n")
                sys.stdout.flush()
            else:
                raise GPGException("GPG unlock failed")

            if self.keepalive:
                self.GPG_unlock_command = shlex_split(
                    varexpand(self.GPG_unlock_command, mydict=self.settings)
                )
                self.thread = threading.Thread(target=self.gpg_keepalive, daemon=True)
                self.thread.start()
Пример #8
0
    def ask(self, name, input_f=raw_input):
        """Ask for a config value.

        :param name: Name of config option to be retrieved
        :type name: string
        :param input_f: function to do the asking
        :type: input_f: function
        :returns: Config value or if given option not valid, ask again.

        """
        if self.IS_FIRST_QUESTION:
            self.print_help()

        if self.options.nocolors:
            msg = "%s [%r]: "
        else:
            msg = colorize("GOOD", " * ") + "%s" + colorize("BRACKET", " [")\
                + "%r" + colorize("BRACKET", ']') + ": "

        option = Config.allowed_options[name]
        # ask the question or use default
        answer = input_f(msg % (option[0].capitalize(), option[2])) or option[2]

        try:
            return Config.validate(name, answer)
        except GPyPiValidationError, e:
            log.error("Error: %s" % e)
            return self.ask(name, input_f)
Пример #9
0
    def _start(self):

        self.scheduler = self.merge.scheduler
        pkg = self.merge.pkg
        pkg_count = self.merge.pkg_count
        pkg_color = "PKG_MERGE"
        if pkg.type_name == "binary":
            pkg_color = "PKG_BINARY_MERGE"

        if pkg.installed:
            action_desc = "Uninstalling"
            preposition = "from"
            counter_str = ""
        else:
            action_desc = "Installing"
            preposition = "to"
            counter_str = "(%s of %s) " % (
                colorize("MERGE_LIST_PROGRESS", str(pkg_count.curval)),
                colorize("MERGE_LIST_PROGRESS", str(pkg_count.maxval)),
            )

        msg = "%s %s%s" % (action_desc, counter_str, colorize(pkg_color, pkg.cpv + _repo_separator + pkg.repo))

        if pkg.root_config.settings["ROOT"] != "/":
            msg += " %s %s" % (preposition, pkg.root)

        if (
            not self.merge.build_opts.fetchonly
            and not self.merge.build_opts.pretend
            and not self.merge.build_opts.buildpkgonly
        ):
            self.merge.statusMessage(msg)

        task = self.merge.create_install_task()
        self._start_task(task, self._default_final_exit)
Пример #10
0
def _finalize():
    global _items
    printer = EOutput()
    for root, key, logentries in _items:
        print()
        if root == "/":
            printer.einfo(
                _("Messages for package %s:") % colorize("INFORM", key))
        else:
            printer.einfo(
                _("Messages for package %(pkg)s merged to %(root)s:") % {
                    "pkg": colorize("INFORM", key),
                    "root": root
                })
        print()
        for phase in EBUILD_PHASES:
            if phase not in logentries:
                continue
            for msgtype, msgcontent in logentries[phase]:
                fmap = {
                    "INFO": printer.einfo,
                    "WARN": printer.ewarn,
                    "ERROR": printer.eerror,
                    "LOG": printer.einfo,
                    "QA": printer.ewarn
                }
                if isinstance(msgcontent, basestring):
                    msgcontent = [msgcontent]
                for line in msgcontent:
                    fmap[msgtype](line.strip("\n"))
    _items = []
    return
Пример #11
0
def chk_updated_cfg_files(eroot, config_protect):
    target_root = eroot
    result = list(
        portage.util.find_updated_config_files(target_root, config_protect))

    for x in result:
        writemsg_level("\n %s " % (colorize("WARN", "* " + _("IMPORTANT:"))),
                       level=logging.INFO,
                       noiselevel=-1)
        if not x[1]:  # it's a protected file
            writemsg_level(_("config file '%s' needs updating.\n") % x[0],
                           level=logging.INFO,
                           noiselevel=-1)
        else:  # it's a protected dir
            if len(x[1]) == 1:
                head, tail = os.path.split(x[1][0])
                tail = tail[len("._cfg0000_"):]
                fpath = os.path.join(head, tail)
                writemsg_level(_("config file '%s' needs updating.\n") % fpath,
                               level=logging.INFO,
                               noiselevel=-1)
            else:
                writemsg_level(
                 _("%d config files in '%s' need updating.\n") % \
                 (len(x[1]), x[0]), level=logging.INFO, noiselevel=-1)

    if result:
        print(" " + yellow("*") + " See the " +
              colorize("INFORM", _("CONFIGURATION FILES")) + " " +
              _("section of the") + " " + bold("emerge"))
        print(" " + yellow("*") + " " +
              _("man page to learn how to update config files."))
Пример #12
0
    def pkgprint(pkg_str, pkg_info):
        """Colorizes a string acording to pkg_info settings

		@param pkg_str: string
		@param pkg_info: dictionary
		@rtype colorized string
		"""
        if pkg_info.merge:
            if pkg_info.built:
                if pkg_info.system:
                    return colorize("PKG_BINARY_MERGE_SYSTEM", pkg_str)
                elif pkg_info.world:
                    return colorize("PKG_BINARY_MERGE_WORLD", pkg_str)
                else:
                    return colorize("PKG_BINARY_MERGE", pkg_str)
            else:
                if pkg_info.system:
                    return colorize("PKG_MERGE_SYSTEM", pkg_str)
                elif pkg_info.world:
                    return colorize("PKG_MERGE_WORLD", pkg_str)
                else:
                    return colorize("PKG_MERGE", pkg_str)
        elif pkg_info.operation == "uninstall":
            return colorize("PKG_UNINSTALL", pkg_str)
        else:
            if pkg_info.system:
                return colorize("PKG_NOMERGE_SYSTEM", pkg_str)
            elif pkg_info.world:
                return colorize("PKG_NOMERGE_WORLD", pkg_str)
            else:
                return colorize("PKG_NOMERGE", pkg_str)
Пример #13
0
def finalize(mysettings=None):
	"""The mysettings parameter is just for backward compatibility since
	an older version of portage will import the module from a newer version
	when it upgrades itself."""
	global _items
	printer = EOutput()
	for root, key, logentries in _items:
		print()
		if root == "/":
			printer.einfo(_("Messages for package %s:") %
				colorize("INFORM", key))
		else:
			printer.einfo(_("Messages for package %(pkg)s merged to %(root)s:") %
				{"pkg": colorize("INFORM", key), "root": root})
		print()
		for phase in EBUILD_PHASES:
			if phase not in logentries:
				continue
			for msgtype, msgcontent in logentries[phase]:
				fmap = {"INFO": printer.einfo,
						"WARN": printer.ewarn,
						"ERROR": printer.eerror,
						"LOG": printer.einfo,
						"QA": printer.ewarn}
				if isinstance(msgcontent, basestring):
					msgcontent = [msgcontent]
				for line in msgcontent:
					fmap[msgtype](line.strip("\n"))
	_items = []
	return
Пример #14
0
 def addSuccess(self, test):
     super(_TextTestResult, self).addSuccess(test)
     if self.showAll:
         self.stream.writeln(colorize("GOOD", "ok"))
     elif self.dots:
         self.stream.write(colorize("GOOD", "."))
         self.stream.flush()
Пример #15
0
    def show_diff(s):
        output = ""

        for tag, i0, i1, j0, j1 in s.get_opcodes():

            if tag == "equal":
                output += s.a[i0:i1]

            if tag in ("delete", "replace"):
                o = s.a[i0:i1]
                if style == "color-inline":
                    o = colorize("bg_darkred", o)
                else:
                    o = "-{%s}" % o
                output += o

            if tag in ("insert", "replace"):
                o = s.b[j0:j1]
                if style == "color-inline":
                    o = colorize("bg_darkgreen", o)
                else:
                    o = "+{%s}" % o
                output += o

        return output
Пример #16
0
	def show_diff(s):
		output = ''

		for tag, i0, i1, j0, j1 in s.get_opcodes():

			if tag == 'equal':
				output += s.a[i0:i1]

			if tag in ('delete', 'replace'):
				o = s.a[i0:i1]
				if style == 'color-inline':
					o = colorize('bg_darkred', o)
				else:
					o = '-{%s}' % o
				output += o

			if tag in ('insert', 'replace'):
				o = s.b[j0:j1]
				if style == 'color-inline':
					o = colorize('bg_darkgreen', o)
				else:
					o = '+{%s}' % o
				output += o

		return output
Пример #17
0
	def _start(self):

		self.scheduler = self.merge.scheduler
		pkg = self.merge.pkg
		pkg_count = self.merge.pkg_count

		if pkg.installed:
			action_desc = "Uninstalling"
			preposition = "from"
			counter_str = ""
		else:
			action_desc = "Installing"
			preposition = "to"
			counter_str = "(%s of %s) " % \
				(colorize("MERGE_LIST_PROGRESS", str(pkg_count.curval)),
				colorize("MERGE_LIST_PROGRESS", str(pkg_count.maxval)))

		msg = "%s %s%s" % \
			(action_desc,
			counter_str,
			colorize("GOOD", pkg.cpv))

		if pkg.root != "/":
			msg += " %s %s" % (preposition, pkg.root)

		if not self.merge.build_opts.fetchonly and \
			not self.merge.build_opts.pretend and \
			not self.merge.build_opts.buildpkgonly:
			self.merge.statusMessage(msg)

		task = self.merge.create_install_task()
		self._start_task(task, self._default_final_exit)
Пример #18
0
					def highlight_violations(atom, version, use=[]):
						"""Colorize parts of an atom"""
						atom_str = str(atom)
						if version:
							op = atom.operator
							ver = cpv_getversion(atom.cpv)
							slot = atom.slot
							atom_str = atom_str.replace(op, colorize("BAD", op), 1)
							
							start = atom_str.rfind(ver)
							end = start + len(ver)
							atom_str = atom_str[:start] + \
								colorize("BAD", ver) + \
								atom_str[end+1:]
							if slot:
								atom_str = atom_str.replace(":" + slot, colorize("BAD", ":" + slot))
						
						if use and atom.use.tokens:
							use_part_start = atom_str.find("[")
							use_part_end = atom_str.find("]")
							
							new_tokens = []
							for token in atom.use.tokens:
								if token.lstrip("-!").rstrip("=?") in use:
									new_tokens.append(colorize("BAD", token))
								else:
									new_tokens.append(token)

							atom_str = atom_str[:use_part_start] \
								+ "[%s]" % (",".join(new_tokens),) + \
								atom_str[use_part_end+1:]
						
						return atom_str
Пример #19
0
    def ask(self, name, input_f=raw_input):
        """Ask for a config value.

        :param name: Name of config option to be retrieved
        :type name: string
        :param input_f: function to do the asking
        :type: input_f: function
        :returns: Config value or if given option not valid, ask again.

        """
        if self.IS_FIRST_QUESTION:
            self.print_help()

        if self.options.nocolors:
            msg = "%s [%r]: "
        else:
            msg = colorize("GOOD", " * ") + "%s" + colorize("BRACKET", " [") + "%r" + colorize("BRACKET", "]") + ": "

        option = Config.allowed_options[name]
        # ask the question or use default
        answer = input_f(msg % (option[0].capitalize(), option[2])) or option[2]

        try:
            return Config.validate(name, answer)
        except GPyPiValidationError, e:
            log.error("Error: %s" % e)
            return self.ask(name, input_f)
Пример #20
0
 def run(self, test):
     """
     Run the given test case or test suite.
     """
     result = self._makeResult()
     startTime = time.time()
     test(result)
     stopTime = time.time()
     timeTaken = stopTime - startTime
     result.printErrors()
     self.stream.writeln(result.separator2)
     run = result.testsRun
     self.stream.writeln("Ran %d test%s in %.3fs" %
                         (run, run != 1 and "s" or "", timeTaken))
     self.stream.writeln()
     if not result.wasSuccessful():
         self.stream.write(colorize("BAD", "FAILED") + " (")
         failed = len(result.failures)
         errored = len(result.errors)
         if failed:
             self.stream.write("failures=%d" % failed)
         if errored:
             if failed:
                 self.stream.write(", ")
             self.stream.write("errors=%d" % errored)
         self.stream.writeln(")")
     else:
         self.stream.writeln(colorize("GOOD", "OK"))
     return result
Пример #21
0
 def addFailure(self, test, err):
     super(_TextTestResult, self).addFailure(test, err)
     if self.showAll:
         self.stream.writeln(colorize("BAD", "FAIL"))
     elif self.dots:
         self.stream.write(colorize("BAD", "F"))
         self.stream.flush()
Пример #22
0
 def addError(self, test, err):
     super(_TextTestResult, self).addError(test, err)
     if self.showAll:
         self.stream.writeln(colorize("BAD", "ERROR"))
     elif self.dots:
         self.stream.write(colorize("HILITE", "E"))
         self.stream.flush()
Пример #23
0
def finalize(mysettings=None):
    """The mysettings parameter is just for backward compatibility since
	an older version of portage will import the module from a newer version
	when it upgrades itself."""
    global _items
    printer = EOutput()
    for root, key, logentries in _items:
        print()
        if root == "/":
            printer.einfo(
                _("Messages for package %s:") % colorize("INFORM", key))
        else:
            printer.einfo(
                _("Messages for package %(pkg)s merged to %(root)s:") % {
                    "pkg": colorize("INFORM", key),
                    "root": root
                })
        print()
        for phase in EBUILD_PHASES:
            if phase not in logentries:
                continue
            for msgtype, msgcontent in logentries[phase]:
                fmap = {
                    "INFO": printer.einfo,
                    "WARN": printer.ewarn,
                    "ERROR": printer.eerror,
                    "LOG": printer.einfo,
                    "QA": printer.ewarn
                }
                if isinstance(msgcontent, basestring):
                    msgcontent = [msgcontent]
                for line in msgcontent:
                    fmap[msgtype](line.strip("\n"))
    _items = []
    return
Пример #24
0
 def display(self):
     self.out.write(
         "\r" + colorize("WARN",
                         _("cache miss: '") + str(self.misses) + "'") +
         " --- " + colorize("GOOD",
                            _("cache hit: '") + str(self.hits) + "'"))
     self.out.flush()
Пример #25
0
def chk_updated_cfg_files(eroot, config_protect):
	target_root = eroot
	result = list(
		portage.util.find_updated_config_files(target_root, config_protect))

	for x in result:
		writemsg_level("\n %s " % (colorize("WARN", "* " + _("IMPORTANT:"))),
			level=logging.INFO, noiselevel=-1)
		if not x[1]: # it's a protected file
			writemsg_level( _("config file '%s' needs updating.\n") % x[0],
				level=logging.INFO, noiselevel=-1)
		else: # it's a protected dir
			if len(x[1]) == 1:
				head, tail = os.path.split(x[1][0])
				tail = tail[len("._cfg0000_"):]
				fpath = os.path.join(head, tail)
				writemsg_level(_("config file '%s' needs updating.\n") % fpath,
					level=logging.INFO, noiselevel=-1)
			else:
				writemsg_level(
					_("%d config files in '%s' need updating.\n") % \
					(len(x[1]), x[0]), level=logging.INFO, noiselevel=-1)

	if result:
		print(" " + yellow("*") + " See the " +
			colorize("INFORM", _("CONFIGURATION FILES")) + " and " +
			colorize("INFORM", _("CONFIGURATION FILES UPDATE TOOLS")))
		print(" " + yellow("*") + " sections of the " + bold("emerge") + " " +
			_("man page to learn how to update config files."))
Пример #26
0
    def _start(self):

        self.scheduler = self.merge.scheduler
        pkg = self.merge.pkg
        pkg_count = self.merge.pkg_count

        if pkg.installed:
            action_desc = "Uninstalling"
            preposition = "from"
            counter_str = ""
        else:
            action_desc = "Installing"
            preposition = "to"
            counter_str = "(%s of %s) " % \
             (colorize("MERGE_LIST_PROGRESS", str(pkg_count.curval)),
             colorize("MERGE_LIST_PROGRESS", str(pkg_count.maxval)))

        msg = "%s %s%s" % \
         (action_desc,
         counter_str,
         colorize("GOOD", pkg.cpv))

        if pkg.root_config.settings["ROOT"] != "/":
            msg += " %s %s" % (preposition, pkg.root)

        if not self.merge.build_opts.fetchonly and \
         not self.merge.build_opts.pretend and \
         not self.merge.build_opts.buildpkgonly:
            self.merge.statusMessage(msg)

        task = self.merge.create_install_task()
        self._start_task(task, self._default_final_exit)
Пример #27
0
 def display(self):
     self.out.write(
         "\r"
         + colorize("WARN", _("cache miss: '") + str(self.misses) + "'")
         + " --- "
         + colorize("GOOD", _("cache hit: '") + str(self.hits) + "'")
     )
     self.out.flush()
Пример #28
0
def make_http_request(conn, address, _params={}, headers={}, dest=None):
    """Uses the |conn| object to request
    the data from address, performing Location forwarding and using the
    optional params and headers."""

    warnings.warn(
        "portage.getbinpkg.make_http_request() is deprecated",
        DeprecationWarning,
        stacklevel=2,
    )

    rc = 0
    response = None
    while (rc == 0) or (rc == 301) or (rc == 302):
        try:
            if rc != 0:
                conn = create_conn(address)[0]
            conn.request("GET", address, body=None, headers=headers)
        except SystemExit as e:
            raise
        except Exception as e:
            return None, None, "Server request failed: %s" % str(e)
        response = conn.getresponse()
        rc = response.status

        # 301 means that the page address is wrong.
        if (rc == 301) or (rc == 302):
            ignored_data = response.read()
            del ignored_data
            for x in str(response.msg).split("\n"):
                parts = x.split(": ", 1)
                if parts[0] == "Location":
                    if rc == 301:
                        sys.stderr.write(
                            colorize("BAD", _("Location has moved: ")) +
                            str(parts[1]) + "\n")
                    if rc == 302:
                        sys.stderr.write(
                            colorize("BAD",
                                     _("Location has temporarily moved: ")) +
                            str(parts[1]) + "\n")
                    address = parts[1]
                    break

    if (rc != 200) and (rc != 206):
        return (
            None,
            rc,
            "Server did not respond successfully (%s: %s)" %
            (str(response.status), str(response.reason)),
        )

    if dest:
        dest.write(response.read())
        return "", 0, ""

    return response.read(), 0, ""
Пример #29
0
 def display(self):
     self.out.write(
         "".join(
             (
                 "\r",
                 colorize("WARN", _(f"cache miss: '{self.misses}'")),
                 " --- ",
                 colorize("GOOD", _(f"cache hit: '{self.hits}'")),
             )
         )
     )
     self.out.flush()
Пример #30
0
		def print_change(change, indent=""):
			mymsg = ""
			for pkg in change:
				changes = []
				for flag, state in change[pkg].items():
					if state:
						changes.append(colorize("red", "+" + flag))
					else:
						changes.append(colorize("blue", "-" + flag))
				mymsg += indent + "- " + pkg.cpv + " (Change USE: %s" % " ".join(changes) + ")\n"
			mymsg += "\n"
			return mymsg
Пример #31
0
		def print_solution(solution, indent=""):
			mymsg = ""
			for pkg in solution:
				changes = []
				for flag, state in solution[pkg].items():
					if state == "enabled" and flag not in _pkg_use_enabled(pkg):
						changes.append(colorize("red", "+" + flag))
					elif state == "disabled" and flag in _pkg_use_enabled(pkg):
						changes.append(colorize("blue", "-" + flag))
				if changes:
					mymsg += indent + "- " + pkg.cpv + " (Change USE: %s" % " ".join(changes) + ")\n"
			mymsg += "\n"
			return mymsg
Пример #32
0
 def print_solution(solution, indent=""):
     mymsg = ""
     for pkg in solution:
         changes = []
         for flag, state in solution[pkg].items():
             if state == "enabled" and flag not in _pkg_use_enabled(
                     pkg):
                 changes.append(colorize("red", "+" + flag))
             elif state == "disabled" and flag in _pkg_use_enabled(pkg):
                 changes.append(colorize("blue", "-" + flag))
         if changes:
             mymsg += indent + "- " + pkg.cpv + " (Change USE: %s" % " ".join(
                 changes) + ")\n"
     mymsg += "\n"
     return mymsg
Пример #33
0
 def __str__(self):
     total_installs = self.upgrades + self.downgrades + self.newslot + self.new + self.reinst
     myoutput = []
     details = []
     myoutput.append("Total: %s package" % total_installs)
     if total_installs != 1:
         myoutput.append("s")
     if total_installs != 0:
         myoutput.append(" (")
     if self.upgrades > 0:
         details.append("%s upgrade" % self.upgrades)
         if self.upgrades > 1:
             details[-1] += "s"
     if self.downgrades > 0:
         details.append("%s downgrade" % self.downgrades)
         if self.downgrades > 1:
             details[-1] += "s"
     if self.new > 0:
         details.append("%s new" % self.new)
     if self.newslot > 0:
         details.append("%s in new slot" % self.newslot)
         if self.newslot > 1:
             details[-1] += "s"
     if self.reinst > 0:
         details.append("%s reinstall" % self.reinst)
         if self.reinst > 1:
             details[-1] += "s"
     if self.binary > 0:
         details.append("%s binary" % self.binary)
         if self.binary > 1:
             details[-1] = details[-1][:-1] + "ies"
     if self.uninst > 0:
         details.append("%s uninstall" % self.uninst)
         if self.uninst > 1:
             details[-1] += "s"
     if self.interactive > 0:
         details.append("%s %s" %
                        (self.interactive, colorize("WARN", "interactive")))
     myoutput.append(", ".join(details))
     if total_installs != 0:
         myoutput.append(")")
     myoutput.append(", Size of downloads: %s" %
                     _format_size(self.totalsize))
     if self.restrict_fetch:
         myoutput.append("\nFetch Restriction: %s package" % \
          self.restrict_fetch)
         if self.restrict_fetch > 1:
             myoutput.append("s")
     if self.restrict_fetch_satisfied < self.restrict_fetch:
         myoutput.append(bad(" (%s unsatisfied)") % \
          (self.restrict_fetch - self.restrict_fetch_satisfied))
     if self.blocks > 0:
         myoutput.append("\nConflict: %s block" % \
          self.blocks)
         if self.blocks > 1:
             myoutput.append("s")
         if self.blocks_satisfied < self.blocks:
             myoutput.append(bad(" (%s unsatisfied)") % \
              (self.blocks - self.blocks_satisfied))
     return "".join(myoutput)
Пример #34
0
	def _start(self):

		pkg = self.pkg
		settings = self.settings

		if not self.opts.fetchonly:
			rval = _check_temp_dir(settings)
			if rval != os.EX_OK:
				self.returncode = rval
				self._current_task = None
				self._async_wait()
				return

		root_config = pkg.root_config
		tree = "porttree"
		self._tree = tree
		portdb = root_config.trees[tree].dbapi
		settings.setcpv(pkg)
		settings.configdict["pkg"]["EMERGE_FROM"] = "ebuild"
		if self.opts.buildpkgonly:
			settings.configdict["pkg"]["MERGE_TYPE"] = "buildonly"
		else:
			settings.configdict["pkg"]["MERGE_TYPE"] = "source"
		ebuild_path = portdb.findname(pkg.cpv, myrepo=pkg.repo)
		if ebuild_path is None:
			raise AssertionError("ebuild not found for '%s'" % pkg.cpv)
		self._ebuild_path = ebuild_path
		portage.doebuild_environment(ebuild_path, 'setup',
			settings=self.settings, db=portdb)

		# Check the manifest here since with --keep-going mode it's
		# currently possible to get this far with a broken manifest.
		if not self._check_manifest():
			self.returncode = 1
			self._current_task = None
			self._async_wait()
			return

		prefetcher = self.prefetcher
		if prefetcher is None:
			pass
		elif prefetcher.isAlive() and \
			prefetcher.poll() is None:

			waiting_msg = "Fetching files " + \
				"in the background. " + \
				"To view fetch progress, run `tail -f %s` in another terminal." \
				% (_emerge.emergelog._emerge_log_dir)
			msg_prefix = colorize("GOOD", " * ")
			from textwrap import wrap
			waiting_msg = "".join("%s%s\n" % (msg_prefix, line) \
				for line in wrap(waiting_msg, 65))
			if not self.background:
				writemsg(waiting_msg, noiselevel=-1)

			self._current_task = prefetcher
			prefetcher.addExitListener(self._prefetch_exit)
			return

		self._prefetch_exit(prefetcher)
Пример #35
0
    def _validate(self):
        """
        Implements unknown-features-warn and unknown-features-filter.
        """
        if "unknown-features-warn" in self._features:
            unknown_features = self._features.difference(SUPPORTED_FEATURES)
            if unknown_features:
                unknown_features = unknown_features.difference(
                    self._settings._unknown_features)
                if unknown_features:
                    self._settings._unknown_features.update(unknown_features)
                    writemsg_level(
                        colorize(
                            "BAD",
                            _("FEATURES variable contains unknown value(s): %s"
                              ) % ", ".join(sorted(unknown_features)),
                        ) + "\n",
                        level=logging.WARNING,
                        noiselevel=-1,
                    )

        if "unknown-features-filter" in self._features:
            unknown_features = self._features.difference(SUPPORTED_FEATURES)
            if unknown_features:
                self.difference_update(unknown_features)
                self._prune_overrides()
Пример #36
0
def make_http_request(conn, address, params={}, headers={}, dest=None):
	"""(conn,address,params,headers) --- uses the conn object to request
	the data from address, performing Location forwarding and using the
	optional params and headers."""

	warnings.warn("portage.getbinpkg.make_http_request() is deprecated",
		DeprecationWarning, stacklevel=2)

	rc = 0
	response = None
	while (rc == 0) or (rc == 301) or (rc == 302):
		try:
			if (rc != 0):
				conn,ignore,ignore,ignore,ignore = create_conn(address)
			conn.request("GET", address, body=None, headers=headers)
		except SystemExit as e:
			raise
		except Exception as e:
			return None,None,"Server request failed: "+str(e)
		response = conn.getresponse()
		rc = response.status

		# 301 means that the page address is wrong.
		if ((rc == 301) or (rc == 302)):
			ignored_data = response.read()
			del ignored_data
			for x in str(response.msg).split("\n"):
				parts = x.split(": ",1)
				if parts[0] == "Location":
					if (rc == 301):
						sys.stderr.write(colorize("BAD",
							_("Location has moved: ")) + str(parts[1]) + "\n")
					if (rc == 302):
						sys.stderr.write(colorize("BAD",
							_("Location has temporarily moved: ")) + \
							str(parts[1]) + "\n")
					address = parts[1]
					break
	
	if (rc != 200) and (rc != 206):
		return None,rc,"Server did not respond successfully ("+str(response.status)+": "+str(response.reason)+")"

	if dest:
		dest.write(response.read())
		return "",0,""

	return response.read(),0,""
	def __str__(self):
		total_installs = self.upgrades + self.downgrades + self.newslot + self.new + self.reinst
		myoutput = []
		details = []
		myoutput.append("Total: %s package" % total_installs)
		if total_installs != 1:
			myoutput.append("s")
		if total_installs != 0:
			myoutput.append(" (")
		if self.upgrades > 0:
			details.append("%s upgrade" % self.upgrades)
			if self.upgrades > 1:
				details[-1] += "s"
		if self.downgrades > 0:
			details.append("%s downgrade" % self.downgrades)
			if self.downgrades > 1:
				details[-1] += "s"
		if self.new > 0:
			details.append("%s new" % self.new)
		if self.newslot > 0:
			details.append("%s in new slot" % self.newslot)
			if self.newslot > 1:
				details[-1] += "s"
		if self.reinst > 0:
			details.append("%s reinstall" % self.reinst)
			if self.reinst > 1:
				details[-1] += "s"
		if self.binary > 0:
			details.append("%s binary" % self.binary)
			if self.binary > 1:
				details[-1] = details[-1][:-1] + "ies"
		if self.uninst > 0:
			details.append("%s uninstall" % self.uninst)
			if self.uninst > 1:
				details[-1] += "s"
		if self.interactive > 0:
			details.append("%s %s" % (self.interactive,
				colorize("WARN", "interactive")))
		myoutput.append(", ".join(details))
		if total_installs != 0:
			myoutput.append(")")
		myoutput.append(", Size of downloads: %s" % format_size(self.totalsize))
		if self.restrict_fetch:
			myoutput.append("\nFetch Restriction: %s package" % \
				self.restrict_fetch)
			if self.restrict_fetch > 1:
				myoutput.append("s")
		if self.restrict_fetch_satisfied < self.restrict_fetch:
			myoutput.append(bad(" (%s unsatisfied)") % \
				(self.restrict_fetch - self.restrict_fetch_satisfied))
		if self.blocks > 0:
			myoutput.append("\nConflict: %s block" % \
				self.blocks)
			if self.blocks > 1:
				myoutput.append("s")
			if self.blocks_satisfied < self.blocks:
				myoutput.append(bad(" (%s unsatisfied)") % \
					(self.blocks - self.blocks_satisfied))
		return "".join(myoutput)
Пример #38
0
def _p_good(name: str) -> str:
    """
    Prints good output consistently.

    :param name: Name to print
    :return: string of colourised name
    """
    return colorize(good_colour, name)
Пример #39
0
def _p_error(addr: str) -> str:
    """
    Prints an error text consistently.

    :param addr: Address to print
    :return: colourised address
    """
    return colorize(error_colour, addr)
Пример #40
0
def _p_pkg(pkg: str) -> str:
    """
    Prints a package name consistently.

    :param pkg: Package name to print
    :return: colourised package name
    """
    return colorize(cpv_colour, pkg)
Пример #41
0
def _p_file(field: str) -> str:
    """
    Prints a file name consistently.

    :param field: Field label to print
    :return: colourised string
    """
    return colorize(file_colour, field)
Пример #42
0
	def chk_updated_cfg_files(self, eroot, config_protect):
		target_root = eroot
		result = list(portage.util.find_updated_config_files(target_root, config_protect))

		print("DEBUG: scanning /etc for config files....")

		for x in result:
			print("\n"+colorize("WARN", " * IMPORTANT:"), end=' ')
			if not x[1]: # it's a protected file
				print("config file '%s' needs updating." % x[0])
			else: # it's a protected dir
				print("%d config files in '%s' need updating." % (len(x[1]), x[0]))
	
		if result:
			print(" "+yellow("*")+" See the "+colorize("INFORM","CONFIGURATION FILES")\
					+ " section of the " + bold("emerge"))
			print(" "+yellow("*")+" man page to learn how to update config files.")
Пример #43
0
def make_http_request(conn, address, params={}, headers={}, dest=None):
    """(conn,address,params,headers) --- uses the conn object to request
	the data from address, performing Location forwarding and using the
	optional params and headers."""

    rc = 0
    response = None
    while (rc == 0) or (rc == 301) or (rc == 302):
        try:
            if (rc != 0):
                conn, ignore, ignore, ignore, ignore = create_conn(address)
            conn.request("GET", address, params, headers)
        except SystemExit as e:
            raise
        except Exception as e:
            return None, None, "Server request failed: " + str(e)
        response = conn.getresponse()
        rc = response.status

        # 301 means that the page address is wrong.
        if ((rc == 301) or (rc == 302)):
            ignored_data = response.read()
            del ignored_data
            for x in str(response.msg).split("\n"):
                parts = x.split(": ", 1)
                if parts[0] == "Location":
                    if (rc == 301):
                        sys.stderr.write(
                            colorize("BAD", _("Location has moved: ")) +
                            str(parts[1]) + "\n")
                    if (rc == 302):
                        sys.stderr.write(colorize("BAD",
                         _("Location has temporarily moved: ")) + \
                         str(parts[1]) + "\n")
                    address = parts[1]
                    break

    if (rc != 200) and (rc != 206):
        return None, rc, "Server did not respond successfully (" + str(
            response.status) + ": " + str(response.reason) + ")"

    if dest:
        dest.write(response.read())
        return "", 0, ""

    return response.read(), 0, ""
Пример #44
0
def _p_warn(txt: str) -> str:
    """
    Prints warning text consistently.

    :param txt: Text to print (addr or "Maintainer Needed" etc)
    :return: colourised text
    """
    return colorize(warn_colour, txt)
Пример #45
0
def _p_name(name: str) -> str:
    """
    Prints a name consistently.

    :param name: Name to print
    :return: string of colourised name
    """
    return colorize(name_colour, name)
Пример #46
0
def _p_addr(addr: str) -> str:
    """
    Prints an email address consistently.

    :param addr: Address to print
    :return: colourised address
    """
    return colorize(address_colour, addr)
Пример #47
0
def _p_mn(txt: str) -> str:
    """
    Prints maintainer-needed text consistently.

    :param txt: Text to print (addr or "Maintainer Needed" etc)
    :return: colourised text
    """
    return colorize(maintainer_needed_colour, txt)
Пример #48
0
def display_news_notifications(news_counts):
	"""
	Display a notification for unread news items, using a dictionary mapping
	repos to integer counts, like that returned from count_unread_news().
	"""
	newsReaderDisplay = False
	for repo, count in news_counts.items():
		if count > 0:
			if not newsReaderDisplay:
				newsReaderDisplay = True
				print()
			print(colorize("WARN", " * IMPORTANT:"), end=' ')
			print("%s news items need reading for repository '%s'." % (count, repo))

	if newsReaderDisplay:
		print(colorize("WARN", " *"), end=' ')
		print("Use " + colorize("GOOD", "eselect news") + " to read news items.")
		print()
Пример #49
0
def display_news_notifications(news_counts):
	"""
	Display a notification for unread news items, using a dictionary mapping
	repos to integer counts, like that returned from count_unread_news().
	"""
	newsReaderDisplay = False
	for repo, count in news_counts.items():
		if count > 0:
			if not newsReaderDisplay:
				newsReaderDisplay = True
				print()
			print(colorize("WARN", " * IMPORTANT:"), end=' ')
			print("%s news items need reading for repository '%s'." % (count, repo))

	if newsReaderDisplay:
		print(colorize("WARN", " *"), end=' ')
		print("Use " + colorize("GOOD", "eselect news read") + " to view new items.")
		print()
Пример #50
0
def colorize_string(color, string):
    """Add coloring for specified string. Due to rotation we need to do that per character rather than per-line"""
    tmp = []
    for char in list(string):
        # % is whitespace separator so we wont color that :)
        if char != "%":
            tmp.append(colorize(color, char))
        else:
            tmp.append(char)
    return "".join(tmp)
Пример #51
0
def colorize_string(color, string):
	"""Add coloring for specified string. Due to rotation we need to do that per character rather than per-line"""
	tmp = []
	for char in list(string):
		# % is whitespace separator so we wont color that :)
		if char != '%':
			tmp.append(colorize(color, char))
		else:
			tmp.append(char)
	return ''.join(tmp)
Пример #52
0
def display_news_notifications(news_counts):
    """
    Display a notification for unread news items, using a dictionary mapping
    repos to integer counts, like that returned from count_unread_news().
    """
    newsReaderDisplay = False
    for repo, count in news_counts.items():
        if count > 0:
            if not newsReaderDisplay:
                newsReaderDisplay = True
                print()
            print(colorize("WARN", " * IMPORTANT:"), end=" ")
            print(f"{count} news items need reading for repository '{repo}'.")

    if newsReaderDisplay:
        print(colorize("WARN", " *"), end=" ")
        print(
            f"Use {colorize('GOOD', 'eselect news read')} to view new items.\n"
        )
Пример #53
0
	def _start(self):

		pkg = self.pkg
		settings = self.settings
		settings.setcpv(pkg)
		self._tree = "bintree"
		self._bintree = self.pkg.root_config.trees[self._tree]
		self._verify = not self.opts.pretend

		dir_path = os.path.join(settings["PORTAGE_TMPDIR"],
			"portage", pkg.category, pkg.pf)
		self._build_dir = EbuildBuildDir(dir_path=dir_path,
			pkg=pkg, settings=settings)
		self._image_dir = os.path.join(dir_path, "image")
		self._infloc = os.path.join(dir_path, "build-info")
		self._ebuild_path = os.path.join(self._infloc, pkg.pf + ".ebuild")
		settings["EBUILD"] = self._ebuild_path
		debug = settings.get("PORTAGE_DEBUG") == "1"
		portage.doebuild_environment(self._ebuild_path, "setup",
			settings["ROOT"], settings, debug, 1, self._bintree.dbapi)
		settings.configdict["pkg"]["EMERGE_FROM"] = pkg.type_name

		# The prefetcher has already completed or it
		# could be running now. If it's running now,
		# wait for it to complete since it holds
		# a lock on the file being fetched. The
		# portage.locks functions are only designed
		# to work between separate processes. Since
		# the lock is held by the current process,
		# use the scheduler and fetcher methods to
		# synchronize with the fetcher.
		prefetcher = self.prefetcher
		if prefetcher is None:
			pass
		elif not prefetcher.isAlive():
			prefetcher.cancel()
		elif prefetcher.poll() is None:

			waiting_msg = ("Fetching '%s' " + \
				"in the background. " + \
				"To view fetch progress, run `tail -f " + \
				"/var/log/emerge-fetch.log` in another " + \
				"terminal.") % prefetcher.pkg_path
			msg_prefix = colorize("GOOD", " * ")
			from textwrap import wrap
			waiting_msg = "".join("%s%s\n" % (msg_prefix, line) \
				for line in wrap(waiting_msg, 65))
			if not self.background:
				writemsg(waiting_msg, noiselevel=-1)

			self._current_task = prefetcher
			prefetcher.addExitListener(self._prefetch_exit)
			return

		self._prefetch_exit(prefetcher)
Пример #54
0
    def _start(self):

        pkg = self.pkg
        settings = self.settings

        rval = _check_temp_dir(settings)
        if rval != os.EX_OK:
            self.returncode = rval
            self._current_task = None
            self.wait()
            return

        root_config = pkg.root_config
        tree = "porttree"
        self._tree = tree
        portdb = root_config.trees[tree].dbapi
        settings.setcpv(pkg)
        settings.configdict["pkg"]["EMERGE_FROM"] = pkg.type_name
        ebuild_path = portdb.findname(pkg.cpv)
        if ebuild_path is None:
            raise AssertionError("ebuild not found for '%s'" % pkg.cpv)
        self._ebuild_path = ebuild_path

        # Check the manifest here since with --keep-going mode it's
        # currently possible to get this far with a broken manifest.
        if not self._check_manifest():
            self.returncode = 1
            self._current_task = None
            self.wait()
            return

        prefetcher = self.prefetcher
        if prefetcher is None:
            pass
        elif not prefetcher.isAlive():
            prefetcher.cancel()
        elif prefetcher.poll() is None:

            waiting_msg = "Fetching files " + \
             "in the background. " + \
             "To view fetch progress, run `tail -f " + \
             "/var/log/emerge-fetch.log` in another " + \
             "terminal."
            msg_prefix = colorize("GOOD", " * ")
            from textwrap import wrap
            waiting_msg = "".join("%s%s\n" % (msg_prefix, line) \
             for line in wrap(waiting_msg, 65))
            if not self.background:
                writemsg(waiting_msg, noiselevel=-1)

            self._current_task = prefetcher
            prefetcher.addExitListener(self._prefetch_exit)
            return

        self._prefetch_exit(prefetcher)
Пример #55
0
	def _start(self):

		pkg = self.pkg
		settings = self.settings

		rval = _check_temp_dir(settings)
		if rval != os.EX_OK:
			self.returncode = rval
			self._current_task = None
			self.wait()
			return

		root_config = pkg.root_config
		tree = "porttree"
		self._tree = tree
		portdb = root_config.trees[tree].dbapi
		settings.setcpv(pkg)
		settings.configdict["pkg"]["EMERGE_FROM"] = pkg.type_name
		ebuild_path = portdb.findname(pkg.cpv)
		if ebuild_path is None:
			raise AssertionError("ebuild not found for '%s'" % pkg.cpv)
		self._ebuild_path = ebuild_path

		# Check the manifest here since with --keep-going mode it's
		# currently possible to get this far with a broken manifest.
		if not self._check_manifest():
			self.returncode = 1
			self._current_task = None
			self.wait()
			return

		prefetcher = self.prefetcher
		if prefetcher is None:
			pass
		elif not prefetcher.isAlive():
			prefetcher.cancel()
		elif prefetcher.poll() is None:

			waiting_msg = "Fetching files " + \
				"in the background. " + \
				"To view fetch progress, run `tail -f " + \
				"/var/log/emerge-fetch.log` in another " + \
				"terminal."
			msg_prefix = colorize("GOOD", " * ")
			from textwrap import wrap
			waiting_msg = "".join("%s%s\n" % (msg_prefix, line) \
				for line in wrap(waiting_msg, 65))
			if not self.background:
				writemsg(waiting_msg, noiselevel=-1)

			self._current_task = prefetcher
			prefetcher.addExitListener(self._prefetch_exit)
			return

		self._prefetch_exit(prefetcher)
Пример #56
0
	def _start(self):

		pkg = self.pkg
		settings = self.settings
		settings.setcpv(pkg)
		self._tree = "bintree"
		self._bintree = self.pkg.root_config.trees[self._tree]
		self._verify = not self.opts.pretend

		dir_path = os.path.join(settings["PORTAGE_TMPDIR"],
			"portage", pkg.category, pkg.pf)
		self._build_dir = EbuildBuildDir(dir_path=dir_path,
			pkg=pkg, settings=settings)
		self._image_dir = os.path.join(dir_path, "image")
		self._infloc = os.path.join(dir_path, "build-info")
		self._ebuild_path = os.path.join(self._infloc, pkg.pf + ".ebuild")
		settings["EBUILD"] = self._ebuild_path
		debug = settings.get("PORTAGE_DEBUG") == "1"
		portage.doebuild_environment(self._ebuild_path, "setup",
			settings["ROOT"], settings, debug, 1, self._bintree.dbapi)
		settings.configdict["pkg"]["EMERGE_FROM"] = pkg.type_name

		# The prefetcher has already completed or it
		# could be running now. If it's running now,
		# wait for it to complete since it holds
		# a lock on the file being fetched. The
		# portage.locks functions are only designed
		# to work between separate processes. Since
		# the lock is held by the current process,
		# use the scheduler and fetcher methods to
		# synchronize with the fetcher.
		prefetcher = self.prefetcher
		if prefetcher is None:
			pass
		elif not prefetcher.isAlive():
			prefetcher.cancel()
		elif prefetcher.poll() is None:

			waiting_msg = ("Fetching '%s' " + \
				"in the background. " + \
				"To view fetch progress, run `tail -f " + \
				"/var/log/emerge-fetch.log` in another " + \
				"terminal.") % prefetcher.pkg_path
			msg_prefix = colorize("GOOD", " * ")
			from textwrap import wrap
			waiting_msg = "".join("%s%s\n" % (msg_prefix, line) \
				for line in wrap(waiting_msg, 65))
			if not self.background:
				writemsg(waiting_msg, noiselevel=-1)

			self._current_task = prefetcher
			prefetcher.addExitListener(self._prefetch_exit)
			return

		self._prefetch_exit(prefetcher)
Пример #57
0
def countdown(secs=5, doing='Starting'):
    if secs:
        print('>>> Waiting %s seconds before starting...\n'
              '>>> (Control-C to abort)...\n'
              '%s in:' % (secs, doing),
              end='')
        for sec in range(secs, 0, -1):
            sys.stdout.write(colorize('UNMERGE_WARN', ' %i' % sec))
            sys.stdout.flush()
            time.sleep(1)
        print()