diff --git a/bin/is b/bin/is index f71968af6eaa18a73fc29747d756c2f696836f91..1cf1e3553d5f8ca840eecdf91f34b1d71ed5e5b7 100755 --- a/bin/is +++ b/bin/is @@ -15,6 +15,7 @@ import fnmatch import warnings import argparse import json +import psutil import installsystems import installsystems.printer import installsystems.tools as istools @@ -479,6 +480,10 @@ def arg_parser_init(): help="doesn't sync repository database cache") parser.add_argument("--no-color", action="store_true", 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"], + help="ionice class of the process (default: none)") # create a subparser for commands subparser = parser.add_subparsers() # add command parser @@ -701,6 +706,23 @@ def main(): # no warning if we are not in debug mode if installsystems.verbosity < 2: warnings.filterwarnings("ignore") + # nice and ionice process + if options.nice is not None or options.ionice 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: + 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]) + except Exception: + warn("Unable to ionice process to %s" % options.ionice) # except for install command we parse all args! # install command is responsible of parsing if options.func is not c_install: diff --git a/completion/bash/is b/completion/bash/is index 6b3d27ded3650583c2f9086f968a2ce98d01065d..77143a55edaa8a37f3a506cf5e35b6df6865688c 100644 --- a/completion/bash/is +++ b/completion/bash/is @@ -53,6 +53,8 @@ _is() { '-c' '--config' '-C' '--cache' '-t' '--timeout' + '--nice' + '--ionice' '--no-cache' '--no-color' '--no-sync') @@ -131,7 +133,6 @@ _is() { _local_repo ;; install) - #[[ "$cur" == -* ]] && _opt '-b --best' && return 0 _count_args (( args == 2 )) && _image (( args > 2 )) && _filedir diff --git a/debian/control b/debian/control index 26cb37b659ddadbb5c53dbe8c3bbb209f0c39b50..abd718b5f8eee8fdefe8e3f406c22d7b8e81a0a8 100644 --- a/debian/control +++ b/debian/control @@ -8,7 +8,7 @@ Standards-Version: 3.9.1 Package: installsystems Architecture: all -Depends: ${misc:Depends}, ${python:Depends}, python-installsystems (>= ${source:Version}) +Depends: ${misc:Depends}, ${python:Depends}, python-installsystems (>= ${source:Version}), python-psutil (>= 0.2.1) XB-Python-Version: ${python:Versions} Description: InstallSytems Installer InstallSystems command line tool diff --git a/installsystems/config.py b/installsystems/config.py index 268f5b21e21ecb9043e9f06d7d6f9817ae2236d7..971576b287bff595503c3fdb4bda85138d6ec308 100644 --- a/installsystems/config.py +++ b/installsystems/config.py @@ -61,6 +61,8 @@ class MainConfigFile(ConfigFile): "repo_search": str, "repo_filter": str, "repo_config": str, + "nice": int, + "ionice": ["none", "rt", "be", "idle"] } 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 cfc1bc32d25a8959cfed9621c2d26a01c9b6f04a..8e8cd902b99a1e9bb64005b48415aadc00273aac 100644 --- a/samples/installsystems.conf +++ b/samples/installsystems.conf @@ -5,6 +5,12 @@ # Set verbosity (0: quiet, 1: normal, 2: debug) #verbosity = 2 +# Set nice process value +#nice = 0 + +# Set ionice class +#ionice = idle + # define a custom cache directory #cache = /tmp/sex