Changeset View
Changeset View
Standalone View
Standalone View
pykolab/cli/cmd_list_mailbox_acls.py
Show All 11 Lines | |||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||
# GNU General Public License for more details. | # GNU General Public License for more details. | ||||
# You should have received a copy of the GNU General Public License | # You should have received a copy of the GNU General Public License | ||||
# along with this program. If not, see <http://www.gnu.org/licenses/>. | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||||
# | # | ||||
from __future__ import print_function | |||||
import sys | import sys | ||||
import commands | import commands | ||||
import pykolab | import pykolab | ||||
from pykolab.imap import IMAP | from pykolab.imap import IMAP | ||||
from pykolab.translate import _ | from pykolab.translate import _ | ||||
from pykolab import utils | from pykolab import utils | ||||
log = pykolab.getLogger('pykolab.cli') | log = pykolab.getLogger('pykolab.cli') | ||||
conf = pykolab.getConf() | conf = pykolab.getConf() | ||||
def __init__(): | def __init__(): | ||||
commands.register('list_mailbox_acls', execute, description=description(), aliases=['lam']) | commands.register('list_mailbox_acls', execute, description=description(), aliases=['lam']) | ||||
def description(): | def description(): | ||||
return """Obtain a list of ACL entries on a folder.""" | return """Obtain a list of ACL entries on a folder.""" | ||||
def execute(*args, **kw): | def execute(*args, **kw): | ||||
try: | try: | ||||
folder = conf.cli_args.pop(0) | folder = conf.cli_args.pop(0) | ||||
except IndexError, errmsg: | except IndexError: | ||||
folder = utils.ask_question(_("Folder name")) | folder = utils.ask_question(_("Folder name")) | ||||
if len(folder.split('@')) > 1: | if len(folder.split('@')) > 1: | ||||
domain = folder.split('@')[1] | domain = folder.split('@')[1] | ||||
else: | else: | ||||
domain = conf.get('kolab', 'primary_domain') | domain = conf.get('kolab', 'primary_domain') | ||||
imap = IMAP() | imap = IMAP() | ||||
imap.connect(domain=domain) | imap.connect(domain=domain) | ||||
if not imap.has_folder(folder): | if not imap.has_folder(folder): | ||||
print >> sys.stderr, _("No such folder %r") % (folder) | print(_("No such folder %r") % (folder), file=sys.stderr) | ||||
else: | else: | ||||
acls = [] | acls = [] | ||||
folders = imap.list_folders(folder) | folders = imap.list_folders(folder) | ||||
for folder in folders: | for folder in folders: | ||||
print "Folder", folder | print("Folder", folder) | ||||
acls = imap.list_acls(folder) | acls = imap.list_acls(folder) | ||||
for acl in acls.keys(): | for acl in acls: | ||||
print " %-13s %s" %(acls[acl], acl) | print(" %-13s %s" %(acls[acl], acl)) | ||||