Change several python and robot files to 110 chars
Taking advantage of current team limit of 110 chars.
Change-Id: If7ab51fe894889967b8c8bb2f2fa4664f01117d5
Signed-off-by: Michael Walsh <micwalsh@us.ibm.com>
diff --git a/bin/auto_status_file.py b/bin/auto_status_file.py
index 3d3acc3..5147b9d 100755
--- a/bin/auto_status_file.py
+++ b/bin/auto_status_file.py
@@ -100,8 +100,7 @@
def exit_function(signal_number=0,
frame=None):
r"""
- Execute whenever the program ends normally or with the signals that we
- catch (i.e. TERM, INT).
+ Execute whenever the program ends normally or with the signals that we catch (i.e. TERM, INT).
"""
dprint_executing()
@@ -113,18 +112,16 @@
def signal_handler(signal_number,
frame):
r"""
- Handle signals. Without a function to catch a SIGTERM or SIGINT, our
- program would terminate immediately with return code 143 and without
- calling our exit_function.
+ Handle signals. Without a function to catch a SIGTERM or SIGINT, our program would terminate immediately
+ with return code 143 and without calling our exit_function.
"""
- # Our convention is to set up exit_function with atexit.register() so
- # there is no need to explicitly call exit_function from here.
+ # Our convention is to set up exit_function with atexit.register() so there is no need to explicitly
+ # call exit_function from here.
dprint_executing()
- # Calling exit prevents us from returning to the code that was running
- # when we received the signal.
+ # Calling exit prevents us from returning to the code that was running when we received the signal.
exit(0)
@@ -154,8 +151,7 @@
if status_file_name == "":
if prefix == "":
prefix = command_string.split(" ")[0]
- # File extensions (e.g. ".sh", ".py", .etc), look clumsy in
- # status file names.
+ # File extensions (e.g. ".sh", ".py", .etc), look clumsy in status file names.
extension_regex = "\\.[a-zA-Z0-9]{1,3}$"
prefix = re.sub(extension_regex, "", prefix)
set_pgm_arg(prefix)
@@ -175,13 +171,12 @@
def script_func(command_string, status_file_path):
r"""
- Run the command string producing both stdout and file output via the
- script command and return the shell_rc.
+ Run the command string producing both stdout and file output via the script command and return the
+ shell_rc.
Description of argument(s):
command_string The command string to be run.
- status_file_path The path to the status file which is to
- contain a copy of all stdout.
+ status_file_path The path to the status file which is to contain a copy of all stdout.
"""
cmd_buf = "script -a -q -f " + status_file_path + " -c '" \
@@ -192,8 +187,7 @@
sub_proc.communicate()
shell_rc = sub_proc.returncode
- # Retrieve return code by examining ret_code_str output statement from
- # status file.
+ # Retrieve return code by examining ret_code_str output statement from status file.
# Example text to be analyzed.
# auto_status_file_ret_code: 127
cmd_buf = "tail -n 10 " + status_file_path + " | egrep -a \"" \
@@ -207,13 +201,11 @@
def tee_func(command_string, status_file_path):
r"""
- Run the command string producing both stdout and file output via the tee
- command and return the shell_rc.
+ Run the command string producing both stdout and file output via the tee command and return the shell_rc.
Description of argument(s):
command_string The command string to be run.
- status_file_path The path to the status file which is to
- contain a copy of all stdout.
+ status_file_path The path to the status file which is to contain a copy of all stdout.
"""
cmd_buf = "set -o pipefail ; " + command_string + " 2>&1 | tee -a " \
diff --git a/bin/gen_list.sh b/bin/gen_list.sh
index 2fc5875..080e61a 100755
--- a/bin/gen_list.sh
+++ b/bin/gen_list.sh
@@ -2,19 +2,17 @@
# This file contains list-manipulation functions.
-# A list is defined here as a string of items separated by some delimiter.
-# The PATH variable is one such example.
+# A list is defined here as a string of items separated by some delimiter. The PATH variable is one such
+# example.
if ! test "${default_delim+defined}" ; then
readonly default_delim=" "
fi
-# Performance note: It is important for these functions to run quickly. One
-# way to increase their speed is to avoid copying function arguments to local
-# variables and to instead use numbered arguments (e.g. ${1}, {2}, etc.) to
-# access the arguments from inside the functions. In some trials, this
-# doubled the speed of the functions. The cost of this is that it makes the
-# functions slightly more difficult to read.
+# Performance note: It is important for these functions to run quickly. One way to increase their speed is
+# to avoid copying function arguments to local variables and to instead use numbered arguments (e.g. ${1},
+# {2}, etc.) to access the arguments from inside the functions. In some trials, this doubled the speed of
+# the functions. The cost of this is that it makes the functions slightly more difficult to read.
function add_list_element {
@@ -28,10 +26,8 @@
# Description of argument(s):
# list_element The list element to be added.
# list_name The name of the list to be modified.
- # delim The delimiter used to separate list
- # elements.
- # position Indicates the position in the list where
- # the new element should be added
+ # delim The delimiter used to separate list elements.
+ # position Indicates the position in the list where the new element should be added
# ("front"/"back").
if [ -z "${!2}" ] ; then
@@ -62,26 +58,22 @@
# Description of argument(s):
# list_element The list element to be removed.
# list_name The name of the list to be modified.
- # delim The delimiter used to separate list
- # elements.
+ # delim The delimiter used to separate list elements.
local __rle_new_list__="${!2}"
- # Special case: The list contains one element which matches the specified
- # list element:
+ # Special case: The list contains one element which matches the specified list element:
if [ "${1}" == "${__rle_new_list__}" ] ; then
eval ${2}=\"\"
return
fi
- # Replace all occurrences of list_element that are bounded by the delimiter
- # on both sides.
+ # Replace all occurrences of list_element that are bounded by the delimiter on both sides.
__rle_new_list__="${__rle_new_list__//${delim}${1}${delim}/${delim}}"
- # Replace list_item if it occurs at the beginning of the string and is
- # bounded on the right by the delimiter.
+ # Replace list_item if it occurs at the beginning of the string and is bounded on the right by the
+ # delimiter.
__rle_new_list__="${__rle_new_list__#${1}${delim}}"
- # Replace list_item if it occurs at the end of the string and is bounded on
- # the left by the delimiter.
+ # Replace list_item if it occurs at the end of the string and is bounded on the left by the delimiter.
__rle_new_list__="${__rle_new_list__%${delim}${1}}"
# Set caller's variable to new value.
@@ -93,12 +85,11 @@
function cleanup_path_slashes {
local var_name="${1}" ; shift
- # For the variable named in var_name, replace all multiple-slashes with
- # single slashes and strip any trailing slash.
+ # For the variable named in var_name, replace all multiple-slashes with single slashes and strip any
+ # trailing slash.
# Description of argument(s):
- # var_name The name of the variable whose contents
- # are to be changed.
+ # var_name The name of the variable whose contents are to be changed.
local cmd_buf
@@ -112,17 +103,13 @@
local dir_path="${1}" ; shift
local path_var="${1:-PATH}" ; shift
- # Remove all occurrences of dir_path from the path variable named in
- # path_var.
+ # Remove all occurrences of dir_path from the path variable named in path_var.
- # Note that this function will remove extraneous slashes from the elements
- # of path_var.
+ # Note that this function will remove extraneous slashes from the elements of path_var.
# Description of argument(s):
- # dir_path The directory to be removed from the path
- # variable.
- # path_var The name of a variable containing
- # directory paths separated by colons.
+ # dir_path The directory to be removed from the path variable.
+ # path_var The name of a variable containing directory paths separated by colons.
cleanup_path_slashes dir_path || return 1
cleanup_path_slashes ${path_var} || return 1
diff --git a/bin/gen_setup.sh b/bin/gen_setup.sh
index eb81919..752bc44 100755
--- a/bin/gen_setup.sh
+++ b/bin/gen_setup.sh
@@ -19,31 +19,23 @@
local program_dir_path_var="${1:-program_dir_path}" ; shift
local follow_links="${1:-0}" ; shift
- # Determine the program path, name and dir path and assign them to the
- # variables indicated by the caller.
+ # Determine the program path, name and dir path and assign them to the variables indicated by the caller.
# Description of argument(s):
- # program_path_var The name of the variable to receive the
- # program path.
- # program_name_var The name of the variable to receive the
- # program name.
- # program_dir_path_var The name of the variable to receive the
- # program dir path.
- # follow_links If the program running is actually a link
- # to another file, use that file when
- # calculating the above values.
+ # program_path_var The name of the variable to receive the program path.
+ # program_name_var The name of the variable to receive the program name.
+ # program_dir_path_var The name of the variable to receive the program dir path.
+ # follow_links If the program running is actually a link to another file, use that file
+ # when calculating the above values.
local _spn_loc_program_path_="${0}"
- # The program name is the program path minus all characters up to and
- # including the first slash.
+ # The program name is the program path minus all characters up to and including the first slash.
local _spn_loc_program_name_=${_spn_loc_program_path_##*/}
- # The program dir path is the program path minus everything from the last
- # slash to the end of the string.
+ # The program dir path is the program path minus everythin from the last slash to the end of the string.
local _spn_loc_program_dir_path_=${_spn_loc_program_path_%${_spn_loc_program_name_}}
- # If program dir path does not start with a slash then it is relative.
- # Convert it to absolute.
+ # If program dir path does not start with a slash then it is relative. Convert it to absolute.
if [ "${_spn_loc_program_dir_path_:0:1}" != "/" ] ; then
_spn_loc_program_dir_path_="$(readlink -f ${_spn_loc_program_dir_path_})/"
# Re-assemble the parts into program path variable.
diff --git a/bin/obmc_ser_num b/bin/obmc_ser_num
index 4269e42..6d2efeb 100755
--- a/bin/obmc_ser_num
+++ b/bin/obmc_ser_num
@@ -1,8 +1,7 @@
#!/usr/bin/env python
r"""
-This program will get the system serial number from an OBMC machine and print
-it to stdout.
+This program will get the system serial number from an OBMC machine and print it to stdout.
"""
import sys
@@ -50,8 +49,7 @@
def exit_function(signal_number=0,
frame=None):
r"""
- Execute whenever the program ends normally or with the signals that we
- catch (i.e. TERM, INT).
+ Execute whenever the program ends normally or with the signals that we catch (i.e. TERM, INT).
"""
dprint_executing()
@@ -63,25 +61,22 @@
def signal_handler(signal_number,
frame):
r"""
- Handle signals. Without a function to catch a SIGTERM or SIGINT, our
- program would terminate immediately with return code 143 and without
- calling our exit_function.
+ Handle signals. Without a function to catch a SIGTERM or SIGINT, our program would terminate immediately
+ with return code 143 and without calling our exit_function.
"""
- # Our convention is to set up exit_function with atexit.register() so
- # there is no need to explicitly call exit_function from here.
+ # Our convention is to set up exit_function with atexit.register() so there is no need to explicitly
+ # call exit_function from here.
dprint_executing()
- # Calling exit prevents us from returning to the code that was running
- # when we received the signal.
+ # Calling exit prevents us from returning to the code that was running when we received the signal.
exit(0)
def validate_parms():
r"""
- Validate program parameters, etc. Return True or False (i.e. pass/fail)
- accordingly.
+ Validate program parameters, etc. Return True or False (i.e. pass/fail) accordingly.
"""
gen_post_validation(exit_function, signal_handler)
@@ -94,8 +89,7 @@
Create and return an http prefix string.
Description of argument(s):
- host The host being communicated with via the
- curl command.
+ host The host being communicated with via the curl command.
"""
return "https://" + host + "/"
diff --git a/bin/plug_ins/Stop/cp_stop_check b/bin/plug_ins/Stop/cp_stop_check
index 713bd96..efbc733 100755
--- a/bin/plug_ins/Stop/cp_stop_check
+++ b/bin/plug_ins/Stop/cp_stop_check
@@ -49,9 +49,8 @@
formatter_class=argparse.RawTextHelpFormatter,
prefix_chars='-+')
-# 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
-# gen_get_options.
+# 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 gen_get_options.
stock_list = [("test_mode", 0),
("quiet", get_plug_default("quiet", 0)),
("debug", get_plug_default("debug", 0))]
@@ -60,8 +59,7 @@
def exit_function(signal_number=0,
frame=None):
r"""
- Execute whenever the program ends normally or with the signals that we
- catch (i.e. TERM, INT).
+ Execute whenever the program ends normally or with the signals that we catch (i.e. TERM, INT).
"""
dprint_executing()
@@ -75,25 +73,22 @@
def signal_handler(signal_number,
frame):
r"""
- Handle signals. Without a function to catch a SIGTERM or SIGINT, our
- program would terminate immediately with return code 143 and without
- calling our exit_function.
+ Handle signals. Without a function to catch a SIGTERM or SIGINT, our program would terminate immediately
+ with return code 143 and without calling our exit_function.
"""
- # Our convention is to set up exit_function with atexit.register() so
- # there is no need to explicitly call exit_function from here.
+ # Our convention is to set up exit_function with atexit.register() so there is no need to explicitly
+ # call exit_function from here.
dprint_executing()
- # Calling exit prevents us from returning to the code that was running
- # when we received the signal.
+ # Calling exit prevents us from returning to the code that was running when we received the signal.
exit(0)
def validate_parms():
r"""
- Validate program parameters, etc. Return True or False (i.e. pass/fail)
- accordingly.
+ Validate program parameters, etc. Return True or False (i.e. pass/fail) accordingly.
"""
get_plug_vars()
@@ -118,9 +113,8 @@
def rest_fail():
r"""
- If STOP_REST_FAIL, then this function will determine whether REST commands
- to the target are working. If not, this function will stop the program by
- returning stop_test_rc.
+ If STOP_REST_FAIL, then this function will determine whether REST commands to the target are working. If
+ not, this function will stop the program by returning stop_test_rc.
"""
if STOP_REST_FAIL != '1':
@@ -153,9 +147,8 @@
def esel_stop_check():
r"""
- Run the esel_stop_check program to determine whether any eSEL entries
- found warrant stopping the test run. See esel_stop_check help text for
- details.
+ Run the esel_stop_check program to determine whether any eSEL entries found warrant stopping the test
+ run. See esel_stop_check help text for details.
"""
if STOP_ESEL_STOP_FILE_PATH == "":
diff --git a/bin/process_plug_in_packages.py b/bin/process_plug_in_packages.py
index b03290c..9941892 100755
--- a/bin/process_plug_in_packages.py
+++ b/bin/process_plug_in_packages.py
@@ -9,12 +9,11 @@
import os
import argparse
-# python puts the program's directory path in sys.path[0]. In other words,
-# the user ordinarily has no way to override python's choice of a module from
-# its own dir. We want to have that ability in our environment. However, we
-# don't want to break any established python modules that depend on this
-# behavior. So, we'll save the value from sys.path[0], delete it, import our
-# modules and then restore sys.path to its original value.
+# python puts the program's directory path in sys.path[0]. In other words, the user ordinarily has no way
+# to override python's choice of a module from its own dir. We want to have that ability in our environment.
+# However, we don't want to break any established python modules that depend on this behavior. So, we'll
+# save the value from sys.path[0], delete it, import our modules and then restore sys.path to its original
+# value.
save_path_0 = sys.path[0]
del sys.path[0]
@@ -121,17 +120,15 @@
default="obmc",
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
-# gen_get_options.
+# 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 gen_get_options.
stock_list = [("test_mode", 0), ("quiet", 1), ("debug", 0)]
def exit_function(signal_number=0,
frame=None):
r"""
- Execute whenever the program ends normally or with the signals that we
- catch (i.e. TERM, INT).
+ Execute whenever the program ends normally or with the signals that we catch (i.e. TERM, INT).
"""
dprint_executing()
@@ -142,18 +139,16 @@
def signal_handler(signal_number, frame):
r"""
- Handle signals. Without a function to catch a SIGTERM or SIGINT, our
- program would terminate immediately with return code 143 and without
- calling our exit_function.
+ Handle signals. Without a function to catch a SIGTERM or SIGINT, our program would terminate immediately
+ with return code 143 and without calling our exit_function.
"""
- # Our convention is to set up exit_function with atexit.registr() so
- # there is no need to explicitly call exit_function from here.
+ # Our convention is to set up exit_function with atexit.registr() so there is no need to explicitly call
+ # exit_function from here.
dprint_executing()
- # Calling exit prevents us from returning to the code that was running
- # when we received the signal.
+ # Calling exit prevents us from returning to the code that was running when we received the signal.
exit(0)
@@ -182,29 +177,20 @@
call_point,
allow_shell_rc):
r"""
- Run the call point program in the given plug_in_dir_path. Return the
- following:
+ Run the call point program in the given plug_in_dir_path. Return the following:
rc The return code - 0 = PASS, 1 = FAIL.
- shell_rc The shell return code returned by
- process_plug_in_packages.py.
+ shell_rc The shell return code returned by process_plug_in_packages.py.
failed_plug_in_name The failed plug in name (if any).
Description of arguments:
- plug_in_dir_path The directory path where the call_point
- program may be located.
- call_point The call point (e.g. "setup"). This
- program will look for a program named
- "cp_" + call_point in the
- plug_in_dir_path. If no such call point
- program is found, this function returns an
- rc of 0 (i.e. success).
- allow_shell_rc The user may supply a value other than
- zero to indicate an 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
+ plug_in_dir_path The directory path where the call_point program may be located.
+ call_point The call point (e.g. "setup"). This program will look for a program
+ named "cp_" + call_point in the plug_in_dir_path. If no such call point
+ program is found, this function returns an rc of 0 (i.e. success).
+ allow_shell_rc The user may supply a value other than zero to indicate an 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.
"""
@@ -216,8 +202,7 @@
cp_prefix = "cp_"
plug_in_pgm_path = plug_in_dir_path + cp_prefix + call_point
if not os.path.exists(plug_in_pgm_path):
- # No such call point in this plug in dir path. This is legal so we
- # return 0, etc.
+ # No such call point in this plug in dir path. This is legal so we return 0, etc.
return rc, shell_rc, failed_plug_in_name
print("------------------------------------------------- Starting plug-"
@@ -278,13 +263,12 @@
def main():
r"""
- This is the "main" function. The advantage of having this function vs
- just doing this in the true mainline is that you can:
+ This is the "main" function. The advantage of having this function vs just doing this in the true
+ mainline is that you can:
- Declare local variables
- Use "return" instead of "exit".
- Indent 4 chars like you would in any function.
- This makes coding more consistent, i.e. it's easy to move code from here
- into a function and vice versa.
+ This makes coding more consistent, i.e. it's easy to move code from here into a function and vice versa.
"""
if not gen_get_options(parser, stock_list):
diff --git a/bin/prop_call.py b/bin/prop_call.py
index 30845ff..eab1c77 100755
--- a/bin/prop_call.py
+++ b/bin/prop_call.py
@@ -67,8 +67,7 @@
def exit_function(signal_number=0,
frame=None):
r"""
- Execute whenever the program ends normally or with the signals that we
- catch (i.e. TERM, INT).
+ Execute whenever the program ends normally or with the signals that we catch (i.e. TERM, INT).
"""
dprint_executing()
@@ -80,25 +79,22 @@
def signal_handler(signal_number,
frame):
r"""
- Handle signals. Without a function to catch a SIGTERM or SIGINT, our
- program would terminate immediately with return code 143 and without
- calling our exit_function.
+ Handle signals. Without a function to catch a SIGTERM or SIGINT, our program would terminate immediately
+ with return code 143 and without calling our exit_function.
"""
- # Our convention is to set up exit_function with atexit.register() so
- # there is no need to explicitly call exit_function from here.
+ # Our convention is to set up exit_function with atexit.register() so there is no need to explicitly
+ # call exit_function from here.
dprint_executing()
- # Calling exit prevents us from returning to the code that was running
- # when we received the signal.
+ # Calling exit prevents us from returning to the code that was running when we received the signal.
exit(0)
def validate_parms():
r"""
- Validate program parameters, etc. Return True or False (i.e. pass/fail)
- accordingly.
+ Validate program parameters, etc. Return True or False (i.e. pass/fail) accordingly.
"""
global prop_dir_path
diff --git a/bin/select_version b/bin/select_version
index ff09003..d6fca43 100755
--- a/bin/select_version
+++ b/bin/select_version
@@ -1,26 +1,22 @@
#!/bin/bash
-# This script is a wrapper for programs that may have alternate versions
-# (e.g. python2, python3). This wrapper allows the user to influence the
-# selection of the program version by setting the <program name>_VERSION (e.g.
-# PYTHON_VERSION, ROBOT_VERSION, etc.) environment variable.
+# This script is a wrapper for programs that may have alternate versions (e.g. python2, python3). This
+# wrapper allows the user to influence the selection of the program version by setting the <program
+# name>_VERSION (e.g. PYTHON_VERSION, ROBOT_VERSION, etc.) environment variable.
-# Users would be expected to create a link with the base name of the program
-# that points to this file.
+# Users would be expected to create a link with the base name of the program that points to this file.
# Example:
# cd openbmc-test-automation/bin
# ln -s select_version python
-# The PATH variable should contain the expanded path to
-# openbmc-test-automation/bin.
+# The PATH variable should contain the expanded path to openbmc-test-automation/bin.
-# If <program name>_VERSION is blank or not set, then the program version
-# will be whatever the system default program version is. If <program
-# name>_VERSION is set to a value, then that value will be appended to the name
-# of the program (e.g. if PYTHON_VERSION = "3", then python3 will be used.).
-# If <program name>_VERSION is set to some value that does not correspond to a
-# valid program version for the given system, this program will fail.
+# If <program name>_VERSION is blank or not set, then the program version will be whatever the system
+# default program version is. If <program name>_VERSION is set to a value, then that value will be appended
+# to the name of the program (e.g. if PYTHON_VERSION = "3", then python3 will be used.). If <program
+# name>_VERSION is set to some value that does not correspond to a valid program version for the given
+# system, this program will fail.
# Make sure program_name is set.
@@ -31,12 +27,10 @@
function get_target_program_path {
local target_program_path_var="${1:-target_program_path}" ; shift
- # Get the full path to the "real" program and assign it to the variable
- # named in target_program_path_var.
+ # Get the full path to the "real" program and assign it to the variable named in target_program_path_var.
# Description of argument(s):
- # target_program_path_var The name of the variable to receive the
- # result.
+ # target_program_path_var The name of the variable to receive the result.
# Example result:
@@ -52,8 +46,7 @@
# The typical use of this program would be to create a link to it like this:
# ln -s select_version python
- # That being the case, get the name of this actual program (rather than the
- # name of the link to it).
+ # That being the case, get the name of this actual program (rather than the name of the link to it).
base_program_path=$(readlink -f "${0}")
base_program_name=${base_program_path##*/}
@@ -70,8 +63,7 @@
# Compose the alternate_program_name (e.g. python3).
alternate_program_name=${program_name}${!version_var_name}
- # Now use the "type" built-in to search the PATH variable for a list of
- # target program candidates.
+ # Now use the "type" built-in to search the PATH variable for a list of target program candidates.
candidates=$(type -ap ${alternate_program_name})
# Example candidates:
@@ -79,20 +71,17 @@
# /usr/bin/python
# In this example, the first candidate is actually a link to
- # /home/robot/openbmc-test-automation/bin/select_version. As such it will
- # be rejected.
+ # /home/robot/openbmc-test-automation/bin/select_version. As such it will be rejected.
for candidate in ${candidates}
do
if [ -L "${candidate}" ] ; then
- # The candidate is a link so we need to see if it's a link to this
- # program file.
+ # The candidate is a link so we need to see if it's a link to this program file.
base_file_path=$(readlink "${candidate}")
[ "${base_file_path}" == "${base_program_name}" ] && continue
fi
- # The candidate is NOT a link so it qualifies as the desired target
- # program path.
+ # The candidate is NOT a link so it qualifies as the desired target program path.
eval ${target_program_path_var}=\"\${candidate}\"
return
@@ -107,8 +96,8 @@
# Compose program path var name (e.g. PYTHON_PGM_PATH).
pgm_path_var_name=${program_uppercase_name}_PGM_PATH
- # Set and export pgm_path_var_name (e.g. PYTHON_PGM_PATH=/usr/bin/python3).
- # This value can be used by child programs for debug.
+ # Set and export pgm_path_var_name (e.g. PYTHON_PGM_PATH=/usr/bin/python3). This value can be used by
+ # child programs for debug.
eval export ${pgm_path_var_name}=${target_program_path}
if [ "${1}" == "--print_only" ] ; then
diff --git a/bin/validate_plug_ins.py b/bin/validate_plug_ins.py
index 809f17a..13ec687 100755
--- a/bin/validate_plug_ins.py
+++ b/bin/validate_plug_ins.py
@@ -8,12 +8,11 @@
import os
-# python puts the program's directory path in sys.path[0]. In other words,
-# the user ordinarily has no way to override python's choice of a module from
-# its own dir. We want to have that ability in our environment. However, we
-# don't want to break any established python modules that depend on this
-# behavior. So, we'll save the value from sys.path[0], delete it, import our
-# modules and then restore sys.path to its original value.
+# python puts the program's directory path in sys.path[0]. In other words, the user ordinarily has no way
+# to override python's choice of a module from its own dir. We want to have that ability in our environment.
+# However, we don't want to break any established python modules that depend on this behavior. So, we'll
+# save the value from sys.path[0], delete it, import our modules and then restore sys.path to its original
+# value.
save_path_0 = sys.path[0]
del sys.path[0]
@@ -49,17 +48,15 @@
default="obmc",
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
-# gen_get_options.
+# 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 gen_get_options.
stock_list = [("test_mode", 0), ("quiet", 1), ("debug", 0)]
def exit_function(signal_number=0,
frame=None):
r"""
- Execute whenever the program ends normally or with the signals that we
- catch (i.e. TERM, INT).
+ Execute whenever the program ends normally or with the signals that we catch (i.e. TERM, INT).
"""
dprint_executing()
@@ -70,18 +67,16 @@
def signal_handler(signal_number, frame):
r"""
- Handle signals. Without a function to catch a SIGTERM or SIGINT, our
- program would terminate immediately with return code 143 and without
- calling our exit_function.
+ Handle signals. Without a function to catch a SIGTERM or SIGINT, our program would terminate immediately
+ with return code 143 and without calling our exit_function.
"""
- # Our convention is to set up exit_function with atexit.registr() so
- # there is no need to explicitly call exit_function from here.
+ # Our convention is to set up exit_function with atexit.registr() so there is no need to explicitly call
+ # exit_function from here.
dprint_executing()
- # Calling exit prevents us from returning to the code that was running
- # when we received the signal.
+ # Calling exit prevents us from returning to the code that was running when we received the signal.
exit(0)
@@ -97,13 +92,12 @@
def main():
r"""
- This is the "main" function. The advantage of having this function vs
- just doing this in the true mainline is that you can:
+ This is the "main" function. The advantage of having this function vs just doing this in the true
+ mainline is that you can:
- Declare local variables
- Use "return" instead of "exit".
- Indent 4 chars like you would in any function.
- This makes coding more consistent, i.e. it's easy to move code from here
- into a function and vice versa.
+ This makes coding more consistent, i.e. it's easy to move code from here into a function and vice versa.
"""
if not gen_get_options(parser, stock_list):
@@ -122,8 +116,7 @@
mch_class)
qprint_var(plug_in_packages_list)
- # As stated in the help text, this program must print the full paths of
- # each selected plug in.
+ # As stated in the help text, this program must print the full paths of each selected plug in.
for plug_in_dir_path in plug_in_packages_list:
print(plug_in_dir_path)