Patches attached.
From e7a0809e0e202bd3729f2408fbc9855d9a7f10d4 Mon Sep 17 00:00:00 2001
From: Martin Basti <mba...@redhat.com>
Date: Fri, 11 Mar 2016 19:51:07 +0100
Subject: [PATCH 1/8] pylint: remove bare except

Bare except should not be used.
---
 client/ipa-client-install                |  4 ++--
 install/tools/ipa-replica-manage         |  2 +-
 install/tools/ipactl                     | 10 +++++-----
 ipaclient/ipadiscovery.py                |  2 +-
 ipalib/cli.py                            |  4 ++--
 ipalib/constants.py                      |  4 ++--
 ipalib/plugins/dns.py                    |  4 ++--
 ipalib/plugins/hbactest.py               |  8 ++++----
 ipalib/plugins/stageuser.py              |  6 +++---
 ipalib/plugins/user.py                   |  2 +-
 ipaplatform/base/services.py             |  4 ++--
 ipapython/config.py                      |  8 ++++----
 ipapython/ipautil.py                     |  4 ++--
 ipapython/log_manager.py                 |  2 +-
 ipapython/nsslib.py                      | 17 ++++++-----------
 ipaserver/install/bindinstance.py        |  4 ++--
 ipaserver/install/certs.py               |  2 +-
 ipaserver/install/dnskeysyncinstance.py  |  2 +-
 ipaserver/install/installutils.py        |  4 ++--
 ipaserver/install/krbinstance.py         |  6 +++---
 ipaserver/install/odsexporterinstance.py |  2 +-
 ipaserver/install/server/install.py      |  2 +-
 ipaserver/plugins/dogtag.py              |  2 +-
 ipatests/test_ipapython/test_ipautil.py  |  2 +-
 pylintrc                                 |  1 -
 25 files changed, 51 insertions(+), 57 deletions(-)

diff --git a/client/ipa-client-install b/client/ipa-client-install
index f42d877559365af3d8def3cab9b204cdb5eb919e..06905b1a8124218325db4bfe077da9edd2a87c01 100755
--- a/client/ipa-client-install
+++ b/client/ipa-client-install
@@ -2469,11 +2469,11 @@ def install(options, env, fstore, statestore):
         try:
             socket.inet_pton(socket.AF_INET, srv)
             is_ipaddr = True
-        except:
+        except socket.error:
             try:
                 socket.inet_pton(socket.AF_INET6, srv)
                 is_ipaddr = True
-            except:
+            except socket.error:
                 is_ipaddr = False
 
         if is_ipaddr:
diff --git a/install/tools/ipa-replica-manage b/install/tools/ipa-replica-manage
index 0497a0f0549b392216c654ab67d98cedbf122a4b..075e4293e1285a2bd17717a8ac8d9e42f624b1c0 100755
--- a/install/tools/ipa-replica-manage
+++ b/install/tools/ipa-replica-manage
@@ -597,7 +597,7 @@ def clean_dangling_ruvs(realm, host, options):
             conn = ipaldap.IPAdmin(master_cn, 636, cacert=CACERT)
             conn.do_simple_bind(bindpw=options.dirman_passwd)
             master_info['online'] = True
-        except:
+        except Exception:
             print("The server '{host}' appears to be offline."
                   .format(host=master_cn))
             offlines.add(master_cn)
diff --git a/install/tools/ipactl b/install/tools/ipactl
index d27ada56556c58c42242cf0add11ef47d4440f56..fb1e890ea16af492e1dc4956d40a3fb6287d5837 100755
--- a/install/tools/ipactl
+++ b/install/tools/ipactl
@@ -343,13 +343,13 @@ def ipa_stop(options):
         try:
             print("Stopping %s Service" % svc)
             svchandle.stop(capture_output=False)
-        except:
+        except Exception:
             emit_err("Failed to stop %s Service" % svc)
 
     try:
         print("Stopping Directory Service")
         dirsrv.stop(capture_output=False)
-    except:
+    except Exception:
         raise IpactlError("Failed to stop Directory Service")
 
     # remove file with list of started services
@@ -383,7 +383,7 @@ def ipa_restart(options):
         emit_err("Shutting down")
         try:
             dirsrv.stop(capture_output=False)
-        except:
+        except Exception:
             pass
         if isinstance(e, IpactlError):
             # do not display any other error message
@@ -421,7 +421,7 @@ def ipa_restart(options):
             try:
                 print("Stopping %s Service" % svc)
                 svchandle.stop(capture_output=False)
-            except:
+            except Exception:
                 emit_err("Failed to stop %s Service" % svc)
 
     try:
@@ -521,7 +521,7 @@ def ipa_status(options):
                 print("%s Service: RUNNING" % svc)
             else:
                 print("%s Service: STOPPED" % svc)
-        except:
+        except Exception:
             emit_err("Failed to get %s Service status" % svc)
 
 def main():
diff --git a/ipaclient/ipadiscovery.py b/ipaclient/ipadiscovery.py
index 1ba7c1a2d6ae071543b76812463d114de494c296..62c8aef9563b4cdbaf9454c1a20cc294e6b61704 100644
--- a/ipaclient/ipadiscovery.py
+++ b/ipaclient/ipadiscovery.py
@@ -129,7 +129,7 @@ class IPADiscovery(object):
                 elif line.lower().startswith('search'):
                     domains += [(d, 'search domain from /etc/resolv.conf') for
                         d in line.split()[1:]]
-        except:
+        except Exception:
             pass
         if domain:
             domains = [domain] + domains
diff --git a/ipalib/cli.py b/ipalib/cli.py
index e1abaa5d5dee844b453d049a6baa091c8d517b29..3592d3b61051e904ab4c871bd2c83cd7c57845f2 100644
--- a/ipalib/cli.py
+++ b/ipalib/cli.py
@@ -663,7 +663,7 @@ class textui(backend.Backend):
                 selection = int(resp) - 1
                 if (selection >= 0 and selection < counter):
                     break
-            except:
+            except Exception:
                 # fall through to the error msg
                 pass
 
@@ -907,7 +907,7 @@ class console(frontend.Command):
             try:
                 with script:
                     exec(script, globals(), local)
-            except:
+            except Exception:
                 traceback.print_exc()
                 exit(1)
         else:
diff --git a/ipalib/constants.py b/ipalib/constants.py
index 1ff9ccc7efe0c3be0fc3cf2f21352e89ef94ad6e..021f18cd366b821427bdbfcc5e354d2047ef39b1 100644
--- a/ipalib/constants.py
+++ b/ipalib/constants.py
@@ -28,10 +28,10 @@ from ipapython.version import VERSION, API_VERSION
 
 try:
     FQDN = socket.getfqdn()
-except:
+except Exception:
     try:
         FQDN = socket.gethostname()
-    except:
+    except Exception:
         FQDN = None
 
 # Path to CA certificate bundle
diff --git a/ipalib/plugins/dns.py b/ipalib/plugins/dns.py
index 1892d29ec9f87d3b3f955ff8df6b154961fbce36..b01ac840fb930ad21dcb50370cc61e23daf3a188 100644
--- a/ipalib/plugins/dns.py
+++ b/ipalib/plugins/dns.py
@@ -443,7 +443,7 @@ def _normalize_bind_aci(bind_acis):
                 netmask = ""
             normalized.append(u"%s%s%s" % (prefix, str(ip), netmask))
             continue
-        except:
+        except Exception:
             normalized.append(bind_aci)
             continue
 
@@ -4030,7 +4030,7 @@ class dnsrecord_del(LDAPUpdate):
                     try:
                         param = self.params[attr]
                         attr_name = unicode(param.label or param.name)
-                    except:
+                    except Exception:
                         attr_name = attr
                     raise errors.AttrValueNotFound(attr=attr_name, value=val)
             entry_attrs[attr] = list(set(old_entry[attr]))
diff --git a/ipalib/plugins/hbactest.py b/ipalib/plugins/hbactest.py
index fb0c03389e18780847a3e186596a45ac59ec160d..52cf7539e4bb13df5081c74001bfba604063271c 100644
--- a/ipalib/plugins/hbactest.py
+++ b/ipalib/plugins/hbactest.py
@@ -343,7 +343,7 @@ class hbactest(Command):
             for rule in testrules:
                 try:
                     hbacset.append(self.api.Command.hbacrule_show(rule)['result'])
-                except:
+                except Exception:
                     pass
 
         # We have some rules, import them
@@ -426,7 +426,7 @@ class hbactest(Command):
                     if 'memberofindirect_group' in search_result:
                         groups += search_result['memberofindirect_group']
                     request.user.groups = sorted(set(groups))
-                except:
+                except Exception:
                     pass
 
         if options['service'] != u'all':
@@ -435,7 +435,7 @@ class hbactest(Command):
                 service_result = self.api.Command.hbacsvc_show(request.service.name)['result']
                 if 'memberof_hbacsvcgroup' in service_result:
                     request.service.groups = service_result['memberof_hbacsvcgroup']
-            except:
+            except Exception:
                 pass
 
         if options['targethost'] != u'all':
@@ -446,7 +446,7 @@ class hbactest(Command):
                 if 'memberofindirect_hostgroup' in tgthost_result:
                     groups += tgthost_result['memberofindirect_hostgroup']
                 request.targethost.groups = sorted(set(groups))
-            except:
+            except Exception:
                 pass
 
         matched_rules = []
diff --git a/ipalib/plugins/stageuser.py b/ipalib/plugins/stageuser.py
index 877e6489b1a3a0129875cf0b441f456c1ffaef7e..510b66c43ef3d3b4bbd99637814809c75e15d450 100644
--- a/ipalib/plugins/stageuser.py
+++ b/ipalib/plugins/stageuser.py
@@ -565,7 +565,7 @@ class stageuser_activate(LDAPQuery):
                     try:
                         v.decode('utf-8')
                         self.log.debug("merge: %s:%r wiped" % (attr, v))
-                    except:
+                    except ValueError:
                         self.log.debug("merge %s: [no_print %s]" % (attr, v.__class__.__name__))
                     if isinstance(entry_to[attr], (list, tuple)):
                         # multi value attribute
@@ -581,7 +581,7 @@ class stageuser_activate(LDAPQuery):
                     try:
                         v.decode('utf-8')
                         self.log.debug("Add: %s:%r" % (attr, v))
-                    except:
+                    except ValueError:
                         self.log.debug("Add %s: [no_print %s]" % (attr, v.__class__.__name__))
 
                     if isinstance(entry_to[attr], (list, tuple)):
@@ -692,7 +692,7 @@ class stageuser_activate(LDAPQuery):
             try:
                 self.log.error("Fail to delete the Staging user after activating it %s " % (staging_dn))
                 self._exc_wrapper(args, options, ldap.delete_entry)(active_dn)
-            except:
+            except Exception:
                 self.log.error("Fail to cleanup activation. The user remains active %s" % (active_dn))
             raise
 
diff --git a/ipalib/plugins/user.py b/ipalib/plugins/user.py
index 9d82366cb0bd1d126f495d058fa9c031e203fc4e..102f821ceefac854c896d2a28d1cb7a4246660d2 100644
--- a/ipalib/plugins/user.py
+++ b/ipalib/plugins/user.py
@@ -731,7 +731,7 @@ class user_del(baseuser_del):
                 try:
                     self._preserve_user(pkey, delete_container, **options)
                     preserved.append(pkey_to_value(pkey, options))
-                except:
+                except Exception:
                     if not options.get('continue', False):
                         raise
                     failed.append(pkey_to_value(pkey, options))
diff --git a/ipaplatform/base/services.py b/ipaplatform/base/services.py
index 2ec84cdb21607cb51df6ad5fcd2ae515898bee44..11d0c2a838ee0c7d2fdb397df130cdf6656914f1 100644
--- a/ipaplatform/base/services.py
+++ b/ipaplatform/base/services.py
@@ -434,7 +434,7 @@ class SystemdService(PlatformService):
                         os.unlink(srv_lnk)
                         os.symlink(self.lib_path, srv_lnk)
                 ipautil.run([paths.SYSTEMCTL, "--system", "daemon-reload"])
-            except:
+            except Exception:
                 pass
         else:
             self.__enable(instance_name)
@@ -457,7 +457,7 @@ class SystemdService(PlatformService):
                     if os.path.islink(srv_lnk):
                         os.unlink(srv_lnk)
                 ipautil.run([paths.SYSTEMCTL, "--system", "daemon-reload"])
-            except:
+            except Exception:
                 pass
         else:
             try:
diff --git a/ipapython/config.py b/ipapython/config.py
index cbf479a177d61bc84ce8156165448a02bbc20585..0b70d057955f647acd6164895daa15ee96019d54 100644
--- a/ipapython/config.py
+++ b/ipapython/config.py
@@ -160,19 +160,19 @@ def __parse_config(discover_server = True):
     try:
         if not config.default_realm:
             config.default_realm = p.get("global", "realm")
-    except:
+    except AttributeError:
         pass
     if discover_server:
         try:
             s = p.get("global", "xmlrpc_uri")
             server = urlsplit(s)
             config.default_server.append(server.netloc)
-        except:
+        except Exception:
             pass
     try:
         if not config.default_domain:
             config.default_domain = p.get("global", "domain")
-    except:
+    except AttributeError:
         pass
 
 def __discover_config(discover_server = True):
@@ -218,7 +218,7 @@ def __discover_config(discover_server = True):
                 hostname = str(server.target).rstrip(".")
                 config.default_server.append(hostname)
 
-    except:
+    except Exception:
         pass
 
 def add_standard_options(parser):
diff --git a/ipapython/ipautil.py b/ipapython/ipautil.py
index 95357fa54ecf7f836e07de4a4322a9040c57c87e..392e1f6db5af4b5fe7437c045ed3fc07e2988c30 100644
--- a/ipapython/ipautil.py
+++ b/ipapython/ipautil.py
@@ -505,7 +505,7 @@ def file_exists(filename):
             return True
         else:
             return False
-    except:
+    except Exception:
         return False
 
 def dir_exists(filename):
@@ -515,7 +515,7 @@ def dir_exists(filename):
             return True
         else:
             return False
-    except:
+    except Exception:
         return False
 
 def install_file(fname, dest):
diff --git a/ipapython/log_manager.py b/ipapython/log_manager.py
index a8e7b50f4c70b3163f279d627876596faafbb71d..3190574cf729568e7f8b78bb0449faffe83914fd 100644
--- a/ipapython/log_manager.py
+++ b/ipapython/log_manager.py
@@ -606,7 +606,7 @@ def parse_log_level(level):
     if isinstance(level, six.string_types):
         try:
             level = int(level)
-        except:
+        except ValueError:
             pass
 
     # If it's a string lookup it's name and map to logging level
diff --git a/ipapython/nsslib.py b/ipapython/nsslib.py
index 16aa1d9a4a89f214d2ae3ff06a7178be52309f44..335ac28f6491e271f762055b7449f09f2970afb5 100644
--- a/ipapython/nsslib.py
+++ b/ipapython/nsslib.py
@@ -223,17 +223,12 @@ class NSSConnection(httplib.HTTPConnection, NSSAddressFamilyFallback):
         self.tls_version_max = str(tls_version_max)
 
     def _create_socket(self):
-        # TODO: remove the try block once python-nss is guaranteed to contain
-        # these values
-        try:
-            #pylint: disable=E1101
-            ssl_enable_renegotiation  = ssl.SSL_ENABLE_RENEGOTIATION
-            ssl_require_safe_negotiation = ssl.SSL_REQUIRE_SAFE_NEGOTIATION
-            ssl_renegotiate_requires_xtn = ssl.SSL_RENEGOTIATE_REQUIRES_XTN
-        except:
-            ssl_enable_renegotiation  = 20
-            ssl_require_safe_negotiation = 21
-            ssl_renegotiate_requires_xtn = 2
+        ssl_enable_renegotiation = getattr(
+            ssl, 'SSL_ENABLE_RENEGOTIATION', 20)
+        ssl_require_safe_negotiation = getattr(
+            ssl,'SSL_REQUIRE_SAFE_NEGOTIATION', 21)
+        ssl_renegotiate_requires_xtn = getattr(
+            ssl, 'SSL_RENEGOTIATE_REQUIRES_XTN', 2)
 
         # Create the socket here so we can do things like let the caller
         # override the NSS callbacks
diff --git a/ipaserver/install/bindinstance.py b/ipaserver/install/bindinstance.py
index 3d4900e78c361d47af08af6e6fb0a41d7931507d..f7d5be41e303d22510e40ab7989a6f9ebdf0bcfb 100644
--- a/ipaserver/install/bindinstance.py
+++ b/ipaserver/install/bindinstance.py
@@ -571,7 +571,7 @@ class DnsBackup(object):
                     try:
                         delkw = { '%srecord' % str(type.lower()) : unicode(rdata) }
                         api.Command.dnsrecord_del(unicode(zone), unicode(host), **delkw)
-                    except:
+                    except Exception:
                         pass
                 j += 1
 
@@ -662,7 +662,7 @@ class BindInstance(service.Service):
 
         try:
             self.stop()
-        except:
+        except Exception:
             pass
 
         # get a connection to the DS
diff --git a/ipaserver/install/certs.py b/ipaserver/install/certs.py
index c220ffdb3fea957bafc8d180da9c8c73d0cc2813..76f62751db8abbb27ca5849bcb09c5b5540e2cda 100644
--- a/ipaserver/install/certs.py
+++ b/ipaserver/install/certs.py
@@ -127,7 +127,7 @@ class CertDB(object):
             shutil.rmtree(self.reqdir, ignore_errors=True)
         try:
             os.chdir(self.cwd)
-        except:
+        except OSError:
             pass
 
     def setup_cert_request(self):
diff --git a/ipaserver/install/dnskeysyncinstance.py b/ipaserver/install/dnskeysyncinstance.py
index a5871bad7a9a4e39519a680d223af4f10161587a..4fe566cdd08dc1dda1c93178cb04e92cd2be7d82 100644
--- a/ipaserver/install/dnskeysyncinstance.py
+++ b/ipaserver/install/dnskeysyncinstance.py
@@ -122,7 +122,7 @@ class DNSKeySyncInstance(service.Service):
         self.suffix = ipautil.realm_to_suffix(self.realm)
         try:
             self.stop()
-        except:
+        except Exception:
             pass
 
         # get a connection to the DS
diff --git a/ipaserver/install/installutils.py b/ipaserver/install/installutils.py
index 07124265470071f89a549edaaebb01339d8f3a8d..179909543e8791ff2a85b6bf4ce57dee8d00508b 100644
--- a/ipaserver/install/installutils.py
+++ b/ipaserver/install/installutils.py
@@ -120,10 +120,10 @@ def get_fqdn():
     fqdn = ""
     try:
         fqdn = socket.getfqdn()
-    except:
+    except Exception:
         try:
             fqdn = socket.gethostname()
-        except:
+        except Exception:
             fqdn = ""
     return fqdn
 
diff --git a/ipaserver/install/krbinstance.py b/ipaserver/install/krbinstance.py
index 31149752a1eab62ce142ac9614309a1d0a098754..f782068d1d471ea8275574af0e7719d48c402c8d 100644
--- a/ipaserver/install/krbinstance.py
+++ b/ipaserver/install/krbinstance.py
@@ -135,7 +135,7 @@ class KrbInstance(service.Service):
         self.backup_state("running", self.is_running())
         try:
             self.stop()
-        except:
+        except Exception:
             # It could have been not running
             pass
 
@@ -210,7 +210,7 @@ class KrbInstance(service.Service):
     def __start_instance(self):
         try:
             self.start()
-        except:
+        except Exception:
             root_logger.critical("krb5kdc service failed to start")
 
     def __setup_sub_dict(self):
@@ -386,7 +386,7 @@ class KrbInstance(service.Service):
 
         try:
             self.stop()
-        except:
+        except Exception:
             pass
 
         for f in [paths.KRB5KDC_KDC_CONF, paths.KRB5_CONF]:
diff --git a/ipaserver/install/odsexporterinstance.py b/ipaserver/install/odsexporterinstance.py
index f50c21452b54f401332b00bc5583bfea03857638..e761ebcdeda4ffdc445d1db4c8215ca43b69551c 100644
--- a/ipaserver/install/odsexporterinstance.py
+++ b/ipaserver/install/odsexporterinstance.py
@@ -50,7 +50,7 @@ class ODSExporterInstance(service.Service):
 
         try:
             self.stop()
-        except:
+        except Exception:
             pass
 
         # get a connection to the DS
diff --git a/ipaserver/install/server/install.py b/ipaserver/install/server/install.py
index b7a38a57c0f4fa7a38605585e663e767de8b0fee..f01022c4c3a056513db47f70727aa48157a8c6f2 100644
--- a/ipaserver/install/server/install.py
+++ b/ipaserver/install/server/install.py
@@ -286,7 +286,7 @@ def common_cleanup(func):
                 # what is the state of the environment
                 try:
                     installer._fstore.restore_file(paths.HOSTS)
-                except:
+                except Exception:
                     pass
 
     return decorated
diff --git a/ipaserver/plugins/dogtag.py b/ipaserver/plugins/dogtag.py
index 2549aae3d7d99364cc78f44bd96897e3738ef00d..e920987cb5137018e1ace05b1d53565d6ef1a045 100644
--- a/ipaserver/plugins/dogtag.py
+++ b/ipaserver/plugins/dogtag.py
@@ -1978,7 +1978,7 @@ class RestClient(Backend):
     def _parse_dogtag_error(body):
         try:
             return pki.PKIException.from_json(json.loads(body))
-        except:
+        except Exception:
             return None
 
     def __init__(self, api):
diff --git a/ipatests/test_ipapython/test_ipautil.py b/ipatests/test_ipapython/test_ipautil.py
index 52f87c7f66338063fd5cd32706409b8bc9bfae78..dee82d6275901eebdb291b384ea7111df9057e69 100644
--- a/ipatests/test_ipapython/test_ipautil.py
+++ b/ipatests/test_ipapython/test_ipautil.py
@@ -38,7 +38,7 @@ def make_ipaddress_checker(addr, words=None, prefixlen=None):
         try:
             ip = ipautil.CheckedIPAddress(addr, match_local=False)
             assert ip.words == words and ip.prefixlen == prefixlen
-        except:
+        except Exception:
             assert words is None and prefixlen is None
     check_ipaddress.description = "Test IP address parsing and verification (%s)" % addr
     return check_ipaddress
diff --git a/pylintrc b/pylintrc
index 2a4dd7b09ef8b7ab052fc12e382c88a7af2ed568..871be6cb6f657a0ce1c34a55444d8b8fe30e5495 100644
--- a/pylintrc
+++ b/pylintrc
@@ -26,7 +26,6 @@ disable=
     attribute-defined-outside-init,
     bad-builtin,
     bad-indentation,
-    bare-except,
     broad-except,
     dangerous-default-value,
     eval-used,
-- 
2.5.0

From b706e7727731233b74b71ae07793c2a4a5a44ec3 Mon Sep 17 00:00:00 2001
From: Martin Basti <mba...@redhat.com>
Date: Thu, 17 Mar 2016 18:40:04 +0100
Subject: [PATCH 2/8] Pylint: fix definition of global variables

Global variables should be defined in the outer space, not just marked
as global inside functions.

Removes unused global variables
---
 client/ipa-client-install         | 11 +++++------
 install/tools/ipa-adtrust-install |  1 -
 ipaserver/install/ca.py           |  3 +++
 pylintrc                          |  1 -
 4 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/client/ipa-client-install b/client/ipa-client-install
index 06905b1a8124218325db4bfe077da9edd2a87c01..210fdd1e99586df06e2409862d2d5e804bc1427a 100755
--- a/client/ipa-client-install
+++ b/client/ipa-client-install
@@ -74,6 +74,11 @@ CLIENT_NOT_CONFIGURED = 2
 CLIENT_ALREADY_CONFIGURED = 3
 CLIENT_UNINSTALL_ERROR = 4 # error after restoring files/state
 
+
+fstore = sysrestore.FileStore(paths.IPA_CLIENT_SYSRESTORE)
+statestore = sysrestore.StateFile(paths.IPA_CLIENT_SYSRESTORE)
+
+
 def parse_options():
     def validate_ca_cert_file_option(option, opt, value, parser):
         if not os.path.exists(value):
@@ -3067,12 +3072,6 @@ def main():
 
     env={"PATH":"/bin:/sbin:/usr/kerberos/bin:/usr/kerberos/sbin:/usr/bin:/usr/sbin"}
 
-    global fstore
-    fstore = sysrestore.FileStore(paths.IPA_CLIENT_SYSRESTORE)
-
-    global statestore
-    statestore = sysrestore.StateFile(paths.IPA_CLIENT_SYSRESTORE)
-
     if options.uninstall:
         return uninstall(options, env)
 
diff --git a/install/tools/ipa-adtrust-install b/install/tools/ipa-adtrust-install
index f972835ec89c18d0453e659142d4434aaa571dd5..36caa5c2d429c6cf107df03e82aa80e15d8efe01 100755
--- a/install/tools/ipa-adtrust-install
+++ b/install/tools/ipa-adtrust-install
@@ -238,7 +238,6 @@ def main():
 
     check_server_configuration()
 
-    global fstore
     fstore = sysrestore.FileStore(paths.SYSRESTORE)
 
     print("==============================================================================")
diff --git a/ipaserver/install/ca.py b/ipaserver/install/ca.py
index 8420a8ddfc2ddb118adf4685a046a33e3dc8b594..acc54334e1b6e64a0b2d4b097e7464c95988f3f5 100644
--- a/ipaserver/install/ca.py
+++ b/ipaserver/install/ca.py
@@ -16,6 +16,9 @@ from ipalib import api, certstore, x509
 from ipapython.dn import DN
 from ipapython.ipa_log_manager import root_logger
 
+external_cert_file = None
+external_ca_file = None
+
 
 def install_check(standalone, replica_config, options):
     global external_cert_file
diff --git a/pylintrc b/pylintrc
index 871be6cb6f657a0ce1c34a55444d8b8fe30e5495..e1810ebe771fc97c493e09a7ca0d4e51158adb7b 100644
--- a/pylintrc
+++ b/pylintrc
@@ -33,7 +33,6 @@ disable=
     fixme,
     global-statement,
     global-variable-not-assigned,
-    global-variable-undefined,
     no-init,
     pointless-except,
     pointless-statement,
-- 
2.5.0

From 3dc6768a7a95d5c2e20b8a828b2ecf30a4c5cc21 Mon Sep 17 00:00:00 2001
From: Martin Basti <mba...@redhat.com>
Date: Thu, 17 Mar 2016 18:49:10 +0100
Subject: [PATCH 3/8] Pylint: enable pointless-except check

This check can be enabled, there is no errors in current code, and it
should stay in that way.
---
 pylintrc | 1 -
 1 file changed, 1 deletion(-)

diff --git a/pylintrc b/pylintrc
index e1810ebe771fc97c493e09a7ca0d4e51158adb7b..e3fafa331fa9efc24d067820fa88b165b3d4570f 100644
--- a/pylintrc
+++ b/pylintrc
@@ -34,7 +34,6 @@ disable=
     global-statement,
     global-variable-not-assigned,
     no-init,
-    pointless-except,
     pointless-statement,
     pointless-string-statement,
     protected-access,
-- 
2.5.0

From e29af092f7b0bbaff08ffcf038c5914850e431bb Mon Sep 17 00:00:00 2001
From: Martin Basti <mba...@redhat.com>
Date: Thu, 17 Mar 2016 19:38:53 +0100
Subject: [PATCH 4/8] Pylint: enable reimported check

Fixes current reimports and enables pylint check for them
---
 ipalib/session.py                       | 2 +-
 ipalib/x509.py                          | 1 -
 ipaserver/install/ipa_backup.py         | 1 -
 ipaserver/install/opendnssecinstance.py | 3 +--
 ipaserver/plugins/dogtag.py             | 3 +--
 ipatests/test_ipalib/test_x509.py       | 2 --
 ipatests/test_ipapython/test_ipautil.py | 2 --
 pylintrc                                | 1 -
 8 files changed, 3 insertions(+), 12 deletions(-)

diff --git a/ipalib/session.py b/ipalib/session.py
index 44c29fe51a3893894dd0a7f98546bd0fad19af73..e84a355d7a0f04b29824fc5dfec872b2155dea63 100644
--- a/ipalib/session.py
+++ b/ipalib/session.py
@@ -27,7 +27,7 @@ from six.moves.urllib.parse import urlparse
 from ipalib import errors
 from ipalib.text import _
 from ipapython.ipa_log_manager import root_logger, log_mgr
-from ipalib import api, errors
+from ipalib import api
 from ipaplatform.paths import paths
 from ipalib.krb_utils import (
     krb5_parse_ccache,
diff --git a/ipalib/x509.py b/ipalib/x509.py
index 2edd3fef2f89fa8956359eeb99b4c7ae3bd65775..7903441c550eea74a99595026918f3f0b7d35851 100644
--- a/ipalib/x509.py
+++ b/ipalib/x509.py
@@ -404,7 +404,6 @@ if __name__ == '__main__':
     # this can be run with:
     # python ipalib/x509.py < /etc/ipa/ca.crt
 
-    from ipalib import api
     api.bootstrap()
     api.finalize()
 
diff --git a/ipaserver/install/ipa_backup.py b/ipaserver/install/ipa_backup.py
index ae387ad8d143f779c5a6095ed089c12d936ddc94..3e765b9ae1260bab06672ab05d57297ac4ff788a 100644
--- a/ipaserver/install/ipa_backup.py
+++ b/ipaserver/install/ipa_backup.py
@@ -38,7 +38,6 @@ from ipaserver.install import installutils
 from ipapython import ipaldap
 from ipalib.session import ISO8601_DATETIME_FMT
 from ipalib.constants import CACERT
-from six.moves.configparser import SafeConfigParser
 from ipaplatform.tasks import tasks
 
 """
diff --git a/ipaserver/install/opendnssecinstance.py b/ipaserver/install/opendnssecinstance.py
index c7a796e8e03a13dec244a4926e9fba60468ce606..05b2013c812109e1ee7c5fb0f580c3ab863a2fc6 100644
--- a/ipaserver/install/opendnssecinstance.py
+++ b/ipaserver/install/opendnssecinstance.py
@@ -9,7 +9,6 @@ import stat
 import shutil
 from subprocess import CalledProcessError
 
-from ipapython import p11helper as _ipap11helper
 from ipaserver.install import service
 from ipaserver.install import installutils
 from ipapython.ipa_log_manager import root_logger
@@ -245,7 +244,7 @@ class OpenDNSSECInstance(service.Service):
             pin = f.read()
 
         os.environ["SOFTHSM2_CONF"] = paths.DNSSEC_SOFTHSM2_CONF
-        p11 = _ipap11helper.P11_Helper(softhsm_slot, pin, paths.LIBSOFTHSM2_SO)
+        p11 = p11helper.P11_Helper(softhsm_slot, pin, paths.LIBSOFTHSM2_SO)
         try:
             # generate master key
             root_logger.debug("Creating master key")
diff --git a/ipaserver/plugins/dogtag.py b/ipaserver/plugins/dogtag.py
index e920987cb5137018e1ace05b1d53565d6ef1a045..5e358d231e9ab65a01530555497174f8a0743b1f 100644
--- a/ipaserver/plugins/dogtag.py
+++ b/ipaserver/plugins/dogtag.py
@@ -253,7 +253,7 @@ from six.moves import urllib
 from ipalib import Backend
 from ipapython.dn import DN
 import ipapython.cookie
-import ipapython.dogtag
+from ipapython import dogtag
 from ipapython import ipautil
 
 if six.PY3:
@@ -1276,7 +1276,6 @@ import os, random
 from ipaserver.plugins import rabase
 from ipalib.constants import TYPE_ERROR
 from ipalib.util import cachedproperty
-from ipapython import dogtag
 from ipalib import _
 from ipaplatform.paths import paths
 
diff --git a/ipatests/test_ipalib/test_x509.py b/ipatests/test_ipalib/test_x509.py
index 28745ffd815a93c718fb34f3855f617e4cfc7e6d..32d0e8561cede4f5bf19d55102f934ec129e0850 100644
--- a/ipatests/test_ipalib/test_x509.py
+++ b/ipatests/test_ipalib/test_x509.py
@@ -29,8 +29,6 @@ from nss.error import NSPRError
 from ipalib import x509
 from ipapython.dn import DN
 
-import pytest
-
 pytestmark = pytest.mark.tier0
 
 # certutil -
diff --git a/ipatests/test_ipapython/test_ipautil.py b/ipatests/test_ipapython/test_ipautil.py
index dee82d6275901eebdb291b384ea7111df9057e69..8c0b9c43469bd0653b2f37e2f0bcd84daac7a430 100644
--- a/ipatests/test_ipapython/test_ipautil.py
+++ b/ipatests/test_ipapython/test_ipautil.py
@@ -28,8 +28,6 @@ import six
 
 from ipapython import ipautil
 
-import pytest
-
 pytestmark = pytest.mark.tier0
 
 
diff --git a/pylintrc b/pylintrc
index e3fafa331fa9efc24d067820fa88b165b3d4570f..e469128f4062d159f09bd230a6d585ec4021df25 100644
--- a/pylintrc
+++ b/pylintrc
@@ -40,7 +40,6 @@ disable=
     redefine-in-handler,
     redefined-builtin,
     redefined-outer-name,
-    reimported,
     relative-import,
     super-init-not-called,
     undefined-loop-variable,
-- 
2.5.0

From 45d860aa3e8f7e006af48438f8a50a526208bf19 Mon Sep 17 00:00:00 2001
From: Martin Basti <mba...@redhat.com>
Date: Sun, 20 Mar 2016 20:54:26 +0100
Subject: [PATCH 5/8] Pylint: use list comprehension instead of iteration

Iteration over indexes without calling enumeration fuction is not pythonic and should not be used.
In this case iteration can be replaced by list comprehension.  Fixing this allows to enable
pylint consider-using-enumerate check.
---
 ipaserver/dcerpc.py | 5 +----
 pylintrc            | 1 -
 2 files changed, 1 insertion(+), 5 deletions(-)

diff --git a/ipaserver/dcerpc.py b/ipaserver/dcerpc.py
index 6b62b5feab41801fbef2fe17b142440046706a61..a93e8ddb2a199f7344c4ba2ba4e1b342126dfc77 100644
--- a/ipaserver/dcerpc.py
+++ b/ipaserver/dcerpc.py
@@ -784,11 +784,8 @@ class DomainValidator(object):
         return info
 
 def string_to_array(what):
-    blob = [0] * len(what)
+    return [ord(v) for v in what]
 
-    for i in range(len(what)):
-        blob[i] = ord(what[i])
-    return blob
 
 class TrustDomainInstance(object):
 
diff --git a/pylintrc b/pylintrc
index e469128f4062d159f09bd230a6d585ec4021df25..d75ca13de95c68ada826de0f6597c117455339d1 100644
--- a/pylintrc
+++ b/pylintrc
@@ -72,7 +72,6 @@ disable=
     not-an-iterable,
     singleton-comparison,
     misplaced-comparison-constant,
-    consider-using-enumerate,
     unneeded-not,
     not-a-mapping,
     singleton-comparison
-- 
2.5.0

From b4b9cded38af7e5ce978ccaf1ebb1f210cc2fdfc Mon Sep 17 00:00:00 2001
From: Martin Basti <mba...@redhat.com>
Date: Sun, 20 Mar 2016 21:21:10 +0100
Subject: [PATCH 6/8] Pylint: import max one module per line

---
 install/oddjob/com.redhat.idm.trust-fetch-domains | 3 ++-
 ipalib/plugins/trust.py                           | 3 ++-
 ipapython/ipautil.py                              | 3 ++-
 ipaserver/dcerpc.py                               | 3 ++-
 ipaserver/install/service.py                      | 3 ++-
 ipaserver/plugins/dogtag.py                       | 3 ++-
 pylintrc                                          | 1 -
 7 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/install/oddjob/com.redhat.idm.trust-fetch-domains b/install/oddjob/com.redhat.idm.trust-fetch-domains
index ea82e086ef5bade9be3b9f30ae50504c4fcd5db7..6e8bfc6c8d589605a942518a48027ac2caa26c9e 100755
--- a/install/oddjob/com.redhat.idm.trust-fetch-domains
+++ b/install/oddjob/com.redhat.idm.trust-fetch-domains
@@ -9,7 +9,8 @@ from ipalib.config import Env
 from ipalib.constants import DEFAULT_CONFIG
 from ipapython.ipautil import kinit_keytab
 import sys
-import os, pwd
+import os
+import pwd
 
 import six
 import gssapi
diff --git a/ipalib/plugins/trust.py b/ipalib/plugins/trust.py
index 7d815fd6118586a4a75a1eeff7457103fe4c331c..6d6ac6096bd1d337bf294fac886ebc5d7a176e18 100644
--- a/ipalib/plugins/trust.py
+++ b/ipalib/plugins/trust.py
@@ -64,7 +64,8 @@ if api.env.in_server and api.env.context in ['lite', 'server']:
     try:
         import ipaserver.dcerpc #pylint: disable=F0401
         from ipaserver.dcerpc import TRUST_ONEWAY, TRUST_BIDIRECTIONAL
-        import dbus, dbus.mainloop.glib
+        import dbus
+        import dbus.mainloop.glib
         _bindings_installed = True
     except ImportError:
         _bindings_installed = False
diff --git a/ipapython/ipautil.py b/ipapython/ipautil.py
index 392e1f6db5af4b5fe7437c045ed3fc07e2988c30..d705c51f8d1937ffe57e52cce4b590951653c37b 100644
--- a/ipapython/ipautil.py
+++ b/ipapython/ipautil.py
@@ -23,7 +23,8 @@ import string
 import tempfile
 import subprocess
 import random
-import os, sys
+import os
+import sys
 import copy
 import stat
 import shutil
diff --git a/ipaserver/dcerpc.py b/ipaserver/dcerpc.py
index a93e8ddb2a199f7344c4ba2ba4e1b342126dfc77..25ffbfaea87ef6acbd0c16fcb31f566984a987ca 100644
--- a/ipaserver/dcerpc.py
+++ b/ipaserver/dcerpc.py
@@ -33,7 +33,8 @@ from ipapython.dn import DN
 from ipaserver.install import installutils
 from ipalib.util import normalize_name
 
-import os, struct
+import os
+import struct
 from samba import param
 from samba import credentials
 from samba.dcerpc import security, lsa, drsblobs, nbt, netlogon
diff --git a/ipaserver/install/service.py b/ipaserver/install/service.py
index 636c3cdd1bb718157e553757dfd4a046ab87f6a7..40767acd57d5e1fa8126144ca64f6951848ce214 100644
--- a/ipaserver/install/service.py
+++ b/ipaserver/install/service.py
@@ -18,7 +18,8 @@
 #
 
 import sys
-import os, socket
+import os
+import socket
 import tempfile
 import datetime
 import traceback
diff --git a/ipaserver/plugins/dogtag.py b/ipaserver/plugins/dogtag.py
index 5e358d231e9ab65a01530555497174f8a0743b1f..3e5a07de4f653b77027320926efbce384a8eb999 100644
--- a/ipaserver/plugins/dogtag.py
+++ b/ipaserver/plugins/dogtag.py
@@ -1272,7 +1272,8 @@ from ipalib import api, errors, SkipPluginModule
 if api.env.ra_plugin != 'dogtag':
     # In this case, abort loading this plugin module...
     raise SkipPluginModule(reason='dogtag not selected as RA plugin')
-import os, random
+import os
+import random
 from ipaserver.plugins import rabase
 from ipalib.constants import TYPE_ERROR
 from ipalib.util import cachedproperty
diff --git a/pylintrc b/pylintrc
index d75ca13de95c68ada826de0f6597c117455339d1..611df901d07373318b901a7ce5523561034cea2a 100644
--- a/pylintrc
+++ b/pylintrc
@@ -57,7 +57,6 @@ disable=
     invalid-name,
     line-too-long,
     missing-docstring,
-    multiple-imports,
     multiple-statements,
     old-style-class,
     superfluous-parens,
-- 
2.5.0

From a5b373d54c0d8a33ff149ba04e00e31bab0c6e8e Mon Sep 17 00:00:00 2001
From: Martin Basti <mba...@redhat.com>
Date: Sun, 20 Mar 2016 21:32:27 +0100
Subject: [PATCH 7/8] Pylint: remove unnecessary-semicolon

---
 ipalib/plugins/aci.py                   | 4 ++--
 ipalib/session.py                       | 2 +-
 ipapython/nsslib.py                     | 2 +-
 ipaserver/rpcserver.py                  | 2 +-
 ipatests/test_webui/test_automember.py  | 4 ++--
 ipatests/test_xmlrpc/test_dns_plugin.py | 2 +-
 pylintrc                                | 1 -
 7 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/ipalib/plugins/aci.py b/ipalib/plugins/aci.py
index 60dbcee7fa6c111cc97be664628e097939bdf12d..0c46359f90d30bb460e4a2f6abee245b9a46f2e4 100644
--- a/ipalib/plugins/aci.py
+++ b/ipalib/plugins/aci.py
@@ -344,7 +344,7 @@ def _aci_to_kw(ldap, a, test=False, pkey_only=False):
             if _type_map[k] == target:
                 kw['type'] = unicode(k)
                 found = True
-                break;
+                break
         if not found:
             if target.startswith('('):
                 kw['filter'] = unicode(target)
@@ -792,7 +792,7 @@ class aci_find(crud.Search):
                 for k in _type_map.keys():
                     if _type_map[k] == target and kw['type'] == k:
                         found = True
-                        break;
+                        break
                 if not found:
                     try:
                         results.remove(a)
diff --git a/ipalib/session.py b/ipalib/session.py
index e84a355d7a0f04b29824fc5dfec872b2155dea63..35eb554b413b0e5d200a0174b7f290320d325763 100644
--- a/ipalib/session.py
+++ b/ipalib/session.py
@@ -1079,7 +1079,7 @@ class MemcacheSessionManager(SessionManager):
         '''
 
         if not expiration:      # Catch zero unix timestamps
-            expiration = None;
+            expiration = None
 
         cookie = Cookie(self.session_cookie_name, session_id,
                         domain=urlparse(api.env.xmlrpc_uri).netloc,
diff --git a/ipapython/nsslib.py b/ipapython/nsslib.py
index 335ac28f6491e271f762055b7449f09f2970afb5..b5e5b6586f1d38a0eac99d3f34f2b07426c4781d 100644
--- a/ipapython/nsslib.py
+++ b/ipapython/nsslib.py
@@ -252,7 +252,7 @@ class NSSConnection(httplib.HTTPConnection, NSSAddressFamilyFallback):
 
     def password_callback(self, slot, retry, password):
         if not retry and password: return password
-        return getpass.getpass("Enter password for %s: " % slot.token_name);
+        return getpass.getpass("Enter password for %s: " % slot.token_name)
 
     def handshake_callback(self, sock):
         """
diff --git a/ipaserver/rpcserver.py b/ipaserver/rpcserver.py
index 64620b4cc8f36c4dbfdd681267ffbbff85558bf2..14796b978f862b95e81b0fe1eaa3d1e81129a665 100644
--- a/ipaserver/rpcserver.py
+++ b/ipaserver/rpcserver.py
@@ -330,7 +330,7 @@ class WSGIExecutioner(Executioner):
                 lang_reg = lang_reg_w_q.split(';')[0]
                 lang_ = lang_reg.split('-')[0]
                 if '-' in lang_reg:
-                    reg = lang_reg.split('-')[1].upper();
+                    reg = lang_reg.split('-')[1].upper()
                 else:
                     reg = lang_.upper()
                 os.environ['LANG'] = '%s_%s' % (lang_, reg)
diff --git a/ipatests/test_webui/test_automember.py b/ipatests/test_webui/test_automember.py
index 8d07c8c99b133532f45e7f091e3fe484c4fe5d8a..9f3da1e9693ec8f8a924b9e81545161eb2af44c9 100644
--- a/ipatests/test_webui/test_automember.py
+++ b/ipatests/test_webui/test_automember.py
@@ -110,8 +110,8 @@ class test_automember(UI_driver):
         })
 
         # Add hosts
-        self.add_record('host', host_util.get_data("web1", domain));
-        self.add_record('host', host_util.get_data("web2", domain));
+        self.add_record('host', host_util.get_data("web1", domain))
+        self.add_record('host', host_util.get_data("web2", domain))
 
         # Add an automember rule
         self.add_record(
diff --git a/ipatests/test_xmlrpc/test_dns_plugin.py b/ipatests/test_xmlrpc/test_dns_plugin.py
index ee0bc8ea714d9019d8b45633496521dff780e490..eed816048653e4b34e93db6a0b1d9cad72fa2d54 100644
--- a/ipatests/test_xmlrpc/test_dns_plugin.py
+++ b/ipatests/test_xmlrpc/test_dns_plugin.py
@@ -260,7 +260,7 @@ cnamerev_hostname = u'129.128/25.70.16.172.in-addr.arpa.'
 ptr_revzone3 = u'129'
 ptr_revzone3_dnsname = DNSName(ptr_revzone3)
 ptr_revzone3_dn = DN(('idnsname',cnamerev), revzone3_classless2_dn)
-ptr_revzone3_hostname = zone3_ns2;
+ptr_revzone3_hostname = zone3_ns2
 
 relnxname = u'does-not-exist-test'
 absnxname = u'does.not.exist.test.'
diff --git a/pylintrc b/pylintrc
index 611df901d07373318b901a7ce5523561034cea2a..00304e51e09a8dcc68149c226f759c034b4c1520 100644
--- a/pylintrc
+++ b/pylintrc
@@ -44,7 +44,6 @@ disable=
     super-init-not-called,
     undefined-loop-variable,
     unnecessary-lambda,
-    unnecessary-semicolon,
     unused-argument,
     unused-variable,
     useless-else-on-loop,
-- 
2.5.0

From 55532f75c452a515e21b84e44094409ff52ace17 Mon Sep 17 00:00:00 2001
From: Martin Basti <mba...@redhat.com>
Date: Sun, 20 Mar 2016 21:40:23 +0100
Subject: [PATCH 8/8] Pylint: enable invalid-name check

This check can be enabled, there is no errors in current code, and
it should stay in that way.
---
 pylintrc | 1 -
 1 file changed, 1 deletion(-)

diff --git a/pylintrc b/pylintrc
index 00304e51e09a8dcc68149c226f759c034b4c1520..424d76249026a4c549c6d0e08fc9401f3c442491 100644
--- a/pylintrc
+++ b/pylintrc
@@ -18,7 +18,6 @@ enable=
 disable=
     R,
     I,
-    invalid-name,
     import-error,
     abstract-method,
     anomalous-backslash-in-string,
-- 
2.5.0

-- 
Manage your subscription for the Freeipa-devel mailing list:
https://www.redhat.com/mailman/listinfo/freeipa-devel
Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code

Reply via email to