Changes to process_plug_in_packages.py.

  - Made some pep8 corrections to parser.add_arguement().
  - Added valid_integer(shell_rc) check.
  - Added shell_rc shift left (which was specified in help text but not
    implemented).
  - Change to convert shell_rc to int for consistent processing.

lib/gen_arg.py
  - Made some pep8 corrections to parser.add_arguement().
  - set_pgm_arg:  New function.

Change-Id: I7726c80bb3312a96ee5dc670b50e47e4d3c7aaa3
Signed-off-by: Michael Walsh <micwalsh@us.ibm.com>
diff --git a/bin/process_plug_in_packages.py b/bin/process_plug_in_packages.py
index 7b1e743..c0a056e 100755
--- a/bin/process_plug_in_packages.py
+++ b/bin/process_plug_in_packages.py
@@ -55,16 +55,14 @@
                 " reserverd for errors in calling the call point program" +
                 " rather than errors generated by the call point program.>",
     formatter_class=argparse.RawTextHelpFormatter,
-    prefix_chars='-+'
-    )
+    prefix_chars='-+')
 
 # Create arguments.
 parser.add_argument(
     'plug_in_dir_paths',
     nargs='?',
     default="",
-    help=plug_in_dir_paths_help_text + default_string
-    )
+    help=plug_in_dir_paths_help_text + default_string)
 
 parser.add_argument(
     '--call_point',
@@ -73,8 +71,7 @@
     help='The call point program name.  This value must not include the' +
          ' "cp_" prefix.  For each plug-in package passed to this program,' +
          ' the specified call_point program will be called if it exists in' +
-         ' the plug-in directory.' + default_string
-    )
+         ' the plug-in directory.' + default_string)
 
 parser.add_argument(
     '--shell_rc',
@@ -83,8 +80,7 @@
          ' acceptable non-zero return code.  For example, if this value' +
          ' equals 0x00000200, it means that for each plug-in call point that' +
          ' runs, a 0x00000200 will not be counted as a failure.  See note' +
-         ' above regarding left-shifting of return codes.' + default_string
-    )
+         ' above regarding left-shifting of return codes.' + default_string)
 
 parser.add_argument(
     '--stop_on_plug_in_failure',
@@ -97,8 +93,7 @@
          'the call point program from each and every plug-in directory ' +
          'regardless of their return values.  Typical example cases where ' +
          'you\'d want to run all plug-in call points regardless of success ' +
-         'or failure would be "cleanup" or "ffdc" call points.'
-    )
+         'or failure would be "cleanup" or "ffdc" call points.')
 
 parser.add_argument(
     '--stop_on_non_zero_rc',
@@ -117,14 +112,12 @@
          ' that a given error log entry was found in an "ignore" list and is' +
          ' therefore to be ignored.  That being the case, no other' +
          ' "check_errl" call point program would need to be called.' +
-         default_string
-    )
+         default_string)
 
 parser.add_argument(
     '--mch_class',
     default="obmc",
-    help=mch_class_help_text + default_string
-    )
+    help=mch_class_help_text + default_string)
 
 # The stock_list will be passed to gen_get_options.  We populate it with the
 # names of stock parm options we want.  These stock parms are pre-defined by
@@ -181,6 +174,14 @@
     if not valid_value(call_point):
         return False
 
+    global shell_rc
+    if not valid_integer(shell_rc):
+        return False
+
+    # Convert to hex string for consistency in printout.
+    shell_rc = "0x%08x" % int(shell_rc, 0)
+    set_pgm_arg(shell_rc)
+
     gen_post_validation(exit_function, signal_handler)
 
     return True
@@ -256,7 +257,9 @@
     sub_proc = subprocess.Popen(cmd_buf, shell=True)
     sub_proc.communicate()
     shell_rc = sub_proc.returncode
-    if shell_rc != 0 and shell_rc != int(caller_shell_rc, 16):
+    # Shift to left.
+    shell_rc *= 0x100
+    if shell_rc != 0 and shell_rc != caller_shell_rc:
         rc = 1
         failed_plug_in_name = \
             os.path.basename(os.path.normpath(plug_in_dir_path))
@@ -303,7 +306,7 @@
     qpvar(plug_in_packages_list)
     qprint("\n")
 
-    caller_shell_rc = shell_rc
+    caller_shell_rc = int(shell_rc, 0)
     shell_rc = 0
     failed_plug_in_name = ""
 
diff --git a/lib/gen_arg.py b/lib/gen_arg.py
index 72638cc..36fcba1 100755
--- a/lib/gen_arg.py
+++ b/lib/gen_arg.py
@@ -82,8 +82,7 @@
                 help='If this parameter is set to "1", %(prog)s' +
                      ' will print only essential information, i.e. it will' +
                      ' not echo parameters, echo commands, print the total' +
-                     ' run time, etc.' + default_string
-                )
+                     ' run time, etc.' + default_string)
         elif arg_name == "test_mode":
             if default is None:
                 default = 0
@@ -95,8 +94,7 @@
                 help='This means that %(prog)s should go through all the' +
                      ' motions but not actually do anything substantial.' +
                      '  This is mainly to be used by the developer of' +
-                     ' %(prog)s.' + default_string
-                )
+                     ' %(prog)s.' + default_string)
         elif arg_name == "debug":
             if default is None:
                 default = 0
@@ -107,8 +105,7 @@
                 choices=[1, 0],
                 help='If this parameter is set to "1", %(prog)s will print' +
                      ' additional debug information.  This is mainly to be' +
-                     ' used by the developer of %(prog)s.' + default_string
-                )
+                     ' used by the developer of %(prog)s.' + default_string)
         elif arg_name == "loglevel":
             if default is None:
                 default = "info"
@@ -120,8 +117,7 @@
                          'debug', 'info', 'warning', 'error', 'critical'],
                 help='If this parameter is set to "1", %(prog)s will print' +
                      ' additional debug information.  This is mainly to be' +
-                     ' used by the developer of %(prog)s.' + default_string
-                )
+                     ' used by the developer of %(prog)s.' + default_string)
 
     arg_obj = parser.parse_args()
 
@@ -161,6 +157,37 @@
 ###############################################################################
 
 
+###############################################################################
+def set_pgm_arg(var_value,
+                var_name=None):
+
+    r"""
+    Set the value of the arg_obj.__dict__ entry named in var_name with the
+    var_value provided.  Also, set corresponding global variable.
+
+    Description of arguments:
+    var_value                       The value to set in the variable.
+    var_name                        The name of the variable to set.  This
+                                    defaults to the name of the variable used
+                                    for var_value when calling this function.
+    """
+
+    if var_name is None:
+        var_name = gp.get_arg_name(None, 1, 2)
+
+    arg_obj.__dict__[var_name] = var_value
+    module = sys.modules['__main__']
+    setattr(module, var_name, var_value)
+    if var_name == "quiet":
+        __builtin__.quiet = var_value
+    elif var_name == "debug":
+        __builtin__.debug = var_value
+    elif var_name == "test_mode":
+        __builtin__.test_mode = var_value
+
+###############################################################################
+
+
 # Put this in gen_opt.py or gen_parm.py or gen_arg.py.
 ###############################################################################
 def sprint_args(arg_obj,