diff options
-rwxr-xr-x | client/ipa-client-install | 4 | ||||
-rwxr-xr-x | install/tools/ipa-replica-manage | 2 | ||||
-rwxr-xr-x | install/tools/ipactl | 10 | ||||
-rw-r--r-- | ipaclient/ipadiscovery.py | 2 | ||||
-rw-r--r-- | ipalib/cli.py | 4 | ||||
-rw-r--r-- | ipalib/constants.py | 4 | ||||
-rw-r--r-- | ipalib/plugins/dns.py | 4 | ||||
-rw-r--r-- | ipalib/plugins/hbactest.py | 8 | ||||
-rw-r--r-- | ipalib/plugins/stageuser.py | 6 | ||||
-rw-r--r-- | ipalib/plugins/user.py | 2 | ||||
-rw-r--r-- | ipaplatform/base/services.py | 4 | ||||
-rw-r--r-- | ipapython/config.py | 8 | ||||
-rw-r--r-- | ipapython/ipautil.py | 4 | ||||
-rw-r--r-- | ipapython/log_manager.py | 2 | ||||
-rw-r--r-- | ipapython/nsslib.py | 17 | ||||
-rw-r--r-- | ipaserver/install/bindinstance.py | 4 | ||||
-rw-r--r-- | ipaserver/install/certs.py | 2 | ||||
-rw-r--r-- | ipaserver/install/dnskeysyncinstance.py | 2 | ||||
-rw-r--r-- | ipaserver/install/installutils.py | 4 | ||||
-rw-r--r-- | ipaserver/install/krbinstance.py | 6 | ||||
-rw-r--r-- | ipaserver/install/odsexporterinstance.py | 2 | ||||
-rw-r--r-- | ipaserver/install/server/install.py | 2 | ||||
-rw-r--r-- | ipaserver/plugins/dogtag.py | 2 | ||||
-rw-r--r-- | ipatests/test_ipapython/test_ipautil.py | 2 | ||||
-rw-r--r-- | pylintrc | 1 |
25 files changed, 51 insertions, 57 deletions
diff --git a/client/ipa-client-install b/client/ipa-client-install index 82e5c4cb0..884491eb0 100755 --- a/client/ipa-client-install +++ b/client/ipa-client-install @@ -2470,11 +2470,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 0497a0f05..075e4293e 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 d27ada565..fb1e890ea 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 1ba7c1a2d..62c8aef95 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 e1abaa5d5..3592d3b61 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 1ff9ccc7e..021f18cd3 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 1892d29ec..b01ac840f 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 fb0c03389..52cf7539e 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 877e6489b..510b66c43 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 9d82366cb..102f821ce 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 2ec84cdb2..11d0c2a83 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 cbf479a17..0b70d0579 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 95357fa54..392e1f6db 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 a8e7b50f4..3190574cf 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 16aa1d9a4..335ac28f6 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 3d4900e78..f7d5be41e 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 c220ffdb3..76f62751d 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 a5871bad7..4fe566cdd 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 071242654..179909543 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 31149752a..f782068d1 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 f50c21452..e761ebcde 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 b7a38a57c..f01022c4c 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 2549aae3d..e920987cb 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 52f87c7f6..dee82d627 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 @@ -26,7 +26,6 @@ disable= attribute-defined-outside-init, bad-builtin, bad-indentation, - bare-except, broad-except, dangerous-default-value, eval-used, |