From 1ddda9a8db7b1e09a04220a8677b60015b2fe849 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Mon, 8 Oct 2012 13:30:08 -0700 Subject: [PATCH] emerge: handle --load-average with no arg With no argument, removes a previous load limit (same behavior as make). --- man/emerge.1 | 3 ++- pym/_emerge/main.py | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/man/emerge.1 b/man/emerge.1 index c0303079d..929996721 100644 --- a/man/emerge.1 +++ b/man/emerge.1 @@ -511,9 +511,10 @@ dependencies are recalculated for remaining packages and any with unsatisfied dependencies are automatically dropped. Also see the related \fB\-\-skipfirst\fR option. .TP -.BR \-\-load\-average=LOAD +.BR "\-\-load\-average [LOAD]" Specifies that no new builds should be started if there are other builds running and the load average is at least LOAD (a floating-point number). +With no argument, removes a previous load limit. This option is recommended for use in combination with \fB\-\-jobs\fR in order to avoid excess load. See \fBmake\fR(1) for information about analogous options that should be configured via \fBMAKEOPTS\fR in diff --git a/pym/_emerge/main.py b/pym/_emerge/main.py index c3e96465d..e3557e574 100644 --- a/pym/_emerge/main.py +++ b/pym/_emerge/main.py @@ -454,6 +454,16 @@ def insert_optional_args(args): return False valid_integers = valid_integers() + + class valid_floats(object): + def __contains__(self, s): + try: + return float(s) >= 0 + except (ValueError, OverflowError): + return False + + valid_floats = valid_floats() + y_or_n = ('y', 'n',) new_args = [] @@ -475,6 +485,7 @@ def insert_optional_args(args): '--getbinpkgonly' : y_or_n, '--jobs' : valid_integers, '--keep-going' : y_or_n, + '--load-average' : valid_floats, '--package-moves' : y_or_n, '--quiet' : y_or_n, '--quiet-build' : y_or_n, @@ -1209,6 +1220,9 @@ def parse_opts(tmpcmdline, silent=False): myoptions.jobs = jobs + if myoptions.load_average == "True": + myoptions.load_average = None + if myoptions.load_average: try: load_average = float(myoptions.load_average) -- 2.26.2