Example #1
0
    def setup_class(self, *args, **kw):
        conf = pykolab.getConf()
        conf.finalize_conf(fatal=False)

        self.login = conf.get('ldap', 'bind_dn')
        self.password = conf.get('ldap', 'bind_pw')
        self.domain = conf.get('kolab', 'primary_domain')
Example #2
0
    def __init__(self, *args, **kw):
        # load pykolab conf
        conf = pykolab.getConf()
        if not hasattr(conf, 'defaults'):
            conf.finalize_conf(fatal=False)

        self.imap = IMAP()
Example #3
0
    def setup_class(self, *args, **kw):
        conf = pykolab.getConf()
        conf.finalize_conf(fatal=False)

        self.login = conf.get('ldap', 'bind_dn')
        self.password = conf.get('ldap', 'bind_pw')
        self.domain = conf.get('kolab', 'primary_domain')
Example #4
0
    def __init__(self, *args, **kw):
        # load pykolab conf
        self.pykolab_conf = pykolab.getConf()
        if not hasattr(self.pykolab_conf, 'defaults'):
            self.pykolab_conf.finalize_conf(fatal=False)

        self.ldap = Auth()
        self.ldap.connect()
Example #5
0
def send_reply(from_address, itip_events, response_text, subject=None):
    """
        Send the given iCal events as a valid iTip REPLY to the organizer.
    """
    import smtplib

    conf = pykolab.getConf()
    smtp = None

    if isinstance(itip_events, dict):
        itip_events = [ itip_events ]

    for itip_event in itip_events:
        attendee = itip_event['xml'].get_attendee_by_email(from_address)
        participant_status = itip_event['xml'].get_ical_attendee_participant_status(attendee)

        log.debug(_("Send iTip reply %s for %s %r") % (participant_status, itip_event['xml'].type, itip_event['xml'].uid), level=8)

        event_summary = itip_event['xml'].get_summary()
        message_text = response_text % { 'summary':event_summary, 'status':participant_status_label(participant_status), 'name':attendee.get_name() }

        if subject is not None:
            subject = subject % { 'summary':event_summary, 'status':participant_status_label(participant_status), 'name':attendee.get_name() }

        try:
            message = itip_event['xml'].to_message_itip(from_address,
                method="REPLY",
                participant_status=participant_status,
                message_text=message_text,
                subject=subject
            )
        except Exception, e:
            log.error(_("Failed to compose iTip reply message: %r: %s") % (e, traceback.format_exc()))
            return

        smtp = smtplib.SMTP("localhost", 10026)  # replies go through wallace again

        if conf.debuglevel > 8:
            smtp.set_debuglevel(True)

        try:
            smtp.sendmail(message['From'], message['To'], message.as_string())
        except Exception, e:
            log.error(_("SMTP sendmail error: %r") % (e))
Example #6
0
def send_reply(from_address, itip_events, response_text, subject=None):
    """
        Send the given iCal events as a valid iTip REPLY to the organizer.
    """
    import smtplib

    conf = pykolab.getConf()
    smtp = None

    if isinstance(itip_events, dict):
        itip_events = [ itip_events ]

    for itip_event in itip_events:
        attendee = itip_event['xml'].get_attendee_by_email(from_address)
        participant_status = itip_event['xml'].get_ical_attendee_participant_status(attendee)

        log.debug(_("Send iTip reply %s for %s %r") % (participant_status, itip_event['xml'].type, itip_event['xml'].uid), level=8)

        event_summary = itip_event['xml'].get_summary()
        message_text = response_text % { 'summary':event_summary, 'status':participant_status_label(participant_status), 'name':attendee.get_name() }

        if subject is not None:
            subject = subject % { 'summary':event_summary, 'status':participant_status_label(participant_status), 'name':attendee.get_name() }

        try:
            message = itip_event['xml'].to_message_itip(from_address,
                method="REPLY",
                participant_status=participant_status,
                message_text=message_text,
                subject=subject
            )
        except Exception, e:
            log.error(_("Failed to compose iTip reply message: %r: %s") % (e, traceback.format_exc()))
            return

        smtp = smtplib.SMTP("localhost", 10026)  # replies go through wallace again

        if conf.debuglevel > 8:
            smtp.set_debuglevel(True)

        try:
            smtp.sendmail(message['From'], message['To'], message.as_string())
        except Exception, e:
            log.error(_("SMTP sendmail error: %r") % (e))
    def test_001_list_options_user_preferredlanguage(self):
        conf = pykolab.getConf()
        conf.finalize_conf(fatal=False)

        self.login = conf.get('ldap', 'bind_dn')
        self.password = conf.get('ldap', 'bind_pw')
        self.domain = conf.get('kolab', 'primary_domain')

        result = wap_client.authenticate(self.login, self.password, self.domain)

        attribute_values = wap_client.form_value_select_options(
                'user',
                1,
                'preferredlanguage'
            )

        self.assertTrue(attribute_values['preferredlanguage'].has_key('default'))
        self.assertTrue(attribute_values['preferredlanguage'].has_key('list'))
        self.assertTrue(len(attribute_values['preferredlanguage']['list']) > 1)
        self.assertTrue(attribute_values['preferredlanguage']['default'] in attribute_values['preferredlanguage']['list'])
Example #8
0
def send_request(to_address, itip_events, request_text, subject=None, direct=False):
    """
        Send an iTip REQUEST message from the given iCal events
    """
    import smtplib

    conf = pykolab.getConf()
    smtp = None

    if isinstance(itip_events, dict):
        itip_events = [ itip_events ]

    for itip_event in itip_events:
        event_summary = itip_event['xml'].get_summary()
        message_text = request_text % { 'summary':event_summary }

        if subject is not None:
            subject = subject % { 'summary':event_summary }

        try:
            message = itip_event['xml'].to_message_itip(None,
                method="REQUEST",
                message_text=message_text,
                subject=subject
            )
        except Exception, e:
            log.error(_("Failed to compose iTip request message: %r") % (e))
            return

        port = 10027 if direct else 10026
        smtp = smtplib.SMTP("localhost", port)

        if conf.debuglevel > 8:
            smtp.set_debuglevel(True)

        try:
            smtp.sendmail(message['From'], to_address, message.as_string())
        except Exception, e:
            log.error(_("SMTP sendmail error: %r") % (e))
Example #9
0
def send_request(to_address, itip_events, request_text, subject=None, direct=False):
    """
        Send an iTip REQUEST message from the given iCal events
    """
    import smtplib

    conf = pykolab.getConf()
    smtp = None

    if isinstance(itip_events, dict):
        itip_events = [ itip_events ]

    for itip_event in itip_events:
        event_summary = itip_event['xml'].get_summary()
        message_text = request_text % { 'summary':event_summary }

        if subject is not None:
            subject = subject % { 'summary':event_summary }

        try:
            message = itip_event['xml'].to_message_itip(None,
                method="REQUEST",
                message_text=message_text,
                subject=subject
            )
        except Exception, e:
            log.error(_("Failed to compose iTip request message: %r") % (e))
            return

        port = 10027 if direct else 10026
        smtp = smtplib.SMTP("localhost", port)

        if conf.debuglevel > 8:
            smtp.set_debuglevel(True)

        try:
            smtp.sendmail(message['From'], to_address, message.as_string())
        except Exception, e:
            log.error(_("SMTP sendmail error: %r") % (e))
Example #10
0
 def __init__(self):
     self.primaryDomain = "example.org"
     self.resourceOu = u'ou=Resources,dc=example,dc=org'
     self.conf = pykolab.getConf()
     self.conf.finalize_conf()
Example #11
0
# 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.imap import IMAP
from pykolab.translate import _

log = pykolab.getLogger('pykolab.cli')
conf = pykolab.getConf()

def __init__():
    commands.register('undelete_mailbox', execute, description=description())

def cli_options():
    my_option_group = conf.add_cli_parser_option_group(_("CLI Options"))
    my_option_group.add_option( '--dry-run',
                                dest    = "dry_run",
                                action  = "store_true",
                                default = False,
                                help    = _("Do not actually execute, but state what would have been executed."))

def description(*args, **kw):
    return _("Recover mailboxes previously deleted.")
Example #12
0
# 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 logging
import os
import pdb
import sys
import traceback

import pykolab

from pykolab.translate import _

log = pykolab.getLogger('pykolab.plugins')
conf = pykolab.getConf()

class KolabPlugins(object):
    """
        Detects, loads and interfaces with plugins for different
        Kolab components.
    """
    def __init__(self):
        """
            Searches the plugin directory for plugins, and loads
            them into a list.
        """
        self.plugins = {}

        for plugin_path in [
                os.path.dirname(__file__),
Example #13
0
def setup_package():
    conf = pykolab.getConf()
    conf.finalize_conf(fatal=False)
Example #14
0
 def __init__(self):
     self.primaryDomain = "example.org"
     self.resourceOu = u'ou=Resources,dc=example,dc=org'
     self.conf = pykolab.getConf()
     self.conf.finalize_conf()
Example #15
0
def setup_package():
    conf = pykolab.getConf()
    conf.finalize_conf(fatal=False)