Projects
Kolab:3.4
pykolab
Log In
Username
Password
We truncated the diff of some files because they were too big. If you want to see the full diff for every file,
click here
.
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
Expand all
Collapse all
Changes of Revision 94
View file
pykolab-0.7.tar.gz/pykolab/auth/ldap/__init__.py
Changed
@@ -1215,46 +1215,45 @@ folder_path = entry['cn'] folderacl_entry_attribute = self.config_get('sharedfolder_acl_entry_attribute') + if folderacl_entry_attribute == None: + folderacl_entry_attribute = 'acl' - if not folderacl_entry_attribute == None: - if not entry.has_key(folderacl_entry_attribute): - entry[folderacl_entry_attribute] = self.get_entry_attribute( - entry['id'], - folderacl_entry_attribute - ) - - if not entry[folderacl_entry_attribute] == None: - # Parse it before assigning it - entry['kolabmailfolderaclentry'] = [] - if not isinstance(entry[folderacl_entry_attribute], list): - entry[folderacl_entry_attribute] = [ entry[folderacl_entry_attribute] ] + if not entry.has_key(folderacl_entry_attribute): + entry[folderacl_entry_attribute] = self.get_entry_attribute( + entry['id'], + folderacl_entry_attribute + ) - for acl_entry in entry[folderacl_entry_attribute]: - acl_access = acl_entry.split()[-1] - aci_subject = ' '.join(acl_entry.split()[:-1]) + if not entry[folderacl_entry_attribute] == None: + # Parse it before assigning it + entry['kolabfolderaclentry'] = [] + if not isinstance(entry[folderacl_entry_attribute], list): + entry[folderacl_entry_attribute] = [ entry[folderacl_entry_attribute] ] - log.debug(_("Found a subject %r with access %r") % (aci_subject, acl_access), level=8) + for acl_entry in entry[folderacl_entry_attribute]: + acl_access = acl_entry.split()[-1] + aci_subject = ' '.join(acl_entry.split()[:-1]) - access_lookup_dict = { - 'read': 'lrs', - 'post': 'p', - 'append': 'wip', - 'write': 'lrswite', - 'all': 'lrsedntxakcpiw' - } + log.debug(_("Found a subject %r with access %r") % (aci_subject, acl_access), level=8) - if access_lookup_dict.has_key(acl_access): - acl_access = access_lookup_dict[acl_access] + access_lookup_dict = { + 'all': 'lrsedntxakcpiw', + 'append': 'wip', + 'full': 'lrswipkxtecdn', + 'read': 'lrs', + 'read-only': 'lrs', + 'read-write': 'lrswitedn', + 'post': 'p', + 'semi-full': 'lrswit', + 'write': 'lrswite', + } - log.debug(_("Found a subject %r with access %r") % (aci_subject, acl_access), level=8) + if access_lookup_dict.has_key(acl_access): + acl_access = access_lookup_dict[acl_access] - entry['kolabmailfolderaclentry'].append("(%r, %r, %r)" % (folder_path, aci_subject, acl_access)) + log.debug(_("Found a subject %r with access %r") % (aci_subject, acl_access), level=8) - if not entry.has_key('kolabmailfolderaclentry'): - entry['kolabmailfolderaclentry'] = self.get_entry_attribute( - entry['id'], - 'kolabmailfolderaclentry' - ) + entry['kolabfolderaclentry'].append("(%r, %r, %r)" % (folder_path, aci_subject, acl_access)) if not self.imap.shared_folder_exists(folder_path): self.imap.shared_folder_create(folder_path, server) @@ -1267,12 +1266,14 @@ entry['kolabfoldertype'] ) - if entry.has_key('kolabmailfolderaclentry') and \ - not entry['kolabmailfolderaclentry'] == None: + if entry.has_key('kolabfolderaclentry') and \ + not entry['kolabfolderaclentry'] == None: self.imap._set_kolab_mailfolder_acls( - entry['kolabmailfolderaclentry'] + entry['kolabfolderaclentry'] ) + else: + self.imap.set_acl(folder_path, 'anyone', '') if entry.has_key(delivery_address_attribute) and \ not entry[delivery_address_attribute] == None: @@ -1414,7 +1415,7 @@ success = True for _type in ['user','group','role','sharedfolder']: try: - eval("self._change_delete_%s(entry, change)" % (_type)) + eval("success = self._change_delete_%s(entry, change)" % (_type)) except: success = False @@ -1593,46 +1594,45 @@ folder_path = entry['cn'] folderacl_entry_attribute = self.config_get('sharedfolder_acl_entry_attribute') + if folderacl_entry_attribute == None: + folderacl_entry_attribute = 'acl' - if not folderacl_entry_attribute == None: - if not entry.has_key(folderacl_entry_attribute): - entry[folderacl_entry_attribute] = self.get_entry_attribute( - entry['id'], - folderacl_entry_attribute - ) + if not entry.has_key(folderacl_entry_attribute): + entry[folderacl_entry_attribute] = self.get_entry_attribute( + entry['id'], + folderacl_entry_attribute + ) - if not entry[folderacl_entry_attribute] == None: - # Parse it before assigning it - entry['kolabmailfolderaclentry'] = [] - if not isinstance(entry[folderacl_entry_attribute], list): - entry[folderacl_entry_attribute] = [ entry[folderacl_entry_attribute] ] + if not entry[folderacl_entry_attribute] == None: + # Parse it before assigning it + entry['kolabfolderaclentry'] = [] + if not isinstance(entry[folderacl_entry_attribute], list): + entry[folderacl_entry_attribute] = [ entry[folderacl_entry_attribute] ] - for acl_entry in entry[folderacl_entry_attribute]: - acl_access = acl_entry.split()[-1] - aci_subject = ' '.join(acl_entry.split()[:-1]) + for acl_entry in entry[folderacl_entry_attribute]: + acl_access = acl_entry.split()[-1] + aci_subject = ' '.join(acl_entry.split()[:-1]) - log.debug(_("Found a subject %r with access %r") % (aci_subject, acl_access), level=8) + log.debug(_("Found a subject %r with access %r") % (aci_subject, acl_access), level=8) - access_lookup_dict = { - 'read': 'lrs', - 'post': 'p', - 'append': 'wip', - 'write': 'lrswite', - 'all': 'lrsedntxakcpiw' - } + access_lookup_dict = { + 'all': 'lrsedntxakcpiw', + 'append': 'wip', + 'full': 'lrswipkxtecdn', + 'read': 'lrs', + 'read-only': 'lrs', + 'read-write': 'lrswitedn', + 'post': 'p', + 'semi-full': 'lrswit', + 'write': 'lrswite', + } - if access_lookup_dict.has_key(acl_access): - acl_access = access_lookup_dict[acl_access] + if access_lookup_dict.has_key(acl_access): + acl_access = access_lookup_dict[acl_access] - log.debug(_("Found a subject %r with access %r") % (aci_subject, acl_access), level=8) + log.debug(_("Found a subject %r with access %r") % (aci_subject, acl_access), level=8) - entry['kolabmailfolderaclentry'].append("(%r, %r, %r)" % (folder_path, aci_subject, acl_access)) - - if not entry.has_key('kolabmailfolderaclentry'): - entry['kolabmailfolderaclentry'] = self.get_entry_attribute( - entry['id'], - 'kolabmailfolderaclentry' - ) + entry['kolabfolderaclentry'].append("(%r, %r, %r)" % (folder_path, aci_subject, acl_access)) if not self.imap.shared_folder_exists(folder_path): self.imap.shared_folder_create(folder_path, server) @@ -1644,20 +1644,21 @@ folder_path, entry['kolabfoldertype'] ) + else: + self.imap.set_acl(folder_path, 'anyone', '') - if entry.has_key(delivery_address_attribute) and \ - not entry[delivery_address_attribute] == None: - self.imap.set_acl(folder_path, 'anyone', 'p') - - if entry.has_key('kolabmailfolderaclentry') and \ - not entry['kolabmailfolderaclentry'] == None: + if entry.has_key('kolabfolderaclentry') and \ + not entry['kolabfolderaclentry'] == None: self.imap._set_kolab_mailfolder_acls(
View file
pykolab-0.7.tar.gz/pykolab/auth/ldap/cache.py
Changed
@@ -175,9 +175,13 @@ db_uri = 'sqlite:///%s/%s.db' % (KOLAB_LIB_PATH, domain) echo = conf.debuglevel > 8 - engine = create_engine(db_uri, echo=echo) - metadata.create_all(engine) + try: + engine = create_engine(db_uri, echo=echo) + metadata.create_all(engine) + except: + engine = create_engine('sqlite://') + metadata.create_all(engine) Session = sessionmaker(bind=engine) db = Session() @@ -185,14 +189,17 @@ return db def last_modify_timestamp(domain): - db = init_db(domain) - last_change = db.query(Entry).order_by(desc(Entry.last_change)).first() - modifytimestamp_format = conf.get_raw('ldap', 'modifytimestamp_format') if modifytimestamp_format == None: modifytimestamp_format = "%Y%m%d%H%M%SZ" - if not last_change == None: - return last_change.last_change.strftime(modifytimestamp_format) - - return datetime.datetime(1900, 01, 01, 00, 00, 00).strftime(modifytimestamp_format) + try: + db = init_db(domain) + last_change = db.query(Entry).order_by(desc(Entry.last_change)).first() + + if not last_change == None: + return last_change.last_change.strftime(modifytimestamp_format) + else: + return datetime.datetime(1900, 01, 01, 00, 00, 00).strftime(modifytimestamp_format) + except: + return datetime.datetime(1900, 01, 01, 00, 00, 00).strftime(modifytimestamp_format)
View file
pykolab-0.7.tar.gz/pykolab/cli/cmd_count_domain_mailboxes.py
Changed
@@ -56,10 +56,8 @@ domains = auth.list_domains() folders = [] - for primary,secondaries in domains: - print "%s: %d" % (primary,len(imap.lm("user/%%@%s" % (primary)))) - for secondary in secondaries: - print "%s: %d" % (secondary,len(imap.lm("user/%%@%s" % (secondary)))) + for domain in domains.keys(): + print "%s: %d" % (domain,len(imap.lm("user/%%@%s" % (domain)))) null_realm = len(imap.lm("user/%%"))
View file
pykolab-0.7.tar.gz/pykolab/cli/cmd_delete_mailbox.py
Changed
@@ -57,5 +57,8 @@ sys.exit(1) for delete_folder in delete_folders: - imap.delete_mailfolder(delete_folder) + try: + imap.delete_mailfolder(delete_folder) + except Exception, errmsg: + log.error(_("Could not delete mailbox '%s'") % (delete_folder))
View file
pykolab-0.7.tar.gz/pykolab/cli/cmd_list_users.py
Added
@@ -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_users', 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")) + + users = wap_client.users_list() + print '\n'.join(users['list'].keys())
View file
pykolab-0.7.tar.gz/pykolab/cli/cmd_rebalance_mailboxes.py
Changed
@@ -52,52 +52,32 @@ imap = IMAP() imap.connect() - import os - if not os.access('./cache.folders', os.R_OK): - auth = Auth() - auth.connect() + auth = Auth() + auth.connect() - domains = auth.list_domains() + domains = auth.list_domains() - folders = {} + folders = {} - for primary,secondaries in domains: - for folder in imap.lm("user/%%@%s" % (primary)): - folders[folder] = get_quota(imap, folder) - - for folder in imap.lm("shared/%%@%s" % (primary)): - folders[folder] = get_quota(imap, folder) - - for secondary in secondaries: - for folder in imap.lm("user/%%@%s" % (secondary)): - folders[folder] = get_quota(imap, folder) - - for folder in imap.lm("shared/%%@%s" % (secondary)): - folders[folder] = get_quota(imap, folder) - - for folder in imap.lm("user/%%"): + for domain in domains.keys(): + for folder in imap.lm("user/%%@%s" % (domain)): folders[folder] = get_quota(imap, folder) - for folder in imap.lm("shared/%%"): + for folder in imap.lm("shared/%%@%s" % (domain)): folders[folder] = get_quota(imap, folder) - for folder in folders.keys(): - if folders[folder] == None: - del folders[folder] + for folder in imap.lm("user/%%"): + folders[folder] = get_quota(imap, folder) - for folder in folders: - folders[folder]['server'] = imap.imap.find_mailfolder_server(folder) + for folder in imap.lm("shared/%%"): + folders[folder] = get_quota(imap, folder) - import json - fp = open('./cache.folders', 'w') - fp.write(json.dumps(folders)) - fp.close() + for folder in folders.keys(): + if folders[folder] == None: + del folders[folder] - else: - import json - fp = open('./cache.folders', 'r') - folders = json.load(fp) - fp.close() + for folder in folders: + folders[folder]['server'] = imap.imap.find_mailfolder_server(folder) # Data gathered, calculations can begin. mboxs = {} @@ -122,21 +102,24 @@ #used = {'bs101.kolabsys.net': 7508435, 'bs102.kolabsys.net': 586967, 'bs103.kolabsys.net': 121} #alloc = {'bs101.kolabsys.net': 3279032832, 'bs102.kolabsys.net': 60817408, 'bs103.kolabsys.net': 6291456} - print mboxs - print sum(mboxs.values()) / len(mboxs.keys()) + print "number of mailboxes per node:", mboxs + print "average per mailbox:", sum(mboxs.values()) / len(mboxs.keys()) for (k,v) in mboxs.iteritems(): print "k:", k, "is", float(v * len(mboxs.keys())) / float(sum(mboxs.values())), "%" - print used - print sum(used.values()) / len(used.keys()) + print "used:", used + print "used average:", sum(used.values()) / len(used.keys()) for (k,v) in used.iteritems(): - print "k:", k, "is", float(v * len(used.keys())) / float(sum(used.values())), "%" + if (float(sum(used.values())) > 0): + print "k:", k, "is", float(v * len(used.keys())) / float(sum(used.values())), "%" + print "average storage per mailbox:", float(used[k]) / float(mboxs[k]) print alloc print sum(alloc.values()) / len(alloc.keys()) for (k,v) in alloc.iteritems(): - print "k:", k, "is", float(v * len(alloc.keys())) / float(sum(alloc.values())), "%" + if (float(sum(alloc.values())) > 0): + print "k:", k, "is", float(v * len(alloc.keys())) / float(sum(alloc.values())), "%" print "average quota per mailbox:", float(alloc[k]) / float(mboxs[k])
View file
pykolab-0.7.tar.gz/pykolab/cli/commands.py
Changed
@@ -55,7 +55,6 @@ register('help', list_commands) - register('list_users', not_yet_implemented, description="Not yet implemented") register('delete_user', not_yet_implemented, description="Not yet implemented") register('list_groups', not_yet_implemented, description="Not yet implemented")
View file
pykolab-0.7.tar.gz/pykolab/imap/__init__.py
Changed
@@ -320,11 +320,15 @@ Set an ACL entry on a folder. """ short_rights = { - 'all': 'lrswipkxtecda', + 'all': 'lrsedntxakcpiw', + 'append': 'wip', + 'full': 'lrswipkxtecdn', + 'read': 'lrs', 'read-only': 'lrs', - 'read-write': 'lrswited', + 'read-write': 'lrswitedn', + 'post': 'p', 'semi-full': 'lrswit', - 'full': 'lrswipkxtecd' + 'write': 'lrswite', } if short_rights.has_key(acl): @@ -652,7 +656,7 @@ if additional_folders[additional_folder].has_key("partition"): partition = additional_folders[additional_folder]["partition"] try: - self.imap.rename(folder_name, folder_name, partition) + self.imap._rename(folder_name, folder_name, partition) except: log.error(_("Could not rename %s to reside on partition %s") % (folder_name, partition))
View file
pykolab-0.7.tar.gz/pykolab/imap/cyrus.py
Changed
@@ -384,9 +384,9 @@ verify_folder_search = "%s@%s" % (verify_folder_search, mbox['domain']) if ' ' in verify_folder_search: - folders = self.lm('"%s"' % verify_folder_search) + folders = self.lm('"%s"' % self.folder_utf7(verify_folder_search)) else: - folders = self.lm(verify_folder_search) + folders = self.lm(self.folder_utf7(verify_folder_search)) # NOTE: Case also covered is valid hexadecimal folders; won't be the # actual check as intended, but doesn't give you anyone else's data
View file
pykolab-0.7.tar.gz/pykolab/wap_client/__init__.py
Changed
@@ -67,6 +67,9 @@ response = request('POST', "system.authenticate", post=post) + if not response: + return False + if response.has_key('session_token'): session_id = response['session_token'] return True @@ -126,6 +129,31 @@ return request('POST', 'form_value.generate', post=post) +def form_value_generate_password(*args, **kw): + return request('GET', 'form_value.generate_password') + +def form_value_list_options(object_type, object_type_id, attribute): + post = json.dumps( + { + 'object_type': object_type, + 'type_id': object_type_id, + 'attribute': attribute + } + ) + + return request('POST', 'form_value.list_options', post=post) + +def form_value_select_options(object_type, object_type_id, attribute): + post = json.dumps( + { + 'object_type': object_type, + 'type_id': object_type_id, + 'attributes': [ attribute ] + } + ) + + return request('POST', 'form_value.select_options', post=post) + def get_group_input(): group_types = group_types_list() @@ -275,10 +303,18 @@ return request('POST', 'group_form_value.generate_mail', params) -def group_info(): - group = utils.ask_question("Group email address") - group = request('GET', 'group.info?group=%s' % (group)) - return group +def group_find(params=None): + post = { 'search': { 'params': {} } } + + for (k,v) in params.iteritems(): + post['search']['params'][k] = { 'value': v, 'type': 'exact' } + + return request('POST', 'group.find', post=json.dumps(post)) + +def group_info(group=None): + if group == None: + group = utils.ask_question("group DN") + return request('GET', 'group.info', get={ 'id': group }) def group_members_list(group=None): if group == None: @@ -298,6 +334,21 @@ def ou_delete(params={}): return request('POST', 'ou.delete', post=json.dumps(params)) +def ou_find(params=None): + post = { 'search': { 'params': {} } } + + for (k,v) in params.iteritems(): + post['search']['params'][k] = { 'value': v, 'type': 'exact' } + + return request('POST', 'ou.find', post=json.dumps(post)) + +def ou_info(ou): + _params = { 'id': ou } + + ou = request('GET', 'ou.info', get=_params) + + return ou + def ous_list(params={}): return request('POST', 'ous.list', post=json.dumps(params)) @@ -308,7 +359,6 @@ del response_data['status'] return response_data['result'] else: - print "ERROR: %r" % (response_data['reason']) return False def request_raw(method, api_uri, get=None, post=None, headers={}): @@ -345,9 +395,111 @@ return response_data +def resource_add(params=None): + if params == None: + params = get_user_input() + + return request('POST', 'resource.add', post=json.dumps(params)) + +def resource_delete(params=None): + if params == None: + params = { + 'id': utils.ask_question("Resource DN to delete", "resource") + } + + return request('POST', 'resource.delete', post=json.dumps(params)) + +def resource_find(params=None): + post = { 'search': { 'params': {} } } + + for (k,v) in params.iteritems(): + post['search']['params'][k] = { 'value': v, 'type': 'exact' } + + return request('POST', 'resource.find', post=json.dumps(post)) + +def resource_info(resource=None): + if resource == None: + resource = utils.ask_question("Resource DN") + return request('GET', 'resource.info', get={ 'id': resource }) + +def resource_types_list(): + return request('GET', 'resource_types.list') + +def resources_list(params={}): + return request('POST', 'resources.list', post=json.dumps(params)) + +def role_add(params=None): + if params == None: + role_name = utils.ask_question("Role name") + params = { + 'cn': role_name + } + + params = json.dumps(params) + + return request('POST', 'role.add', params) + def role_capabilities(): return request('GET', 'role.capabilities') +def role_delete(params=None): + if params == None: + role_name = utils.ask_question("Role name") + role = role_find_by_attribute({'cn': role_name}) + params = { + 'role': role.keys()[0] + } + + if not params.has_key('role'): + role = role_find_by_attribute(params) + params = { + 'role': role.keys()[0] + } + + post = json.dumps(params) + + return request('POST', 'role.delete', post=post) + +def role_find_by_attribute(params=None): + if params == None: + role_name = utils.ask_question("Role name") + else: + role_name = params['cn'] + + get = { 'cn': role_name } + role = request('GET', 'role.find_by_attribute', get=get) + + return role + +def role_info(role_name): + role = role_find_by_attribute({'cn': role_name}) + + get = { 'role': role['id'] } + + role = request('GET', 'role.info', get=get) + + return role + +def roles_list(): + return request('GET', 'roles.list') + +def sharedfolder_add(params=None): + if params == None: + params = get_user_input() + + return request('POST', 'sharedfolder.add', post=json.dumps(params)) + +def sharedfolder_delete(params=None): + if params == None: + params = { + 'id': utils.ask_question("Shared Folder DN to delete", "sharedfolder") + } + + return request('POST', 'sharedfolder.delete', post=json.dumps(params))
Locations
Projects
Search
Status Monitor
Help
Open Build Service
OBS Manuals
API Documentation
OBS Portal
Reporting a Bug
Contact
Mailing List
Forums
Chat (IRC)
Twitter
Open Build Service (OBS)
is an
openSUSE project
.