Lines 6617-6622
Link Here
|
6617 |
settings["NOCOLOR"] = "true" |
6617 |
settings["NOCOLOR"] = "true" |
6618 |
settings.backup_changes("NOCOLOR") |
6618 |
settings.backup_changes("NOCOLOR") |
6619 |
|
6619 |
|
|
|
6620 |
def ionice(io_class, io_prio, pid = -1): |
6621 |
"""Execute the program ionice to adapt io performance""" |
6622 |
|
6623 |
# Only the root user can use ionice |
6624 |
if os.getuid() != 0: |
6625 |
return False # Failed not root |
6626 |
|
6627 |
# Determine the process id to change |
6628 |
if pid == -1: |
6629 |
npid = os.getpid() |
6630 |
else: |
6631 |
npid = pid |
6632 |
|
6633 |
# Search ionice executable in PATH |
6634 |
ionice_bin = None |
6635 |
for path in os.environ["PATH"].split(":"): |
6636 |
file = os.path.join(path, "ionice") |
6637 |
if os.path.exists(file): |
6638 |
ionice_bin = file |
6639 |
break |
6640 |
if ionice_bin is None: |
6641 |
return False # Failed binary not installed |
6642 |
|
6643 |
# Execute the ionice program |
6644 |
rv = os.system("%s -c%d -n%d -p%d >/dev/null 2>&1" % \ |
6645 |
(ionice_bin, io_class, io_prio, npid)) |
6646 |
return rv == 0 |
6647 |
|
6620 |
def emerge_main(): |
6648 |
def emerge_main(): |
6621 |
# Disable color until we're sure that it should be enabled (after |
6649 |
# Disable color until we're sure that it should be enabled (after |
6622 |
# EMERGE_DEFAULT_OPTS has been parsed). |
6650 |
# EMERGE_DEFAULT_OPTS has been parsed). |
Lines 6636-6641
Link Here
|
6636 |
settings, trees, mtimedb = load_emerge_config() |
6664 |
settings, trees, mtimedb = load_emerge_config() |
6637 |
portdb = trees[settings["ROOT"]]["porttree"].dbapi |
6665 |
portdb = trees[settings["ROOT"]]["porttree"].dbapi |
6638 |
|
6666 |
|
|
|
6667 |
# Use ionice to amend the performance or responsivness of the system |
6668 |
io_class_dict = {"realtime":1, "besteffort":2, "idle":3, "1":1, "2":2, "3":3, "none":-1} |
6669 |
try: |
6670 |
io_class = io_class_dict[settings.get("PORTAGE_IONICE_CLASS", "none")] |
6671 |
io_prio = int(settings.get("PORTAGE_IONICE_PRIO", "4")) |
6672 |
if io_prio < 0: raise ValueError |
6673 |
if io_prio > 7: raise ValueError |
6674 |
except (KeyError, ValueError), e: |
6675 |
portage.writemsg("!!! Invalid value in PORTAGE_IONICE_CLASS or PORTAGE_IONICE_PRIO\n") |
6676 |
portage.writemsg("!!! PORTAGE_IONICE_CLASS=<realtime|besteffort|idle>\n") |
6677 |
portage.writemsg("!!! PORTAGE_IONICE_PRIO=<0..7>\n") |
6678 |
io_class = -1 |
6679 |
io_prio = -1 |
6680 |
del e |
6681 |
if io_class != -1 and io_prio != -1: |
6682 |
ionice(io_class, io_prio) |
6683 |
|
6639 |
try: |
6684 |
try: |
6640 |
os.nice(int(settings.get("PORTAGE_NICENESS", "0"))) |
6685 |
os.nice(int(settings.get("PORTAGE_NICENESS", "0"))) |
6641 |
except (OSError, ValueError), e: |
6686 |
except (OSError, ValueError), e: |