Add parsing code for --jobs and --load-average. (trunk r13263)
authorZac Medico <zmedico@gentoo.org>
Thu, 30 Apr 2009 06:53:14 +0000 (06:53 -0000)
committerZac Medico <zmedico@gentoo.org>
Thu, 30 Apr 2009 06:53:14 +0000 (06:53 -0000)
svn path=/main/branches/2.1.6/; revision=13442

bin/egencache

index e8981deba56c02f8e27eac8f02c1e14fe5bdb767..c7b73c98c4fbd2a5fa754bb61c36776619c6ee51 100755 (executable)
@@ -56,6 +56,37 @@ def parse_args(args):
                parser.error('No action specified (--update ' + \
                        'is the only available action)')
 
+       if options.jobs:
+               jobs = None
+               try:
+                       jobs = int(options.jobs)
+               except ValueError:
+                       jobs = -1
+
+               if jobs < 1:
+                       parser.error("Invalid: --jobs='%s'" % \
+                               (options.jobs,))
+
+               options.jobs = jobs
+
+       else:
+               options.jobs = None
+
+       if options.load_average:
+               try:
+                       load_average = float(options.load_average)
+               except ValueError:
+                       load_average = 0.0
+
+               if load_average <= 0.0:
+                       parser.error("Invalid: --load-average='%s'" % \
+                               (options.load_average,))
+
+               options.load_average = load_average
+
+       else:
+               options.load_average = None
+
        if options.config_root is not None and \
                not os.path.isdir(options.config_root):
                parser.error("Not a directory: --config-root='%s'" % \