Optimize plugin load and Env YAML load

Changes:
    - Handle FileNotFoundError error for ENV YAML
    - Mask password from print in console log
    - Update code documentation

Tested:
    - Ran from the sandbox with the changes

Change-Id: I8c549285db202242ecd4460c28eaf7090aabe01e
Signed-off-by: George Keishing <gkeishin@in.ibm.com>
diff --git a/ffdc/ffdc_collector.py b/ffdc/ffdc_collector.py
index b017efa..03c2d55 100644
--- a/ffdc/ffdc_collector.py
+++ b/ffdc/ffdc_collector.py
@@ -42,24 +42,20 @@
        - arg1
        - arg2
 """
-plugin_dir = __file__.split(__file__.split("/")[-1])[0] + "/plugins"
+plugin_dir = os.path.join(os.path.dirname(__file__), "plugins")
 sys.path.append(plugin_dir)
-try:
-    for module in os.listdir(plugin_dir):
-        if module == "__init__.py" or module[-3:] != ".py":
-            continue
-        plugin_module = "plugins." + module[:-3]
-        # To access the module plugin.<module name>.<function>
-        # Example: plugin.foo_func.foo_func_yaml()
-        try:
-            plugin = __import__(plugin_module, globals(), locals(), [], 0)
-        except Exception as e:
-            print("PLUGIN: Exception: %s" % e)
-            print("PLUGIN: Module import failed: %s" % module)
-            pass
-except FileNotFoundError as e:
-    print("PLUGIN: %s" % e)
-    pass
+
+for module in os.listdir(plugin_dir):
+    if module == "__init__.py" or not module.endswith(".py"):
+        continue
+
+    plugin_module = f"plugins.{module[:-3]}"
+    try:
+        plugin = __import__(plugin_module, globals(), locals(), [], 0)
+    except Exception as e:
+        print(f"PLUGIN: Exception: {e}")
+        print(f"PLUGIN: Module import failed: {module}")
+        continue
 
 r"""
 This is for plugin functions returning data or responses to the caller
@@ -998,6 +994,8 @@
         )
 
         if result.stderr and not quiet:
+            if self.password in parms_string:
+                parms_string = parms_string.replace(self.password, "********")
             self.logger.error("\n\t\tERROR with %s " % parms_string)
             self.logger.error("\t\t" + result.stderr)
 
@@ -1068,14 +1066,25 @@
 
     def load_env(self):
         r"""
-        Perform protocol working check.
+        Load the user environment variables from a YAML file.
 
+        This method reads the environment variables from a YAML file specified
+        in the ENV_FILE environment variable. If the file is not found or
+        there is an error reading the file, an exception is raised.
+
+        The YAML file should have the following format:
+
+        .. code-block:: yaml
+
+            VAR_NAME: VAR_VALUE
+
+        Where VAR_NAME is the name of the environment variable, and
+        VAR_VALUE is its value.
+
+        After loading the environment variables, they are stored in the
+        self.env attribute for later use.
         """
-        # This is for the env vars a user can use in YAML to load
-        # it at runtime.
-        # Example YAML:
-        # -COMMANDS:
-        #    - my_command ${hostname}  ${username}   ${password}
+
         os.environ["hostname"] = self.hostname
         os.environ["username"] = self.username
         os.environ["password"] = self.password
@@ -1100,6 +1109,7 @@
                     os.environ[key] = value
                     self.env_dict[key] = str(value)
 
+            # Load user specified ENV config YAML.
             if self.econfig:
                 with open(self.econfig, "r") as file:
                     try:
@@ -1114,6 +1124,9 @@
         except json.decoder.JSONDecodeError as e:
             self.logger.error("\n\tERROR: %s " % e)
             sys.exit(-1)
+        except FileNotFoundError as e:
+            self.logger.error("\n\tERROR: %s " % e)
+            sys.exit(-1)
 
         # This to mask the password from displaying on the console.
         mask_dict = self.env_dict.copy()