Example #1
0
    def query(self, prompt, enter_invalid, responses=None, colours=None):
        """Display a prompt and a set of responses, then waits for user input
        and check it against the responses. The first match is returned.

        An empty response will match the first value in the list of responses,
        unless enter_invalid is True. The input buffer is *not* cleared prior
        to the prompt!

        prompt: The String to display as a prompt.
        responses: a List of Strings with the acceptable responses.
        colours: a List of Functions taking and returning a String, used to
        process the responses for display. Typically these will be functions
        like red() but could be e.g. lambda x: "DisplayString".

        If responses is omitted, it defaults to ["Yes", "No"], [green, red].
        If only colours is omitted, it defaults to [bold, ...].

        Returns a member of the List responses. (If called without optional
        arguments, it returns "Yes" or "No".)

        KeyboardInterrupt is converted to SystemExit to avoid tracebacks being
        printed."""
        if responses is None:
            responses = ["Yes", "No"]
            colours = [
                create_color_func("PROMPT_CHOICE_DEFAULT"),
                create_color_func("PROMPT_CHOICE_OTHER"),
            ]
        elif colours is None:
            colours = [bold]
        colours = (colours * len(responses))[: len(responses)]
        responses = [_unicode_decode(x) for x in responses]
        if "--alert" in self.myopts:
            prompt = "\a" + prompt
        print(bold(prompt), end=" ")
        try:
            while True:
                try:
                    response = input(
                        "[%s] "
                        % "/".join(
                            [colours[i](responses[i]) for i in range(len(responses))]
                        )
                    )
                except UnicodeDecodeError as e:
                    response = _unicode_decode(e.object).rstrip("\n")
                if response or not enter_invalid:
                    for key in responses:
                        # An empty response will match the
                        # first value in responses.
                        if response.upper() == key[: len(response)].upper():
                            return key
                print("Sorry, response '%s' not understood." % response, end=" ")
        except (EOFError, KeyboardInterrupt):
            print("Interrupted.")
            sys.exit(128 + signal.SIGINT)
Example #2
0
    def query(self, prompt, enter_invalid, responses=None, colours=None):
        """Display a prompt and a set of responses, then waits for user input
		and check it against the responses. The first match is returned.

		An empty response will match the first value in the list of responses,
		unless enter_invalid is True. The input buffer is *not* cleared prior
		to the prompt!

		prompt: The String to display as a prompt.
		responses: a List of Strings with the acceptable responses.
		colours: a List of Functions taking and returning a String, used to
		process the responses for display. Typically these will be functions
		like red() but could be e.g. lambda x: "DisplayString".

		If responses is omitted, it defaults to ["Yes", "No"], [green, red].
		If only colours is omitted, it defaults to [bold, ...].

		Returns a member of the List responses. (If called without optional
		arguments, it returns "Yes" or "No".)

		KeyboardInterrupt is converted to SystemExit to avoid tracebacks being
		printed."""
        if responses is None:
            responses = ["Yes", "No"]
            colours = [create_color_func("PROMPT_CHOICE_DEFAULT"), create_color_func("PROMPT_CHOICE_OTHER")]
        elif colours is None:
            colours = [bold]
        colours = (colours * len(responses))[: len(responses)]
        responses = [_unicode_decode(x) for x in responses]
        if "--alert" in self.myopts:
            prompt = "\a" + prompt
        print(bold(prompt), end=" ")
        try:
            while True:
                if sys.hexversion >= 0x3000000:
                    try:
                        response = input("[%s] " % "/".join([colours[i](responses[i]) for i in range(len(responses))]))
                    except UnicodeDecodeError as e:
                        response = _unicode_decode(e.object).rstrip("\n")
                else:
                    response = raw_input(
                        "[" + "/".join([colours[i](responses[i]) for i in range(len(responses))]) + "] "
                    )
                    response = _unicode_decode(response)
                if response or not enter_invalid:
                    for key in responses:
                        # An empty response will match the
                        # first value in responses.
                        if response.upper() == key[: len(response)].upper():
                            return key
                print("Sorry, response '%s' not understood." % response, end=" ")
        except (EOFError, KeyboardInterrupt):
            print("Interrupted.")
            sys.exit(128 + signal.SIGINT)
Example #3
0
def userquery(prompt, enter_invalid, responses=None, colours=None):
    """Displays a prompt and a set of responses, then waits for a response
	which is checked against the responses and the first to match is
	returned. An empty response will match the first value in responses,
	unless enter_invalid is True. The input buffer is *not* cleared prior
	to the prompt!

	prompt: a String.
	responses: a List of Strings.
	colours: a List of Functions taking and returning a String, used to
	process the responses for display. Typically these will be functions
	like red() but could be e.g. lambda x: "DisplayString".
	If responses is omitted, defaults to ["Yes", "No"], [green, red].
	If only colours is omitted, defaults to [bold, ...].

	Returns a member of the List responses. (If called without optional
	arguments, returns "Yes" or "No".)
	KeyboardInterrupt is converted to SystemExit to avoid tracebacks being
	printed."""
    if responses is None:
        responses = ["Yes", "No"]
        colours = [
            create_color_func("PROMPT_CHOICE_DEFAULT"),
            create_color_func("PROMPT_CHOICE_OTHER")
        ]
    elif colours is None:
        colours = [bold]
    colours = (colours * len(responses))[:len(responses)]
    print(bold(prompt), end=' ')
    try:
        while True:
            if sys.hexversion >= 0x3000000:
                response = input("[" + "/".join(
                    [colours[i](responses[i])
                     for i in range(len(responses))]) + "] ")
            else:
                response = raw_input("[" + "/".join(
                    [colours[i](responses[i])
                     for i in range(len(responses))]) + "] ")
            if response or not enter_invalid:
                for key in responses:
                    # An empty response will match the
                    # first value in responses.
                    if response.upper() == key[:len(response)].upper():
                        return key
            print("Sorry, response '%s' not understood." % response, end=' ')
    except (EOFError, KeyboardInterrupt):
        print("Interrupted.")
        sys.exit(1)
def userquery(prompt, enter_invalid, responses=None, colours=None):
	"""Displays a prompt and a set of responses, then waits for a response
	which is checked against the responses and the first to match is
	returned. An empty response will match the first value in responses,
	unless enter_invalid is True. The input buffer is *not* cleared prior
	to the prompt!

	prompt: a String.
	responses: a List of Strings.
	colours: a List of Functions taking and returning a String, used to
	process the responses for display. Typically these will be functions
	like red() but could be e.g. lambda x: "DisplayString".
	If responses is omitted, defaults to ["Yes", "No"], [green, red].
	If only colours is omitted, defaults to [bold, ...].

	Returns a member of the List responses. (If called without optional
	arguments, returns "Yes" or "No".)
	KeyboardInterrupt is converted to SystemExit to avoid tracebacks being
	printed."""
	if responses is None:
		responses = ["Yes", "No"]
		colours = [
			create_color_func("PROMPT_CHOICE_DEFAULT"),
			create_color_func("PROMPT_CHOICE_OTHER")
		]
	elif colours is None:
		colours=[bold]
	colours=(colours*len(responses))[:len(responses)]
	print(bold(prompt), end=' ')
	try:
		while True:
			if sys.hexversion >= 0x3000000:
				response=input("["+"/".join([colours[i](responses[i]) for i in range(len(responses))])+"] ")
			else:
				response=raw_input("["+"/".join([colours[i](responses[i]) for i in range(len(responses))])+"] ")
			if response or not enter_invalid:
				for key in responses:
					# An empty response will match the
					# first value in responses.
					if response.upper()==key[:len(response)].upper():
						return key
			print("Sorry, response '%s' not understood." % response, end=' ')
	except (EOFError, KeyboardInterrupt):
		print("Interrupted.")
		sys.exit(1)
Example #5
0
# Copyright 2005-2018 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2

import io
import logging
import subprocess

import portage
from portage import os
from portage.util import writemsg_level, shlex_split
from portage.output import create_color_func, EOutput

good = create_color_func("GOOD")
bad = create_color_func("BAD")
warn = create_color_func("WARN")
from portage.sync.syncbase import NewBase

try:
    from gemato.exceptions import GematoException
    import gemato.openpgp
except ImportError:
    gemato = None


class GitSync(NewBase):
    '''Git sync class'''

    short_desc = "Perform sync operations on git based repositories"

    @staticmethod
    def name():
Example #6
0
from portage import cvstree
from portage import os
from portage import _encodings
from portage import _unicode_encode
from portage.output import (bold, create_color_func, green, red)
from portage.package.ebuild.digestgen import digestgen
from portage.process import find_binary, spawn
from portage.util import writemsg_level

from repoman._subprocess import repoman_popen, repoman_getstatusoutput
from repoman.errors import err
from repoman.gpg import gpgsign, need_signature
from repoman import utilities
from repoman.vcs.vcs import git_supports_gpg_sign, vcs_files_to_cps

bad = create_color_func("BAD")


class Actions(object):
    '''Handles post check result output and performs
	the various vcs activities for committing the results'''
    def __init__(self, repo_settings, options, scanner, vcs_settings):
        self.repo_settings = repo_settings
        self.options = options
        self.scanner = scanner
        self.vcs_settings = vcs_settings
        self.repoman_settings = repo_settings.repoman_settings
        self.suggest = {
            'ignore_masked': False,
            'include_dev': False,
        }
Example #7
0
from portage.util._async.AsyncScheduler import AsyncScheduler
from portage.util._eventloop.global_event_loop import global_event_loop
from portage.util._eventloop.EventLoop import EventLoop

import _emerge
from _emerge.emergelog import emergelog


portage.proxy.lazyimport.lazyimport(globals(),
	'_emerge.actions:adjust_configs,load_emerge_config',
	'_emerge.chk_updated_cfg_files:chk_updated_cfg_files',
	'_emerge.main:parse_opts',
	'_emerge.post_emerge:display_news_notification',
)

warn = create_color_func("WARN")

if sys.hexversion >= 0x3000000:
	_basestring = str
else:
	_basestring = basestring


class SyncRepos(object):

	short_desc = "Check repos.conf settings and/or sync repositories"

	@staticmethod
	def name():
		return "sync"
Example #8
0
	"Display", "format_unmatched_atom",
	)

import sys

import portage
from portage import os
from portage.dbapi.dep_expand import dep_expand
from portage.dep import cpvequal, _repo_separator, _slot_separator
from portage.eapi import _get_eapi_attrs
from portage.exception import InvalidDependString, SignatureException
from portage.package.ebuild.config import _get_feature_flags
from portage.package.ebuild._spawn_nofetch import spawn_nofetch
from portage.output import ( blue, colorize, create_color_func,
	darkblue, darkgreen, green, nc_len, teal)
bad = create_color_func("BAD")
from portage._sets.base import InternalPackageSet
from portage.util import writemsg_stdout
from portage.versions import best, cpv_getversion

from _emerge.Blocker import Blocker
from _emerge.create_world_atom import create_world_atom
from _emerge.resolver.output_helpers import ( _DisplayConfig, _tree_display,
	_PackageCounters, _create_use_string, _format_size, _calc_changelog, PkgInfo)
from _emerge.show_invalid_depstring_notice import show_invalid_depstring_notice

if sys.hexversion >= 0x3000000:
	basestring = str
	_unicode = str
else:
	_unicode = unicode
Example #9
0
import logging

import layman.overlays.overlay as Overlay

from layman.api import LaymanAPI
from layman.config import BareConfig, OptionConfig
from layman.maker import Interactive
from layman.output import Message
from layman.utils import reload_config

import portage
from portage import os
from portage.util import writemsg_level
from portage.output import create_color_func
good = create_color_func("GOOD")
bad = create_color_func("BAD")
warn = create_color_func("WARN")
from portage.sync.syncbase import SyncBase

import sys

def create_overlay_package(config=None, repo=None, logger=None, xterm_titles=None):
    '''
    Creates a layman overlay object
    from the given repos.conf repo info.

    @params config: layman.config class object
    @params repo: portage.repo class object
    @rtype tuple: overlay name and layman.overlay object or None
    '''
Example #10
0
from portage.util.digraph import digraph
from portage.util.futures import asyncio
from portage.util._async.AsyncScheduler import AsyncScheduler

import _emerge
from _emerge.emergelog import emergelog

portage.proxy.lazyimport.lazyimport(
    globals(),
    '_emerge.actions:adjust_configs,load_emerge_config',
    '_emerge.chk_updated_cfg_files:chk_updated_cfg_files',
    '_emerge.main:parse_opts',
    '_emerge.post_emerge:display_news_notification',
)

warn = create_color_func("WARN")


class SyncRepos:

    short_desc = "Check repos.conf settings and/or sync repositories"

    @staticmethod
    def name():
        return "sync"

    def can_progressbar(self, func):
        return False

    def __init__(self, emerge_config=None, emerge_logging=False):
        '''Class init function
Example #11
0
import sys
import textwrap
import platform
try:
	from subprocess import getstatusoutput as subprocess_getstatusoutput
except ImportError:
	from commands import getstatusoutput as subprocess_getstatusoutput
import portage
from portage import os
from portage import _encodings
from portage import _unicode_decode
import _emerge.help
import portage.xpak, errno, re, time
from portage.output import colorize, xtermTitle, xtermTitleReset
from portage.output import create_color_func
good = create_color_func("GOOD")
bad = create_color_func("BAD")

import portage.elog
import portage.dep
portage.dep._dep_check_strict = True
import portage.util
import portage.locks
import portage.exception
from portage.data import secpass
from portage.dbapi.dep_expand import dep_expand
from portage.util import normalize_path as normpath
from portage.util import writemsg, writemsg_level, writemsg_stdout
from portage.sets import SETPREFIX
from portage._global_updates import _global_updates
Example #12
0
# Copyright 2014-2021 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

import logging

from collections import OrderedDict

import portage

from portage import os
from portage.output import create_color_func
from portage.util import writemsg_level, _recursive_file_list
from warnings import warn

bad = create_color_func("BAD")
warn = create_color_func("WARN")


def get_hooks_from_dir(rel_directory, prefix="/"):
    directory = os.path.join(prefix, portage.USER_CONFIG_PATH, rel_directory)

    hooks = OrderedDict()
    for filepath in _recursive_file_list(directory):
        name = filepath.split(directory)[1].lstrip(portage.os.sep)
        if portage.os.access(filepath, portage.os.X_OK):
            hooks[filepath] = name
        else:
            writemsg_level(
                " %s %s hook: '%s' is not executable\n"
                % (
                    warn("*"),