From d5dd5a61b86ad1da92fd39e10edc1bbf1223461b Mon Sep 17 00:00:00 2001 From: Sebastien Luttringer Date: Thu, 1 Mar 2012 15:12:24 +0100 Subject: [PATCH] allow ionice level to be setted --- bin/is | 12 +++++++----- installsystems/config.py | 3 ++- samples/installsystems.conf | 9 ++++++--- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/bin/is b/bin/is index 84019a1..9f9cb77 100755 --- a/bin/is +++ b/bin/is @@ -429,8 +429,10 @@ def arg_parser_init(): help="dot not display colored output") parser.add_argument("--nice", type=int, default=0, help="nice of the process") - parser.add_argument("--ionice", choices=["none","rt", "be","idle"], + parser.add_argument("--ionice-class", choices=["none","rt", "be","idle"], help="ionice class of the process (default: none)") + parser.add_argument("--ionice-level", type=int, default=None, + help="ionice class level of the process") # create a subparser for commands subparser = parser.add_subparsers() # add command parser @@ -667,22 +669,22 @@ def main(): if installsystems.verbosity < 2: warnings.filterwarnings("ignore") # nice and ionice process - if options.nice is not None or options.ionice is not None: + if options.nice is not None or options.ionice_class is not None: proc = psutil.Process(os.getpid()) if options.nice is not None: try: proc.nice = options.nice except Exception: warn("Unable to nice process to %s" % options.nice) - if options.ionice is not None: + if options.ionice_class is not None: try: ioclassmap = { "none": psutil.IOPRIO_CLASS_NONE, "rt": psutil.IOPRIO_CLASS_RT, "be": psutil.IOPRIO_CLASS_BE, "idle": psutil.IOPRIO_CLASS_IDLE} - proc.set_ionice(ioclassmap[options.ionice]) + proc.set_ionice(ioclassmap[options.ionice_class], options.ionice_level) except Exception: - warn("Unable to ionice process to %s" % options.ionice) + warn("Unable to ionice process to %s" % options.ionice_class) # except for install command we parse all args! # install command is responsible of parsing if options.func is not c_install: diff --git a/installsystems/config.py b/installsystems/config.py index 971576b..0babb4c 100644 --- a/installsystems/config.py +++ b/installsystems/config.py @@ -62,7 +62,8 @@ class MainConfigFile(ConfigFile): "repo_filter": str, "repo_config": str, "nice": int, - "ionice": ["none", "rt", "be", "idle"] + "ionice_class": ["none", "rt", "be", "idle"], + "ionice_level": int } def __init__(self, filename, prefix=os.path.basename(sys.argv[0])): self.prefix = prefix diff --git a/samples/installsystems.conf b/samples/installsystems.conf index 8e8cd90..f2cd34d 100644 --- a/samples/installsystems.conf +++ b/samples/installsystems.conf @@ -5,11 +5,14 @@ # Set verbosity (0: quiet, 1: normal, 2: debug) #verbosity = 2 -# Set nice process value +# Set nice process value (see nice (1)) #nice = 0 -# Set ionice class -#ionice = idle +# Set ionice class (see ionice (1)) +#ionice_class = idle + +# Set ionice class data level (see ionice (1)) +#ionice_level = 0 # define a custom cache directory #cache = /tmp/sex -- GitLab