Split out an apply_priorities() function to apply nice and ionice settings.
authorZac Medico <zmedico@gentoo.org>
Sat, 26 Jul 2008 09:33:28 +0000 (09:33 -0000)
committerZac Medico <zmedico@gentoo.org>
Sat, 26 Jul 2008 09:33:28 +0000 (09:33 -0000)
svn path=/main/trunk/; revision=11198

pym/_emerge/__init__.py

index d6bb0d382bc6715a0674a65a8d68f07e5f86d1dc..cc7191ba404f15c25f7569bcc24fb9ea82b1baea 100644 (file)
@@ -12893,6 +12893,19 @@ def adjust_config(myopts, settings):
                settings["NOCOLOR"] = "true"
                settings.backup_changes("NOCOLOR")
 
+def apply_priorities(settings):
+       ionice(settings)
+       nice(settings)
+
+def nice(settings):
+       try:
+               os.nice(int(settings.get("PORTAGE_NICENESS", "0")))
+       except (OSError, ValueError), e:
+               out = portage.output.EOutput()
+               out.eerror("Failed to change nice value to '%s'" % \
+                       settings["PORTAGE_NICENESS"])
+               out.eerror("%s\n" % str(e))
+
 def ionice(settings):
 
        ionice_cmd = settings.get("PORTAGE_IONICE_COMMAND")
@@ -12953,16 +12966,6 @@ def emerge_main():
        settings, trees, mtimedb = load_emerge_config()
        portdb = trees[settings["ROOT"]]["porttree"].dbapi
 
-       ionice(settings)
-
-       try:
-               os.nice(int(settings.get("PORTAGE_NICENESS", "0")))
-       except (OSError, ValueError), e:
-               portage.writemsg("!!! Failed to change nice value to '%s'\n" % \
-                       settings["PORTAGE_NICENESS"])
-               portage.writemsg("!!! %s\n" % str(e))
-               del e
-
        if portage._global_updates(trees, mtimedb["updates"]):
                mtimedb.commit()
                # Reload the whole config from scratch.
@@ -12991,6 +12994,8 @@ def emerge_main():
                mysettings.lock()
                del myroot, mysettings
 
+       apply_priorities(settings)
+
        spinner = stdout_spinner()
        if "candy" in settings.features:
                spinner.update = spinner.update_scroll