Skip to content

Commit

Permalink
removing trailling spaces
Browse files Browse the repository at this point in the history
  • Loading branch information
kakwa committed Jun 6, 2015
1 parent 30cfd24 commit 247a1fe
Show file tree
Hide file tree
Showing 11 changed files with 42 additions and 43 deletions.
16 changes: 8 additions & 8 deletions ldapcherry/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@

# 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):
Expand Down Expand Up @@ -120,7 +120,7 @@ def _init_backends(self, config):
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)
Expand Down Expand Up @@ -190,8 +190,8 @@ def _set_error_log(self, config, level):
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

Expand Down Expand Up @@ -263,7 +263,7 @@ def reload(self, config = None):
"""
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
Expand Down Expand Up @@ -322,7 +322,7 @@ def reload(self, config = None):
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:
Expand Down Expand Up @@ -395,7 +395,7 @@ def login(self, login, password):

@cherrypy.expose
def logout(self):
""" logout page
""" logout page
"""
sess = cherrypy.session
username = sess.get(SESSION_KEY, None)
Expand Down
2 changes: 1 addition & 1 deletion ldapcherry/attributes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions ldapcherry/backend/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -44,6 +44,6 @@ def get_param(self, param, default=None):
return self.config[param]
elif not default is None:
return default
else:
else:
raise MissingParameter('backends', self.backend_name+'.'+param)

16 changes: 8 additions & 8 deletions ldapcherry/backend/backendLdap.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def _connect(self):
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:
Expand Down Expand Up @@ -91,7 +91,7 @@ def _bind(self):
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):
Expand Down Expand Up @@ -225,31 +225,31 @@ def search(self, searchstring):
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
Expand Down
4 changes: 2 additions & 2 deletions ldapcherry/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def __init__(self, key, section, ymlfile):
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):
Expand Down Expand Up @@ -94,4 +94,4 @@ def __init__(self, key, section, ymlfile):
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 }
2 changes: 1 addition & 1 deletion ldapcherry/pyyamlwrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def __init__(self, host, key):
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):

Expand Down
9 changes: 4 additions & 5 deletions ldapcherry/roles.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def _flatten(self, roles=None, groups=None):
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']

Expand All @@ -75,7 +75,6 @@ def _set_admin(self, role):
self.admin_roles.append(r)
self._set_admin(role['subroles'][r])


def _is_parent(self, roleid1, roleid2):
"""Test if roleid1 is contained inside roleid2"""

Expand Down Expand Up @@ -105,7 +104,7 @@ def _is_parent(self, roleid1, roleid2):
def _nest(self):
"""nests the roles (creates roles hierarchy)"""
self._flatten()
parents = {}
parents = {}
for roleid in self.flatten:
role = copy.deepcopy(self.flatten[roleid])

Expand Down Expand Up @@ -143,7 +142,7 @@ def nest(p):
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
Expand Down Expand Up @@ -205,7 +204,7 @@ def _check_member(self, role, groups, notroles, roles, parentroles, usedgroups):
# 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:
Expand Down
6 changes: 3 additions & 3 deletions resources/templates/base.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -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">
Expand All @@ -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>
Expand All @@ -38,7 +38,7 @@
<script>
$(function(){
$("#RecordTable").tablesorter({ sortList: [[0,0]] });
});
});
</script>

</head>
Expand Down
2 changes: 1 addition & 1 deletion resources/templates/error.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
2 changes: 1 addition & 1 deletion resources/templates/searchadmin.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
22 changes: 11 additions & 11 deletions scripts/ldapcherryd
Original file line number Diff line number Diff line change
Expand Up @@ -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"""
Expand Down Expand Up @@ -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')
Expand All @@ -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,
Expand All @@ -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()
Expand All @@ -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")
Expand All @@ -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)
Expand All @@ -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)
Expand Down

0 comments on commit 247a1fe

Please sign in to comment.