4 commits - pykolab/auth pykolab/cli pykolab/wap_client

Jeroen van Meeuwen vanmeeuwen at kolabsys.com
Wed Jul 30 14:25:03 CEST 2014


 pykolab/auth/ldap/__init__.py  |    6 +++++-
 pykolab/cli/cmd_list_ous.py    |   39 +++++++++++++++++++++++++++++++++++++++
 pykolab/wap_client/__init__.py |   18 ++++++++++++++----
 3 files changed, 58 insertions(+), 5 deletions(-)

New commits:
commit 46fd1e032160f010525bddedf18a9ccd14a5c62a
Merge: e949ef9 bc7fba1
Author: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen at kolabsys.com>
Date:   Wed Jul 30 14:24:57 2014 +0200

    Merge branch 'master' of ssh://git.kolabsys.com/git/pykolab



commit e949ef9342ca4c8b67d6207eb2ac211e0b1c2122
Author: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen at kolabsys.com>
Date:   Wed Jul 30 14:24:37 2014 +0200

    Add a 'list-ous' command

diff --git a/pykolab/cli/cmd_list_ous.py b/pykolab/cli/cmd_list_ous.py
new file mode 100644
index 0000000..670b609
--- /dev/null
+++ b/pykolab/cli/cmd_list_ous.py
@@ -0,0 +1,39 @@
+# -*- coding: utf-8 -*-
+# Copyright 2010-2012 Kolab Systems AG (http://www.kolabsys.com)
+#
+# Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen a kolabsys.com>
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+
+import commands
+
+import pykolab
+
+from pykolab import utils
+from pykolab.translate import _
+
+log = pykolab.getLogger('pykolab.cli')
+conf = pykolab.getConf()
+
+def __init__():
+    commands.register('list_ous', execute, description="List organizational units.")
+
+def execute(*args, **kw):
+    from pykolab import wap_client
+
+    wap_client.authenticate(username=conf.get("ldap", "bind_dn"), password=conf.get("ldap", "bind_pw"))
+
+    ous = wap_client.ous_list()
+    print '\n'.join(ous['list'].keys())


commit eedee64b0811fb9e95417feaf851cb9cb19a280a
Author: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen at kolabsys.com>
Date:   Wed Jul 30 14:24:07 2014 +0200

    Add some basic ou functions to the wap client

diff --git a/pykolab/wap_client/__init__.py b/pykolab/wap_client/__init__.py
index eabc893..299b847 100644
--- a/pykolab/wap_client/__init__.py
+++ b/pykolab/wap_client/__init__.py
@@ -69,6 +69,7 @@ def authenticate(username=None, password=None, domain=None):
 
     if response.has_key('session_token'):
         session_id = response['session_token']
+        return True
 
 def connect():
     global conn
@@ -288,8 +289,17 @@ def group_members_list(group=None):
 def group_types_list():
     return request('GET', 'group_types.list')
 
-def groups_list():
-    return request('GET', 'groups.list')
+def groups_list(params={}):
+    return request('POST', 'groups.list', post=json.dumps(params))
+
+def ou_add(params={}):
+    return request('POST', 'ou.add', post=json.dumps(params))
+
+def ou_delete(params={}):
+    return request('POST', 'ou.delete', post=json.dumps(params))
+
+def ous_list(params={}):
+    return request('POST', 'ous.list', post=json.dumps(params))
 
 def request(method, api_uri, get=None, post=None, headers={}):
     response_data = request_raw(method, api_uri, get, post, headers)
@@ -525,8 +535,8 @@ def user_info(user=None):
 def user_types_list():
     return request('GET', 'user_types.list')
 
-def users_list():
-    return request('GET', 'users.list')
+def users_list(params={}):
+    return request('POST', 'users.list', post=json.dumps(params))
 
 def resource_types_list():
     return request('GET', 'resource_types.list')


commit bae16970b5d9d5379214658397834499fb3755d8
Author: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen at kolabsys.com>
Date:   Wed Jul 30 14:23:36 2014 +0200

    Add the traceback to the error log as well

diff --git a/pykolab/auth/ldap/__init__.py b/pykolab/auth/ldap/__init__.py
index d1a0b2d..7249009 100644
--- a/pykolab/auth/ldap/__init__.py
+++ b/pykolab/auth/ldap/__init__.py
@@ -2704,9 +2704,13 @@ class LDAP(pykolab.base.Base):
 
             except Exception, errmsg:
                 log.error(_("An error occured using %s: %r") % (supported_control, errmsg))
+                import traceback
+
                 if conf.debuglevel > 8:
-                    import traceback
                     traceback.print_exc()
+
+                log.error(_("%s") % (traceback.format_exc()))
+
                 continue
 
         return _results




More information about the commits mailing list