1
0
mirror of https://github.com/kakwa/ldapcherry synced 2024-11-22 01:14:21 +01:00

removing trailling spaces

This commit is contained in:
kakwa 2015-06-06 22:23:21 +02:00
parent 30cfd248f7
commit 247a1fed3a
11 changed files with 42 additions and 43 deletions

View File

@ -31,14 +31,14 @@ SESSION_KEY = '_cp_username'
# Custom log function to overrige weird error.log function
# of cherrypy
def syslog_error(msg='', context='',
def syslog_error(msg='', context='',
severity=logging.INFO, traceback=False):
if traceback:
msg += cherrypy._cperror.format_exc()
if context == '':
cherrypy.log.error_log.log(severity, msg)
else:
cherrypy.log.error_log.log(severity,
cherrypy.log.error_log.log(severity,
' '.join((context, msg)))
class LdapCherry(object):
@ -120,7 +120,7 @@ class LdapCherry(object):
try:
bc = __import__(module, globals(), locals(), ['Backend'], -1)
except:
raise BackendModuleLoadingFail(module)
raise BackendModuleLoadingFail(module)
try:
attrslist = self.attributes.get_backend_attributes(backend)
key = self.attributes.get_backend_key(backend)
@ -190,8 +190,8 @@ class LdapCherry(object):
cherrypy.log.error_log.handlers = []
# redefining log.error method because cherrypy does weird
# things like adding the date inside the message
# or adding space even if context is empty
# things like adding the date inside the message
# or adding space even if context is empty
# (by the way, what's the use of "context"?)
cherrypy.log.error = syslog_error
@ -263,7 +263,7 @@ class LdapCherry(object):
"""
try:
# log configuration handling
# get log level
# get log level
# (if not in configuration file, log level is set to debug)
level = self._get_loglevel(self._get_param('global', 'log.level', config, 'debug'))
# configure access log
@ -322,7 +322,7 @@ class LdapCherry(object):
def _search(self, searchstring):
if searchstring is None:
return {}
ret = {}
ret = {}
for b in self.backends:
tmp = self.backends[b].search(searchstring)
for u in tmp:
@ -395,7 +395,7 @@ class LdapCherry(object):
@cherrypy.expose
def logout(self):
""" logout page
""" logout page
"""
sess = cherrypy.session
username = sess.get(SESSION_KEY, None)

View File

@ -21,7 +21,7 @@ class Attributes:
def __init__(self, attributes_file):
self.attributes_file = attributes_file
self.backends = Set([])
self.self_attributes = {}
self.self_attributes = {}
self.backend_attributes = {}
self.displayed_attributes = {}
self.key = None

View File

@ -12,7 +12,7 @@ class Backend:
def __init__(self):
pass
def auth(self, username, password):
def auth(self, username, password):
return False
def add_user(self, attrs):
@ -44,6 +44,6 @@ class Backend:
return self.config[param]
elif not default is None:
return default
else:
else:
raise MissingParameter('backends', self.backend_name+'.'+param)

View File

@ -62,7 +62,7 @@ class Backend(ldapcherry.backend.Backend):
ldap.set_option(ldap.OPT_X_TLS_REQUIRE_CERT, ldap.OPT_X_TLS_ALLOW)
else:
ldap.set_option(ldap.OPT_X_TLS_REQUIRE_CERT,ldap.OPT_X_TLS_DEMAND)
if self.starttls == 'on':
if self.starttls == 'on':
try:
ldap_client.start_tls_s()
except ldap.OPERATIONS_ERROR as e:
@ -91,7 +91,7 @@ class Backend(ldapcherry.backend.Backend):
msg = "Unable to contact ldap server '" + self.uri + "', check 'auth.ldap.uri' and ssl/tls configuration",
)
ldap_client.unbind_s()
raise e
raise e
return ldap_client
def _search(self, searchfilter, attrs, basedn):
@ -225,31 +225,31 @@ class Backend(ldapcherry.backend.Backend):
for u in self._search(searchfilter, None, self.userdn):
attrs = {}
attrs_tmp = u[1]
for attr in attrs_tmp:
for attr in attrs_tmp:
value_tmp = attrs_tmp[attr]
if len(value_tmp) == 1:
attrs[attr] = value_tmp[0]
else:
attrs[attr] = value_tmp
if self.key in attrs:
ret[attrs[self.key]] = attrs
return ret
return ret
def get_user(self, username):
ret = {}
attrs_tmp = self._get_user(username)[1]
for attr in attrs_tmp:
for attr in attrs_tmp:
value_tmp = attrs_tmp[attr]
if len(value_tmp) == 1:
ret[attr] = value_tmp[0]
else:
ret[attr] = value_tmp
return ret
return ret
def get_groups(self, username):
userdn = self._get_user(username, False)
searchfilter = self.group_filter_tmpl % {
'userdn': userdn,
'username': username

View File

@ -18,7 +18,7 @@ class MissingKey(Exception):
self.key = key
self.section = section
self.ymlfile = ymlfile
self.log = "missing key <%(key)s> in section <%(section)s> inside file <%(ymlfile)s>" % {'key': key, 'section': section, 'ymlfile': ymlfile }
self.log = "missing key <%(key)s> in section <%(section)s> inside file <%(ymlfile)s>" % {'key': key, 'section': section, 'ymlfile': ymlfile }
class DumplicateRoleKey(Exception):
def __init__(self, role):
@ -94,4 +94,4 @@ class WrongAttributeType(Exception):
self.key = key
self.section = section
self.ymlfile = ymlfile
self.log = "wrong attribute type <%(key)s> in section <%(section)s> inside file <%(ymlfile)s>" % {'key': key, 'section': section, 'ymlfile': ymlfile }
self.log = "wrong attribute type <%(key)s> in section <%(section)s> inside file <%(ymlfile)s>" % {'key': key, 'section': section, 'ymlfile': ymlfile }

View File

@ -29,7 +29,7 @@ try:
except ImportError:
from yaml import Loader, Dumper
# PyYaml wrapper that loads yaml files throwing an exception
# PyYaml wrapper that loads yaml files throwing an exception
#if a key is dumplicated
class MyLoader(Reader, Scanner, Parser, Composer, Constructor, Resolver):

View File

@ -65,7 +65,7 @@ class Roles:
if not groups is None:
role['backends_groups'] = self._merge_groups([role['backends_groups'], groups])
if 'subroles' in role:
self._flatten(role['subroles'],
self._flatten(role['subroles'],
role['backends_groups'])
del role['subroles']
@ -75,7 +75,6 @@ class Roles:
self.admin_roles.append(r)
self._set_admin(role['subroles'][r])
def _is_parent(self, roleid1, roleid2):
"""Test if roleid1 is contained inside roleid2"""
@ -105,7 +104,7 @@ class Roles:
def _nest(self):
"""nests the roles (creates roles hierarchy)"""
self._flatten()
parents = {}
parents = {}
for roleid in self.flatten:
role = copy.deepcopy(self.flatten[roleid])
@ -143,7 +142,7 @@ class Roles:
if len(parents[p]) == 0:
return ret
else:
for i in parents[p]:
for i in parents[p]:
sub = nest(i)
ret['subroles'][i] = sub
return ret
@ -205,7 +204,7 @@ class Roles:
# if not, add role to the list of roles
if flag:
roles.add(role)
# else remove it from the list of roles and add
# else remove it from the list of roles and add
# it to the list of parentroles
else:
if role in roles:

View File

@ -11,7 +11,7 @@
<!--link rel="stylesheet/less" href="/static/less/responsive.less" type="text/css" /-->
<!--script src="/static/js/less-1.3.3.min.js"></script-->
<!--append #!watch to the browser URL, then refresh the page. -->
<link href="/static/css/bootstrap.min.css" rel="stylesheet">
<link href="/static/css/custom.css" rel="stylesheet">
<link href="/static/css/style.css" rel="stylesheet">
@ -28,7 +28,7 @@
<link rel="apple-touch-icon-precomposed" sizes="72x72" href="/static/img/apple-touch-icon-72-precomposed.png">
<link rel="apple-touch-icon-precomposed" href="/static/img/apple-touch-icon-57-precomposed.png">
<link rel="shortcut icon" href="/static/img/favicon.png">
<script type="text/javascript" src="/static/js/jquery.min.js"></script>
<script type="text/javascript" src="/static/js/bootstrap.min.js"></script>
<script type="text/javascript" src="/static/js/scripts.js"></script>
@ -38,7 +38,7 @@
<script>
$(function(){
$("#RecordTable").tablesorter({ sortList: [[0,0]] });
});
});
</script>
</head>

View File

@ -5,7 +5,7 @@
<div class="alert alert-dismissable alert-${alert}">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
<h4>
${message}
${message}
</h4>
</div>
<a class="btn btn-default blue" href='/?zone=${current_zone}'><span class="glyphicon glyphicon-home"> Return</a>

View File

@ -52,7 +52,7 @@
</a>
</td>
<td>
<a href="/delete?user=${user}">
<button type="submit" class="btn btn-xs red">
<span class="glyphicon glyphicon-remove-sign"></span> Delete</button>

View File

@ -21,7 +21,7 @@ def start(configfile=None, daemonize=False, environment=None,
cgi=False):
"""Subscribe all engine plugins and start the engine."""
sys.path = [''] + sys.path
# monkey patching cherrypy to disable config interpolation
def new_as_dict(self, raw=True, vars=None):
"""Convert an INI file to a dictionary"""
@ -50,24 +50,24 @@ def start(configfile=None, daemonize=False, environment=None,
instance.reload(app.config)
engine = cherrypy.engine
if environment is not None:
cherrypy.config.update({'environment': environment})
# Only daemonize if asked to.
if daemonize:
# Don't print anything to stdout/sterr.
cherrypy.config.update({'log.screen': False})
plugins.Daemonizer(engine).subscribe()
if pidfile:
plugins.PIDFile(engine, pidfile).subscribe()
if hasattr(engine, "signal_handler"):
engine.signal_handler.subscribe()
if hasattr(engine, "console_control_handler"):
engine.console_control_handler.subscribe()
if (fastcgi and (scgi or cgi)) or (scgi and cgi):
cherrypy.log.error("You may only specify one of the cgi, fastcgi, and "
"scgi options.", 'ENGINE')
@ -77,7 +77,7 @@ def start(configfile=None, daemonize=False, environment=None,
cherrypy.config.update({'engine.autoreload_on': False})
# Turn off the default HTTP server (which is subscribed by default).
cherrypy.server.unsubscribe()
addr = cherrypy.server.bind_addr
if fastcgi:
f = servers.FlupFCGIServer(application=cherrypy.tree,
@ -90,7 +90,7 @@ def start(configfile=None, daemonize=False, environment=None,
bindAddress=addr)
s = servers.ServerAdapter(engine, httpserver=f, bind_addr=addr)
s.subscribe()
# Always start the engine; this will start all other services
try:
engine.start()
@ -103,7 +103,7 @@ def start(configfile=None, daemonize=False, environment=None,
if __name__ == '__main__':
from optparse import OptionParser
p = OptionParser()
p.add_option('-c', '--config', dest='config',
help="specify config file")
@ -122,7 +122,7 @@ if __name__ == '__main__':
p.add_option('-P', '--Path', action="append", dest='Path',
help="add the given paths to sys.path")
options, args = p.parse_args()
if options.Path:
for p in options.Path:
sys.path.insert(0, p)
@ -134,7 +134,7 @@ if __name__ == '__main__':
if not os.path.isfile(options.config):
print('configuration file "'+ options.config + '" doesn\'t exist' )
exit(1)
start(options.config, options.daemonize,
options.environment, options.fastcgi, options.scgi,
options.pidfile, options.cgi)