From f85dfe4023d45c9a8b5f9b5646c87cdf62204196 Mon Sep 17 00:00:00 2001
From: Abhishek Koneru <akoneru@redhat.com>
Date: Mon, 1 Jul 2013 10:23:36 -0400
Subject: [PATCH 88/89] Fixes for issues reported by pylint.

Fixes for issues in other files.
Ticket #316
---
 base/common/python/pki/encoder.py            |    2 +-
 base/common/python/pki/util.py               |    6 +++---
 base/server/src/engine/pkiparser.py          |   20 ++++++++++----------
 base/server/src/pkidestroy                   |    2 +-
 base/server/src/pkispawn                     |    2 +-
 base/server/src/scriptlets/initialization.py |    2 +-
 base/server/src/scriptlets/selinux_setup.py  |   16 ++++++++--------
 7 files changed, 25 insertions(+), 25 deletions(-)

diff --git a/base/common/python/pki/encoder.py b/base/common/python/pki/encoder.py
index 7fee57e7106adf841b9d3dd3f58d8eb4843d6ee7..c100be3d50a62e8d951fd2c1a91a4a9cc9fd129a 100644
--- a/base/common/python/pki/encoder.py
+++ b/base/common/python/pki/encoder.py
@@ -16,7 +16,7 @@ class CustomTypeEncoder(json.JSONEncoder):
     def default(self, obj):
         for k, v in TYPES.items():
             if isinstance(obj, v):
-                return { k: obj.__dict__ }
+                return {k: obj.__dict__}
         for k, v in NOTYPES.items():
             if isinstance(obj, v):
                 return obj.__dict__
diff --git a/base/common/python/pki/util.py b/base/common/python/pki/util.py
index 7db4fbe79f925715b915c76c6d2748aabfbdadf1..9b501a3420fd38a46ffa1fd0e95b32f379270ecd 100644
--- a/base/common/python/pki/util.py
+++ b/base/common/python/pki/util.py
@@ -25,9 +25,9 @@ import shutil
 
 def copyfile(source, dest):
 
-    dir = os.path.dirname(dest)
-    if not os.path.exists(dir):
-        os.makedirs(dir)
+    dest_dir = os.path.dirname(dest)
+    if not os.path.exists(dest_dir):
+        os.makedirs(dest_dir)
 
     shutil.copy2(source, dest)
     st = os.stat(source)
diff --git a/base/server/src/engine/pkiparser.py b/base/server/src/engine/pkiparser.py
index 7ad8ad3fea84692c7a02175e76faed235eeae438..2ed0cba7850c9f5e500ebcc4aad76cf46693546d 100644
--- a/base/server/src/engine/pkiparser.py
+++ b/base/server/src/engine/pkiparser.py
@@ -53,7 +53,7 @@ class PKIConfigParser:
     def __init__(self, description, epilog):
         self.pki_config = None
 
-        "Read and process command-line options"
+        #Read and process command-line options
         self.arg_parser = argparse.ArgumentParser(
                      description=description,
                      add_help=False,
@@ -92,7 +92,7 @@ class PKIConfigParser:
         self.pki_slots_dict = dict()
 
     # PKI Deployment Helper Functions
-    def process_command_line_arguments(self, argv):
+    def process_command_line_arguments(self):
 
         # Parse command-line options
         args = self.arg_parser.parse_args()
@@ -133,7 +133,7 @@ class PKIConfigParser:
                       config.pki_root_prefix
                 print
                 self.arg_parser.print_help()
-                self.arg_parser.exit(-1);
+                self.arg_parser.exit(-1)
 
         # always default that configuration file exists
         if not os.path.exists(config.default_deployment_cfg) or\
@@ -143,7 +143,7 @@ class PKIConfigParser:
                   config.default_deployment_cfg
             print
             self.arg_parser.print_help()
-            self.arg_parser.exit(-1);
+            self.arg_parser.exit(-1)
 
         if config.user_deployment_cfg:
             # verify user configuration file exists
@@ -153,8 +153,8 @@ class PKIConfigParser:
                       log.PKI_FILE_MISSING_OR_NOT_A_FILE_1 % \
                       config.user_deployment_cfg
                 print
-                parser.arg_parser.print_help()
-                parser.arg_parser.exit(-1);
+                self.arg_parser.print_help()
+                self.arg_parser.exit(-1)
 
 
     def init_config(self):
@@ -201,7 +201,7 @@ class PKIConfigParser:
         config.user_config.optionxform = str
 
         with open(config.default_deployment_cfg) as f:
-                self.pki_config.readfp(f)
+            self.pki_config.readfp(f)
 
         self.flatten_master_dict()
 
@@ -216,7 +216,7 @@ class PKIConfigParser:
                 # First, remove comments:
                 if PKIConfigParser.COMMENT_CHAR in line:
                     # split on comment char, keep only the part before
-                    line, comment = line.split(PKIConfigParser.COMMENT_CHAR, 1)
+                    line, _ = line.split(PKIConfigParser.COMMENT_CHAR, 1)
                 # Second, find lines with an name=value:
                 if PKIConfigParser.OPTION_CHAR in line:
                     # split on name char:
@@ -229,7 +229,7 @@ class PKIConfigParser:
         return values
 
 
-    def set_property(self, section, property, value):
+    def set_property(self, section, property, value): 
         if section != "DEFAULT" and not self.pki_config.has_section(section):
             self.pki_config.add_section(section)
         self.pki_config.set(section, property, value)
@@ -384,7 +384,7 @@ class PKIConfigParser:
 
             return True
 
-        except ldap.NO_SUCH_OBJECT as e:
+        except ldap.NO_SUCH_OBJECT:
             return False
 
     def ds_close(self):
diff --git a/base/server/src/pkidestroy b/base/server/src/pkidestroy
index 16e2b6654f72f49410132444744fb2255d9dcd44..deca8d586602e5927749523160974f9b04240a53 100755
--- a/base/server/src/pkidestroy
+++ b/base/server/src/pkidestroy
@@ -121,7 +121,7 @@ def main(argv):
         help='security domain password file path')
                                  
 
-    args = parser.process_command_line_arguments(argv)
+    args = parser.process_command_line_arguments()
 
     interactive = False
 
diff --git a/base/server/src/pkispawn b/base/server/src/pkispawn
index 78726ea709ecb4266c1229d43a4c1445585db199..75a04b4a6e498ade6910b9487403ec1fbd95811a 100755
--- a/base/server/src/pkispawn
+++ b/base/server/src/pkispawn
@@ -112,7 +112,7 @@ def main(argv):
         help='configuration filename '
             '(MUST specify complete path)')
 
-    args = parser.process_command_line_arguments(argv)
+    args = parser.process_command_line_arguments()
 
     config.default_deployment_cfg = config.PKI_DEPLOYMENT_DEFAULT_CONFIGURATION_FILE
 
diff --git a/base/server/src/scriptlets/initialization.py b/base/server/src/scriptlets/initialization.py
index 80b28a6635c44b6cdb30932106fd317cb997a69b..41e5752029cbe04112ca6c2498820002786bfcaa 100644
--- a/base/server/src/scriptlets/initialization.py
+++ b/base/server/src/scriptlets/initialization.py
@@ -48,7 +48,7 @@ class PkiScriptlet(pkiscriptlet.AbstractBasePkiScriptlet):
                 # verify that this type of "subsystem" currently EXISTS
                 # for this "instance" (External CA Step 2)
                 deployer.instance.verify_subsystem_exists()
-                deployer.master_dict['pki_skip_installation'] = "True";
+                deployer.master_dict['pki_skip_installation'] = "True"
             else:
                 # verify that this type of "subsystem" does NOT yet
                 # exist for this "instance"
diff --git a/base/server/src/scriptlets/selinux_setup.py b/base/server/src/scriptlets/selinux_setup.py
index 1f3d386166056f810ebc17b2e0b07d8a89b14346..5e3a5ab0d2e44078cd2a72bfca0d0a36f99219b4 100644
--- a/base/server/src/scriptlets/selinux_setup.py
+++ b/base/server/src/scriptlets/selinux_setup.py
@@ -137,19 +137,19 @@ class PkiScriptlet(pkiscriptlet.AbstractBasePkiScriptlet):
                             extra=config.PKI_INDENTATION_LEVEL_1)
 
         # check first if any transactions are required
-        if len(ports) == 0 and deployer.master_dict['pki_instance_name'] == \
-           config.PKI_DEPLOYMENT_DEFAULT_TOMCAT_INSTANCE_NAME:
-               return self.rv
+        if (len(ports) == 0 and deployer.master_dict['pki_instance_name'] ==
+            config.PKI_DEPLOYMENT_DEFAULT_TOMCAT_INSTANCE_NAME):
+            return self.rv
         # A maximum of 10 tries to delete the SELinux contexts
         counter = 1
         max_tries = 10
         while True:
             try:
                 # remove SELinux contexts when removing the last subsystem
-                if deployer.master_dict['pki_subsystem'] in config.PKI_APACHE_SUBSYSTEMS and\
-                    deployer.instance.apache_instance_subsystems() == 0 or\
-                    deployer.master_dict['pki_subsystem'] in config.PKI_TOMCAT_SUBSYSTEMS and\
-                    len(deployer.instance.tomcat_instance_subsystems()) == 0:
+                if (deployer.master_dict['pki_subsystem'] in config.PKI_APACHE_SUBSYSTEMS and
+                    deployer.instance.apache_instance_subsystems() == 0 or
+                    deployer.master_dict['pki_subsystem'] in config.PKI_TOMCAT_SUBSYSTEMS and
+                    len(deployer.instance.tomcat_instance_subsystems()) == 0):
 
                     trans = seobject.semanageRecords("targeted")
                     trans.start()
@@ -172,7 +172,7 @@ class PkiScriptlet(pkiscriptlet.AbstractBasePkiScriptlet):
                         config.pki_log.info("deleting selinux fcontext \"%s\"",
                                   deployer.master_dict['pki_instance_configuration_path'] + self.suffix,
                                   extra=config.PKI_INDENTATION_LEVEL_2)
-                        fcon.delete(deployer.master_dict['pki_instance_configuration_path'] + \
+                        fcon.delete(deployer.master_dict['pki_instance_configuration_path'] +
                                     self.suffix, "")
 
                         config.pki_log.info("deleting selinux fcontext \"%s\"",
-- 
1.7.10.2

