Пример #1
0
    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.
        """
        admin_params = dict(param_tools.get_global_parameters("admin"))
        if not admin_params.get("handle_mailboxes"):
            return None
        if self.__mail_home is None:
            curuser = pwd.getpwuid(os.getuid()).pw_name
            mbowner = admin_params["mailboxes_owner"]
            options = {}
            if curuser != mbowner:
                options["sudo_user"] = mbowner
            code, output = exec_cmd(
                "doveadm user -f home %s" % 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
Пример #2
0
    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
Пример #3
0
 def url(self):
     server_location = param_tools.get_global_parameter(
         "server_location", app="modoboa_radicale")
     if not server_location:
         raise lib_exceptions.InternalError(
             _("Server location is not set, please fix it."))
     return os.path.join(server_location, self.user.username, self._path)
Пример #4
0
 def url(self):
     """Return the calendar URL."""
     if not hasattr(self, "_url"):
         server_location = parameters.get_admin("SERVER_LOCATION")
         if not server_location:
             raise lib_exceptions.InternalError(
                 _("Server location is not set, please fix it."))
         self._url = os.path.join(server_location, self.path)
     return self._url
Пример #5
0
 def url(self):
     """Return the calendar URL."""
     if not hasattr(self, "_url"):
         server_location = param_tools.get_global_parameter(
             "server_location")
         if not server_location:
             raise lib_exceptions.InternalError(
                 _("Server location is not set, please fix it."))
         self._url = os.path.join(server_location, self.path)
     return self._url
Пример #6
0
 def rrdtool_binary(self):
     """Return path to rrdtool binary."""
     dpath = None
     code, output = exec_cmd("which rrdtool")
     if not code:
         dpath = output.strip()
     else:
         known_paths = getattr(
             settings, "RRDTOOL_LOOKUP_PATH",
             ("/usr/bin/rrdtool", "/usr/local/bin/rrdtool"))
         for fpath in known_paths:
             if os.path.isfile(fpath) and os.access(fpath, os.X_OK):
                 dpath = fpath
     if dpath is None:
         raise exceptions.InternalError(
             _("Failed to locate rrdtool binary."))
     return dpath
Пример #7
0
    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.
        """
        admin_params = dict(param_tools.get_global_parameters("admin"))
        if not admin_params.get("handle_mailboxes"):
            return None
        if self.__mail_home is None:
            code, output = doveadm_cmd("user -f home %s" % self.full_address)
            if code:
                raise lib_exceptions.InternalError(
                    _("Failed to retrieve mailbox location (%s)") % output)
            self.__mail_home = force_text(output.strip())
        return self.__mail_home