Changeset View
Changeset View
Standalone View
Standalone View
pykolab/cli/cmd_add_user_subscription.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 _ | ||||
Show All 40 Lines | if backend == None: | ||||
backend = conf.get('kolab', 'imap_backend') | backend = conf.get('kolab', 'imap_backend') | ||||
admin_login = conf.get(backend, 'admin_login') | admin_login = conf.get(backend, 'admin_login') | ||||
admin_password = conf.get(backend, 'admin_password') | admin_password = conf.get(backend, 'admin_password') | ||||
imap.login_plain(admin_login, admin_password, user) | imap.login_plain(admin_login, admin_password, user) | ||||
if not imap.has_folder(folder_pattern): | if not imap.has_folder(folder_pattern): | ||||
print >> sys.stderr, \ | print(_("Cannot subscribe user to folder %r:") % (folder_pattern), \ | ||||
_("Cannot subscribe user to folder %r:") % (folder_pattern), \ | _("No such folder"), \ | ||||
_("No such folder") | file=sys.stderr) | ||||
sys.exit(1) | sys.exit(1) | ||||
_folders = imap.lm(folder_pattern) | _folders = imap.lm(folder_pattern) | ||||
for _folder in _folders: | for _folder in _folders: | ||||
imap.subscribe(_folder) | imap.subscribe(_folder) | ||||