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


Python parameters.get_admin函数代码示例

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


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

示例1: __init__

 def __init__(self, user=None, password=None):
     self.__hdelimiter = None
     self.quota_usage = -1
     self.criterions = []
     self.address = parameters.get_admin("IMAP_SERVER")
     self.port = int(parameters.get_admin("IMAP_PORT"))
     self.login(user, password)
开发者ID:digideskio,项目名称:modoboa-webmail,代码行数:7,代码来源:imaputils.py

示例2: handle

 def handle(self, *args, **options):
     Stats().load()
     if options["logfile"] is None:
         options["logfile"] = parameters.get_admin("LOGFILE", app="stats")
     p = LogParser(options, parameters.get_admin("RRD_ROOTDIR", app="stats"))
     p.process()
     db.close_connection()
开发者ID:finid,项目名称:modoboa,代码行数:7,代码来源:logparser.py

示例3: extra_static_content

def extra_static_content(user):
    if user.group == "SimpleUsers":
        return []

    tpl = Template("""<script type="text/javascript">
$(document).ready(function() {
    {% if user_can_release == "no" %}var poller = new Poller("{{ url }}", {
        interval: {{ interval }},
        success_cb: function(data) {
            var $link = $("#nbrequests");
            if (data.requests > 0) {
                $link.html(data.requests + " " + "{{ text }}");
                $link.parent().removeClass('hidden');
            } else {
                $link.parent().addClass('hidden');
            }
        }
    });{% endif %}

    $(document).bind('domform_init', function() {
        activate_widget.call($('#id_spam_subject_tag2_act'));
    });
});
</script>""")

    return [tpl.render(
        Context(dict(
            url=reverse("modoboa.extensions.amavis.views.nbrequests"),
            interval=int(parameters.get_admin("CHECK_REQUESTS_INTERVAL")) * 1000,
            text=_("pending requests"),
            user_can_release=parameters.get_admin("USER_CAN_RELEASE")
        ))
    )]
开发者ID:schiiz1,项目名称:modoboa,代码行数:33,代码来源:__init__.py

示例4: mail_home

    def mail_home(self):
        """Retrieve the home directory of this mailbox.

        The home directory refers to the place on the file system
        where the mailbox data is stored.

        We ask dovecot to give us this information because there are
        several patterns to understand and we don't want to implement
        them.
        """
        hm = parameters.get_admin("HANDLE_MAILBOXES", raise_error=False)
        if hm is None or hm == "no":
            return None
        if self.__mail_home is None:
            curuser = pwd.getpwuid(os.getuid()).pw_name
            mbowner = parameters.get_admin("MAILBOXES_OWNER")
            options = {}
            if curuser != mbowner:
                options['sudo_user'] = mbowner
            code, output = exec_cmd(
                "doveadm user %s -f home" % self.full_address, **options
            )
            if code:
                raise lib_exceptions.InternalError(
                    _("Failed to retrieve mailbox location (%s)" % output))
            self.__mail_home = output.strip()
        return self.__mail_home
开发者ID:cubicuboctahedron,项目名称:modoboa,代码行数:27,代码来源:mailbox.py

示例5: handle

    def handle(self, *args, **options):
        Amavis().load()
        if options["debug"]:
            import logging
            l = logging.getLogger("django.db.backends")
            l.setLevel(logging.DEBUG)
            l.addHandler(logging.StreamHandler())
        self.verbose = options["verbose"]

        max_messages_age = int(parameters.get_admin("MAX_MESSAGES_AGE",
                                                    app="amavis"))

        flags = ['D']
        if parameters.get_admin("RELEASED_MSGS_CLEANUP",
                                app="amavis") == "yes":
            flags += ['R']

        self.__vprint("Deleting marked messages...")
        ids = Msgrcpt.objects.filter(rs__in=flags).values("mail_id").distinct()
        for msg in Msgs.objects.filter(mail_id__in=ids):
            if not msg.msgrcpt_set.exclude(rs__in=flags).count():
                msg.delete()

        self.__vprint(
            "Deleting messages older than %d days..." % max_messages_age)
        limit = int(time.time()) - (max_messages_age * 24 * 3600)
        Msgs.objects.filter(time_num__lt=limit).delete()

        self.__vprint("Deleting unreferenced e-mail addresses...")
        for maddr in Maddr.objects.all():
            if not maddr.msgs_set.count() and not maddr.msgrcpt_set.count():
                maddr.delete()

        self.__vprint("Done.")
开发者ID:kaxdev,项目名称:modoboa,代码行数:34,代码来源:qcleanup.py

示例6: delete

    def delete(self, fromuser, keepdir=False):
        from modoboa.lib.permissions import \
            ungrant_access_to_object, ungrant_access_to_objects

        if self.domainalias_set.count():
            events.raiseEvent("DomainAliasDeleted", self.domainalias_set.all())
            ungrant_access_to_objects(self.domainalias_set.all())
        if self.mailbox_set.count():
            Quota.objects.filter(username__contains='@%s' % self.name).delete()
            events.raiseEvent("DeleteMailbox", self.mailbox_set.all())
            ungrant_access_to_objects(self.mailbox_set.all())
            hm = parameters.get_admin("HANDLE_MAILBOXES", raise_error=False)
            if hm == "yes" and not keepdir:
                for mb in self.mailbox_set.all():
                    MailboxOperation.objects.create(
                        type='delete', argument=mb.mail_home
                    )
        if self.alias_set.count():
            events.raiseEvent("MailboxAliasDelete", self.alias_set.all())
            ungrant_access_to_objects(self.alias_set.all())
        if parameters.get_admin("AUTO_ACCOUNT_REMOVAL") == "yes":
            for account in User.objects.filter(mailbox__domain__name=self.name):
                account.delete(fromuser, keepdir)
        events.raiseEvent("DeleteDomain", self)
        ungrant_access_to_object(self)
        super(Domain, self).delete()
开发者ID:ricardopadilha,项目名称:modoboa,代码行数:26,代码来源:models.py

示例7: __init__

 def __init__(self, user, recipient_db):
     """Constructor."""
     self._sa_is_local = parameters.get_admin("SA_IS_LOCAL")
     self._default_username = parameters.get_admin("DEFAULT_USER")
     self._recipient_db = recipient_db
     self._setup_cache = {}
     self._username_cache = []
     if user.group == "SimpleUsers":
         user_level_learning = parameters.get_admin("USER_LEVEL_LEARNING")
         if user_level_learning == "yes":
             self._username = user.email
     else:
         self._username = None
     self.error = None
     if self._sa_is_local == "yes":
         self._learn_cmd = "sa-learn --{0} --no-sync -u {1}"
         self._learn_cmd_kwargs = {}
         self._expected_exit_codes = [0]
     else:
         self._learn_cmd = "spamc -d {0} -p {1}".format(
             parameters.get_admin("SPAMD_ADDRESS"),
             parameters.get_admin("SPAMD_PORT")
         )
         self._learn_cmd += " -L {0} -u {1}"
         self._learn_cmd_kwargs = {}
         self._expected_exit_codes = [5, 6]
开发者ID:kaxdev,项目名称:modoboa,代码行数:26,代码来源:lib.py

示例8: _domains

def _domains(request):
    sort_order, sort_dir = get_sort_order(request.GET, "name")
    filters = dict(
        (flt, request.GET.get(flt, None))
        for flt in ['domfilter', 'searchquery']
        + events.raiseQueryEvent('ExtraDomainFilters')
    )
    request.session['domains_filters'] = filters
    domainlist = get_domains(request.user, **filters)
    if sort_order == 'name':
        domainlist = sorted(
            domainlist,
            key=lambda d: getattr(d, sort_order), reverse=sort_dir == '-'
        )
    else:
        domainlist = sorted(domainlist, key=lambda d: d.tags[0],
                            reverse=sort_dir == '-')
    context = {
        "handle_mailboxes": parameters.get_admin(
            "HANDLE_MAILBOXES", raise_error=False),
        "auto_account_removal": parameters.get_admin("AUTO_ACCOUNT_REMOVAL")
    }
    page = get_listing_page(domainlist, request.GET.get("page", 1))
    if page is None:
        context["length"] = 0
    else:
        context["rows"] = _render_to_string(
            request, "admin/domains_table.html", {
                'domains': page.object_list,
            }
        )
        context["pages"] = [page.number]
    return render_to_json_response(context)
开发者ID:ezhishui,项目名称:modoboa,代码行数:33,代码来源:domain.py

示例9: _find_user_dn

 def _find_user_dn(self, user):
     sbase = parameters.get_admin("LDAP_SEARCH_BASE", app="core")
     sfilter = parameters.get_admin("LDAP_SEARCH_FILTER", app="core")
     sfilter = sfilter % {"user": user}
     res = self.conn.search_s(sbase, ldap.SCOPE_SUBTREE, sfilter)
     try:
         dn = res[0][0]
     except IndexError:
         return None
     return dn
开发者ID:JHei,项目名称:modoboa,代码行数:10,代码来源:ldaputils.py

示例10: delete_dir

 def delete_dir(self):
     hm = parameters.get_admin("HANDLE_MAILBOXES", raise_error=False)
     if hm is None or hm == "no":
         return
     if not os.path.exists(self.mail_home):
         return
     code, output = exec_cmd(
         "rm -r %s" % self.mail_home,
         sudo_user=parameters.get_admin("MAILBOXES_OWNER")
     )
     if code:
         raise AdminError(_("Failed to remove mailbox: %s" % output))
开发者ID:juju2013,项目名称:modoboa,代码行数:12,代码来源:models.py

示例11: rename_dir

 def rename_dir(self, old_mail_home):
     hm = parameters.get_admin("HANDLE_MAILBOXES", raise_error=False)
     if hm is None or hm == "no":
         return
     self.__mail_home = None
     if not os.path.exists(old_mail_home):
         return
     code, output = exec_cmd(
         "mv %s %s" % (old_mail_home, self.mail_home),
         sudo_user=parameters.get_admin("MAILBOXES_OWNER")
     )
     if code:
         raise AdminError(_("Failed to rename mailbox: %s" % output))
开发者ID:juju2013,项目名称:modoboa,代码行数:13,代码来源:models.py

示例12: mail_home

    def mail_home(self):
        """

        """
        hm = parameters.get_admin("HANDLE_MAILBOXES", raise_error=False)
        if hm is None or hm == "no":
            return None
        if self.__mail_home is None:
            code, output = exec_cmd("doveadm user %s -f home" % self.full_address, 
                                    sudo_user=parameters.get_admin("MAILBOXES_OWNER"))
            if code:
                raise AdminError(_("Failed to retrieve mailbox location (%s)" % output))
            self.__mail_home = output.strip()
        return self.__mail_home
开发者ID:juju2013,项目名称:modoboa,代码行数:14,代码来源:models.py

示例13: index

def index(request):
    """Default view."""
    check_learning_rcpt = "false"
    if parameters.get_admin("MANUAL_LEARNING") == "yes":
        if request.user.group != "SimpleUsers":
            user_level_learning = parameters.get_admin(
                "USER_LEVEL_LEARNING") == "yes"
            domain_level_learning = parameters.get_admin(
                "DOMAIN_LEVEL_LEARNING") == "yes"
            if user_level_learning or domain_level_learning:
                check_learning_rcpt = "true"
    return render(request, "amavis/index.html", dict(
        selection="quarantine", check_learning_rcpt=check_learning_rcpt
    ))
开发者ID:kaxdev,项目名称:modoboa,代码行数:14,代码来源:views.py

示例14: __init__

 def __init__(self):
     mode = parameters.get_admin("AM_PDP_MODE")
     try:
         if mode == "inet":
             host = parameters.get_admin('AM_PDP_HOST')
             port = parameters.get_admin('AM_PDP_PORT')
             self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
             self.sock.connect((host, int(port)))
         else:
             path = parameters.get_admin('AM_PDP_SOCKET')
             self.sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
             self.sock.connect(path)
     except socket.error, err:
         raise ModoboaException(_("Connection to amavis failed: %s" % str(err)))
开发者ID:Tdey,项目名称:modoboa,代码行数:14,代码来源:lib.py

示例15: __init__

 def __init__(self, user, *args, **kwargs):
     """Constructor."""
     super(LearningRecipientForm, self).__init__(*args, **kwargs)
     choices = []
     if user.group == "SuperAdmins":
         choices.append(("global", _("Global database")))
     domain_level_learning = parameters.get_admin(
         "DOMAIN_LEVEL_LEARNING") == "yes"
     user_level_learning = parameters.get_admin(
         "USER_LEVEL_LEARNING") == "yes"
     if domain_level_learning:
         choices.append(("domain", _("Domain's database")))
     if user_level_learning:
         choices.append(("user", _("User's database")))
     self.fields["recipient"].choices = choices
开发者ID:finid,项目名称:modoboa,代码行数:15,代码来源:forms.py


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