diff --git a/ldapcherry/__init__.py b/ldapcherry/__init__.py index 2a6a15a..642ee2f 100644 --- a/ldapcherry/__init__.py +++ b/ldapcherry/__init__.py @@ -173,7 +173,7 @@ class LdapCherry(object): try: self.backends_display_names[backend] = \ self.backends_params[backend]['display_name'] - except: + except Exception as e: self.backends_display_names[backend] = backend self.backends_params[backend]['display_name'] = backend params = self.backends_params[backend] @@ -225,7 +225,7 @@ class LdapCherry(object): ) try: pp = __import__(module, globals(), locals(), ['PPolicy'], 0) - except: + except Exception as e: raise BackendModuleLoadingFail(module) if 'ppolicy' in config: ppcfg = config['ppolicy'] @@ -1091,7 +1091,7 @@ class LdapCherry(object): is_admin = self._check_admin() try: referer = cherrypy.request.headers['Referer'] - except: + except Exception as e: referer = '/' self._deleteuser(user) self._add_notification('User Deleted') @@ -1110,7 +1110,7 @@ class LdapCherry(object): self._add_notification("User modified") try: referer = cherrypy.request.headers['Referer'] - except: + except Exception as e: referer = '/' raise cherrypy.HTTPRedirect(referer) diff --git a/ldapcherry/attributes.py b/ldapcherry/attributes.py index 75c863e..989bf14 100644 --- a/ldapcherry/attributes.py +++ b/ldapcherry/attributes.py @@ -33,7 +33,7 @@ class Attributes: self.key = None try: stream = open(attributes_file, 'r') - except: + except Exception as e: raise MissingAttributesFile(attributes_file) try: self.attributes = loadNoDump(stream) @@ -71,7 +71,7 @@ class Attributes: raise MissingUserKey() def _is_email(self, email): - pattern = '[\.\w]{1,}[@]\w+[.]\w+' + pattern = r'[\.\w]{1,}[@]\w+[.]\w+' if re.match(pattern, email): return True else: diff --git a/ldapcherry/backend/backendDemo.py b/ldapcherry/backend/backendDemo.py index 0377bad..6e0e0b4 100644 --- a/ldapcherry/backend/backendDemo.py +++ b/ldapcherry/backend/backendDemo.py @@ -9,14 +9,13 @@ import sys -if sys.version < '3': - from sets import Set as set - import ldapcherry.backend from ldapcherry.exceptions import UserDoesntExist, \ GroupDoesntExist, MissingParameter, \ UserAlreadyExists import re +if sys.version < '3': + from sets import Set as set class Backend(ldapcherry.backend.Backend): @@ -41,13 +40,17 @@ class Backend(ldapcherry.backend.Backend): self.backend_name = name admin_user = self.get_param('admin.user', 'admin') admin_password = self.get_param('admin.password', 'admin') - admin_groups = set(self._basic_splitter(self.get_param('admin.groups'))) + admin_groups = set( + self._basic_splitter(self.get_param('admin.groups')) + ) basic_user = self.get_param('basic.user', 'user') basic_password = self.get_param('basic.password', 'user') - basic_groups = set(self._basic_splitter(self.get_param('basic.groups'))) + basic_groups = set( + self._basic_splitter(self.get_param('basic.groups')) + ) pwd_attr = self.get_param('pwd_attr') self.search_attrs = set( - re.split('\W+', self.get_param('search_attributes')), + re.split(r'\W+', self.get_param('search_attributes')), ) self.pwd_attr = pwd_attr self.admin_user = admin_user @@ -66,7 +69,8 @@ class Backend(ldapcherry.backend.Backend): @staticmethod def _basic_splitter(in_str): - return [re.sub(r'(?