• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python parameters.get_admin函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: send_autoreply

def send_autoreply(sender, mailbox, armessage):
    if armessage.fromdate > timezone.now():
        return
    if armessage.untildate is not None \
        and armessage.untildate < timezone.now():
        armessage.enabled = False
        armessage.save()
        return

    try:
        lastar = ARhistoric.objects.get(armessage=armessage.id, sender=sender)
        PostfixAutoreply().load()
        timeout = parameters.get_admin("AUTOREPLIES_TIMEOUT",
                                       app="postfix_autoreply")
        delta = datetime.timedelta(seconds=int(timeout))
        now = timezone.make_aware(datetime.datetime.now(),
                                  timezone.get_default_timezone())
        if lastar.last_sent + delta > now:
            sys.exit(0)
    except ARhistoric.DoesNotExist:
        lastar = ARhistoric()
        lastar.armessage = armessage
        lastar.sender = sender

    sendmail_simple(mailbox.user.encoded_address, sender, armessage.subject,
                    armessage.content.encode('utf-8'))

    lastar.last_sent = datetime.datetime.now()
    lastar.save()
开发者ID:eignatov,项目名称:modoboa,代码行数:29,代码来源:autoreply.py


示例17: account_auto_created

def account_auto_created(user):
    from modoboa.core.models import User
    from modoboa.lib.permissions import grant_access_to_object
    from .lib import check_if_domain_exists

    if parameters.get_admin("AUTO_CREATE_DOMAIN_AND_MAILBOX") == "no":
        return
    localpart, domname = split_mailbox(user.username)
    if user.group != 'SimpleUsers' and domname is None:
        return
    sadmins = User.objects.filter(is_superuser=True)
    try:
        domain = Domain.objects.get(name=domname)
    except Domain.DoesNotExist:
        label = check_if_domain_exists(
            domname, [(DomainAlias, _('domain alias'))])
        if label is not None:
            return
        domain = Domain(name=domname, enabled=True, quota=0)
        domain.save(creator=sadmins[0])
        for su in sadmins[1:]:
            grant_access_to_object(su, domain)
    try:
        mb = Mailbox.objects.get(domain=domain, address=localpart)
    except Mailbox.DoesNotExist:
        mb = Mailbox(
            address=localpart, domain=domain, user=user, use_domain_quota=True
        )
        mb.set_quota(override_rules=True)
        mb.save(creator=sadmins[0])
        for su in sadmins[1:]:
            grant_access_to_object(su, mb)
开发者ID:ezhishui,项目名称:modoboa,代码行数:32,代码来源:callbacks.py


示例18: decrypt

def decrypt(ciph):
    obj = AES.new(
        parameters.get_admin("SECRET_KEY", app="admin"), AES.MODE_ECB
    )
    ciph = base64.b64decode(ciph)
    clear = obj.decrypt(ciph)
    return clear.rstrip(' ')
开发者ID:juju2013,项目名称:modoboa,代码行数:7,代码来源:lib.py


示例19: load_from_master_cf

    def load_from_master_cf(self):
        """Load services from the master.cf file.

        Parse the configuration file to update the service table. New
        entries are saved and outdated ones (ie. present in the
        database but not in the file) are removed.
        """
        with open(parameters.get_admin('MASTER_CF_PATH')) as fp:
            content = fp.read()
        services = []
        for line in content.split('\n'):
            if not line or line.startswith('#'):
                continue
            parts = line.strip().split()
            if len(parts) != 8:
                continue
            if parts[7] != 'smtp':
                continue
            srv, created = self.get_or_create(name=parts[0])
            services.append(parts[0])
        to_delete = []
        for service in self.all():
            if service.name not in services:
                to_delete.append(service.name)
        Service.objects.filter(name__in=to_delete).delete()
开发者ID:kaxdev,项目名称:modoboa,代码行数:25,代码来源:models.py


示例20: attachments

def attachments(request, tplname="webmail/attachments.html"):
    if request.method == "POST":
        csuploader = AttachmentUploadHandler()
        request.upload_handlers.insert(0, csuploader)
        error = None
        form = AttachmentForm(request.POST, request.FILES)
        if form.is_valid():
            try:
                fobj = request.FILES["attachment"]
                tmpname = save_attachment(fobj)
                request.session["compose_mail"]["attachments"] \
                    += [{"fname" : str(fobj),
                         "content-type" : fobj.content_type,
                         "size" : fobj.size,
                         "tmpname" : os.path.basename(tmpname)}]
                request.session.modified = True
                return _render(request, "webmail/upload_done.html", {
                        "status" : "ok", "fname" : request.FILES["attachment"],
                        "tmpname" : os.path.basename(tmpname)
                        })
            except WebmailError, inst:
                error = _("Failed to save attachment: ") + str(inst)

        if csuploader.toobig:
            error = _("Attachment is too big (limit: %s)" \
                          % parameters.get_admin("MAX_ATTACHMENT_SIZE"))
        return _render(request, "webmail/upload_done.html", {
                "status" : "ko", "error" : error
                })
开发者ID:ricardopadilha,项目名称:modoboa,代码行数:29,代码来源:views.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python parameters.get_user函数代码示例发布时间:2022-05-27
下一篇:
Python events.raiseQueryEvent函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap