adtrustinstance: Do not use bare except clauses

https://fedorahosted.org/freeipa/ticket/5134

Reviewed-By: Martin Babinsky <mbabinsk@redhat.com>
This commit is contained in:
Tomas Babej 2015-10-27 16:08:10 +01:00
parent fa3ed16760
commit 767b8de012

View File

@ -215,13 +215,13 @@ class ADTRUSTInstance(service.Service):
try: try:
admin_entry = self.admin_conn.get_entry(admin_dn) admin_entry = self.admin_conn.get_entry(admin_dn)
except: except errors.NotFound:
self.print_msg("IPA admin object not found") self.print_msg("IPA admin object not found")
return return
try: try:
admin_group_entry = self.admin_conn.get_entry(admin_group_dn) admin_group_entry = self.admin_conn.get_entry(admin_group_dn)
except: except errors.NotFound:
self.print_msg("IPA admin group object not found") self.print_msg("IPA admin group object not found")
return return
@ -232,7 +232,7 @@ class ADTRUSTInstance(service.Service):
self.admin_conn.modify_s(admin_dn, \ self.admin_conn.modify_s(admin_dn, \
[(ldap.MOD_ADD, "objectclass", self.OBJC_USER), \ [(ldap.MOD_ADD, "objectclass", self.OBJC_USER), \
(ldap.MOD_ADD, self.ATTR_SID, dom_sid + "-500")]) (ldap.MOD_ADD, self.ATTR_SID, dom_sid + "-500")])
except: except Exception:
self.print_msg("Failed to modify IPA admin object") self.print_msg("Failed to modify IPA admin object")
if admin_group_entry.single_value.get(self.ATTR_SID): if admin_group_entry.single_value.get(self.ATTR_SID):
@ -242,7 +242,7 @@ class ADTRUSTInstance(service.Service):
self.admin_conn.modify_s(admin_group_dn, \ self.admin_conn.modify_s(admin_group_dn, \
[(ldap.MOD_ADD, "objectclass", self.OBJC_GROUP), \ [(ldap.MOD_ADD, "objectclass", self.OBJC_GROUP), \
(ldap.MOD_ADD, self.ATTR_SID, dom_sid + "-512")]) (ldap.MOD_ADD, self.ATTR_SID, dom_sid + "-512")])
except: except Exception:
self.print_msg("Failed to modify IPA admin group object") self.print_msg("Failed to modify IPA admin group object")
def __add_default_trust_view(self): def __add_default_trust_view(self):
@ -313,7 +313,7 @@ class ADTRUSTInstance(service.Service):
try: try:
mod = [(ldap.MOD_ADD, self.ATTR_FALLBACK_GROUP, fb_group_dn)] mod = [(ldap.MOD_ADD, self.ATTR_FALLBACK_GROUP, fb_group_dn)]
self.admin_conn.modify_s(self.smb_dom_dn, mod) self.admin_conn.modify_s(self.smb_dom_dn, mod)
except: except Exception:
self.print_msg("Failed to add fallback group to domain object") self.print_msg("Failed to add fallback group to domain object")
def __add_rid_bases(self): def __add_rid_bases(self):
@ -732,7 +732,7 @@ class ADTRUSTInstance(service.Service):
try: try:
self.start() self.start()
services.service('winbind').start() services.service('winbind').start()
except: except Exception:
root_logger.critical("CIFS services failed to start") root_logger.critical("CIFS services failed to start")
def __stop(self): def __stop(self):
@ -740,13 +740,13 @@ class ADTRUSTInstance(service.Service):
try: try:
services.service('winbind').stop() services.service('winbind').stop()
self.stop() self.stop()
except: except Exception:
pass pass
def __restart_dirsrv(self): def __restart_dirsrv(self):
try: try:
services.knownservices.dirsrv.restart() services.knownservices.dirsrv.restart()
except: except Exception:
pass pass
def __restart_smb(self): def __restart_smb(self):