当前位置: 首页>>代码示例>>Python>>正文


Python translate._函数代码示例

本文整理汇总了Python中pykolab.translate._函数的典型用法代码示例。如果您正苦于以下问题:Python _函数的具体用法?Python _怎么用?Python _使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了_函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: add_custom_property

    def add_custom_property(self, name, value):
        if not name.upper().startswith('X-'):
            raise ValueError, _("Invalid custom property name %r") % (name)

        props = self.event.customProperties()
        props.append(kolabformat.CustomProperty(name.upper(), value))
        self.event.setCustomProperties(props)
开发者ID:tpokorra,项目名称:pykolab,代码行数:7,代码来源:event.py

示例2: cli_options

def cli_options():
    my_option_group = conf.add_cli_parser_option_group(_("List Options"))
    my_option_group.add_option( '--since',
                                dest    = "since",
                                action  = "store",
                                default = 0,
                                help    = _("Display sessions since ..."))
开发者ID:detrout,项目名称:pykolab,代码行数:7,代码来源:cmd_list_sessions.py

示例3: set_status

 def set_status(self, status):
     if status in self.status_map.keys():
         self.event.setStatus(self.status_map[status])
     elif status in self.status_map.values():
         self.event.setStatus(status)
     else:
         raise InvalidEventStatusError, _("Invalid status set: %r") % (status)
开发者ID:detrout,项目名称:pykolab,代码行数:7,代码来源:event.py

示例4: check_config

    def check_config(self, val=None):
        """
            Checks self.config_file or the filename passed using 'val'
            and returns a SafeConfigParser instance if everything is OK.
        """

        if not val == None:
            config_file = val
        else:
            config_file = self.config_file

        if not os.access(config_file, os.R_OK):
            log.error(_("Configuration file %s not readable") % config_file)

        config = SafeConfigParser()
        log.debug(_("Reading configuration file %s") % config_file, level=8)
        try:
            config.read(config_file)
        except:
            log.error(_("Invalid configuration file %s") % config_file)

        if not config.has_section("kolab"):
            log.warning(_("No master configuration section [kolab] in configuration file %s") % config_file)

        return config
开发者ID:detrout,项目名称:pykolab,代码行数:25,代码来源:__init__.py

示例5: set_participant_status

 def set_participant_status(self, participant_status):
     if participant_status in self.participant_status_map.keys():
         self.setPartStat(self.participant_status_map[participant_status])
     elif participant_status in self.participant_status_map.values():
         self.setPartStat(participant_status)
     else:
         raise InvalidAttendeeParticipantStatusError, _("Invalid participant status %r") % (participant_status)
开发者ID:tpokorra,项目名称:pykolab,代码行数:7,代码来源:attendee.py

示例6: store_object

def store_object(object, user_rec, targetfolder=None):
    """
        Append the given object to the user's default calendar/tasklist
    """
    
    # find default calendar folder to save object to
    if targetfolder is None:
        targetfolder = list_user_folders(user_rec, object.type)[0]
        if user_rec.has_key('_default_folder'):
            targetfolder = user_rec['_default_folder']
        # use *.confidential folder for invitations classified as confidential
        if object.get_classification() == kolabformat.ClassConfidential and user_rec.has_key('_confidential_folder'):
            targetfolder = user_rec['_confidential_folder']

    if not targetfolder:
        log.error(_("Failed to save %s: no target folder found for user %r") % (object.type, user_rec['mail']))
        return Fasle

    log.debug(_("Save %s %r to user folder %r") % (object.type, object.uid, targetfolder), level=8)

    try:
        imap.imap.m.select(imap.folder_utf7(targetfolder))
        result = imap.imap.m.append(
            imap.folder_utf7(targetfolder),
            None,
            None,
            object.to_message(creator="Kolab Server <[email protected]>").as_string()
        )
        return result

    except Exception, e:
        log.error(_("Failed to save %s to user folder at %r: %r") % (
            object.type, targetfolder, e
        ))
开发者ID:tpokorra,项目名称:pykolab,代码行数:34,代码来源:module_invitationpolicy.py

示例7: cli_options

def cli_options():
    my_option_group = conf.add_cli_parser_option_group(_("CLI Options"))
    my_option_group.add_option( '--all',
                                dest    = "all",
                                action  = "store_true",
                                default = False,
                                help    = _("All folders this user has access to"))
开发者ID:tpokorra,项目名称:pykolab,代码行数:7,代码来源:cmd_export_mailbox.py

示例8: command_set

    def command_set(self, *args, **kw):
        """
            Set a configuration option.

            Pass me a section, key and value please. Note that the section should
            already exist.

            TODO: Add a strict parameter
            TODO: Add key value checking
        """

        if not self.cfg_parser:
            self.read_config()

        if not len(args) == 3:
            log.error(_("Insufficient options. Need section, key and value -in that order."))

        if not self.cfg_parser.has_section(args[0]):
            log.error(_("No section '%s' exists.") % (args[0]))

        if '%' in args[2]:
            value = args[2].replace('%', '%%')
        else:
            value = args[2]

        self.cfg_parser.set(args[0], args[1], value)

        if hasattr(self, 'cli_keywords') and hasattr(self.cli_keywords, 'config_file'):
            fp = open(self.cli_keywords.config_file, "w+")
            self.cfg_parser.write(fp)
            fp.close()
        else:
            fp = open(self.config_file, "w+")
            self.cfg_parser.write(fp)
            fp.close()
开发者ID:tpokorra,项目名称:pykolab,代码行数:35,代码来源:__init__.py

示例9: cache_init

def cache_init():
    global cache, cache_expire, session

    if conf.has_section('kolab_smtp_access_policy'):
        if conf.has_option('kolab_smtp_access_policy', 'cache_uri'):
            cache_uri = conf.get('kolab_smtp_access_policy', 'cache_uri')
            cache = True
            if conf.has_option('kolab_smtp_access_policy', 'retention'):
                cache_expire = (int)(
                        conf.get(
                                'kolab_smtp_access_policy',
                                'retention'
                            )
                    )
        elif conf.has_option('kolab_smtp_access_policy', 'uri'):
            log.warning(_("The 'uri' setting in the kolab_smtp_access_policy section is soon going to be deprecated in favor of 'cache_uri'"))
            cache_uri = conf.get('kolab_smtp_access_policy', 'uri')
            cache = True
        else:
            return False
    else:
        return False

    if conf.debuglevel > 8:
        engine = create_engine(cache_uri, echo=True)
    else:
        engine = create_engine(cache_uri, echo=False)

    try:
        metadata.create_all(engine)
    except sqlalchemy.exc.OperationalError, e:
        log.error(_("Operational Error in caching: %s" % (e)))
        return False
开发者ID:detrout,项目名称:pykolab,代码行数:33,代码来源:kolab_smtp_access_policy.py

示例10: execute

def execute(*args, **kw):
    """
        Delete mailbox
    """

    if len(conf.cli_args) < 1:
        print >> sys.stderr, _("No mailbox specified")
        sys.exit(1)

    imap = IMAP()

    imap.connect()

    delete_folders = []
    while len(conf.cli_args) > 0:
        folder = conf.cli_args.pop(0)
        folders = imap.list_folders(folder)

        if len(folders) < 1:
            print >> sys.stderr, _("No such folder(s): %s") % (folder)

        delete_folders.extend(folders)

    if len(delete_folders) == 0:
        print >> sys.stderr, _("No folders to delete.")
        sys.exit(1)

    for delete_folder in delete_folders:
        try:
            imap.delete_mailfolder(delete_folder)
        except Exception, errmsg:
            log.error(_("Could not delete mailbox '%s'") % (delete_folder))
开发者ID:tpokorra,项目名称:pykolab,代码行数:32,代码来源:cmd_delete_mailbox.py

示例11: execute

def execute(*args, **kw):
    """
        Delete a message from a mail folder
    """

    try:
        folder = conf.cli_args.pop(0)

        try:
            uid = conf.cli_args.pop(0)
        except:
            log.error(_("Specify a UID"))
            sys.exit(1)
    except:
        log.error(_("Specify a folder"))
        sys.exit(1)

    imap = IMAP()
    imap.connect()

    _folder = imap.lm(folder)

    if _folder == None or _folder == []:
        log.error(_("No such folder"))
        sys.exit(1)

    imap.set_acl(folder, 'cyrus-admin', 'lrswt')

    imap.select(folder)

    imap.store(uid, '+FLAGS', '\\Deleted')
开发者ID:tpokorra,项目名称:pykolab,代码行数:31,代码来源:cmd_delete_message.py

示例12: test_014_owner_confirmation_decline

    def test_014_owner_confirmation_decline(self):
        self.purge_mailbox(self.john['mailbox'])
        self.purge_mailbox(self.jane['mailbox'])

        uid = self.send_itip_invitation(self.room3['mail'], datetime.datetime(2014,9,14, 9,0,0))

        # requester (john) gets a TENTATIVE confirmation
        response = self.check_message_received(self.itip_reply_subject % { 'summary':'test', 'status':participant_status_label('TENTATIVE') }, self.room3['mail'])
        self.assertIsInstance(response, email.message.Message)

        # check confirmation message sent to resource owner (jane)
        notify = self.check_message_received(_('Booking request for %s requires confirmation') % (self.room3['cn']), mailbox=self.jane['mailbox'])
        self.assertIsInstance(notify, email.message.Message)

        itip_event = events_from_message(notify)[0]

        # resource owner declines reservation request
        itip_reply = itip_event['xml'].to_message_itip(self.jane['mail'],
            method="REPLY",
            participant_status='DECLINED',
            message_text="Request declined",
            subject=_('Booking for %s has been %s') % (self.room3['cn'], participant_status_label('DECLINED'))
        )

        smtp = smtplib.SMTP('localhost', 10026)
        smtp.sendmail(self.jane['mail'], str(itip_event['organizer']), str(itip_reply))
        smtp.quit()

        # requester (john) now gets the DECLINED response
        response = self.check_message_received(self.itip_reply_subject % { 'summary':'test', 'status':participant_status_label('DECLINED') }, self.room3['mail'])
        self.assertIsInstance(response, email.message.Message)

        # tentative reservation was set to cancelled
        event = self.check_resource_calendar_event(self.room3['kolabtargetfolder'], uid)
        self.assertEqual(event, None)
开发者ID:tpokorra,项目名称:pykolab,代码行数:35,代码来源:test_005_resource_invitation.py

示例13: test_012_owner_notification

    def test_012_owner_notification(self):
        self.purge_mailbox(self.john['mailbox'])
        self.purge_mailbox(self.jane['mailbox'])

        self.send_itip_invitation(self.room1['mail'], datetime.datetime(2014,8,4, 13,0,0))

        # check notification message sent to resource owner (jane)
        notify = self.check_message_received(_('Booking for %s has been %s') % (self.room1['cn'], participant_status_label('ACCEPTED')), self.room1['mail'], self.jane['mailbox'])
        self.assertIsInstance(notify, email.message.Message)

        notification_text = str(notify.get_payload())
        self.assertIn(self.john['mail'], notification_text)
        self.assertIn(participant_status_label('ACCEPTED'), notification_text)

        self.purge_mailbox(self.john['mailbox'])

        # check notification sent to collection owner (jane)
        self.send_itip_invitation(self.rooms['mail'], datetime.datetime(2014,8,4, 12,30,0))

        # one of the collection members accepted the reservation
        accepted = self.check_message_received(self.itip_reply_subject % { 'summary':'test', 'status':participant_status_label('ACCEPTED') })
        delegatee = self.find_resource_by_email(accepted['from'])

        notify = self.check_message_received(_('Booking for %s has been %s') % (delegatee['cn'], participant_status_label('ACCEPTED')), delegatee['mail'], self.jane['mailbox'])
        self.assertIsInstance(notify, email.message.Message)
        self.assertIn(self.john['mail'], notification_text)
开发者ID:tpokorra,项目名称:pykolab,代码行数:26,代码来源:test_005_resource_invitation.py

示例14: imap_proxy_auth

def imap_proxy_auth(user_rec):
    """
        Perform IMAP login using proxy authentication with admin credentials
    """
    global imap

    mail_attribute = conf.get('cyrus-sasl', 'result_attribute')
    if mail_attribute == None:
        mail_attribute = 'mail'

    mail_attribute = mail_attribute.lower()

    if not user_rec.has_key(mail_attribute):
        log.error(_("User record doesn't have the mailbox attribute %r set" % (mail_attribute)))
        return False

    # do IMAP prox auth with the given user
    backend = conf.get('kolab', 'imap_backend')
    admin_login = conf.get(backend, 'admin_login')
    admin_password = conf.get(backend, 'admin_password')

    try:
        imap.disconnect()
        imap.connect(login=False)
        imap.login_plain(admin_login, admin_password, user_rec[mail_attribute])
    except Exception, errmsg:
        log.error(_("IMAP proxy authentication failed: %r") % (errmsg))
        return False
开发者ID:tpokorra,项目名称:pykolab,代码行数:28,代码来源:module_invitationpolicy.py

示例15: read_request_input

def read_request_input():
    """
        Read a single policy request from sys.stdin, and return a dictionary
        containing the request.
    """

    start_time = time.time()

    log.debug(_("Starting to loop for new request"))

    policy_request = {}

    end_of_request = False
    while not end_of_request:
        if (time.time()-start_time) >= conf.timeout:
            log.warning(_("Timeout for policy request reading exceeded"))
            sys.exit(0)

        request_line = sys.stdin.readline()
        if request_line.strip() == '':
            if policy_request.has_key('request'):
                log.debug(_("End of current request"), level=8)
                end_of_request = True
        else:
            request_line = request_line.strip()
            log.debug(_("Getting line: %s") % (request_line), level=8)
            policy_request[request_line.split('=')[0]] = \
                '='.join(request_line.split('=')[1:]).lower()

    log.debug(_("Returning request"))

    return policy_request
开发者ID:detrout,项目名称:pykolab,代码行数:32,代码来源:kolab_smtp_access_policy.py


注:本文中的pykolab.translate._函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。