Ejemplo n.º 1
0
    def process_postgresql_conf(self):
        with cuisine_sudo():
            pg_hba = cuisine.file_read(self.postgresql_conf_path())

            # replaces "#listen_addresses = 'localhost'	" type of lines
            # with "listen_addresses = '*'"
            new_text, replaced = text_replace_line_re(pg_hba, ".*listen_addresses\s*=", "listen_addresses = '*'	")

        return new_text
Ejemplo n.º 2
0
    def configure_virtualenv(self):
        # configure virtualenv - we don't need it for WSGI, however, it's required for ./manage.py and django-admin.py
        if self.use_virtualenv:
            activate_file_name = path(self.virtualenv_path).joinpath(self.virtualenv_name).joinpath('bin/activate')
            activate_text = file_read(activate_file_name)
            new_activate_text = text_ensure_line(activate_text,
                'export DJANGO_SETTINGS_MODULE="%s"' % self.settings_module)

            if new_activate_text != activate_text:
                file_write(activate_file_name, unix_eol(new_activate_text))
Ejemplo n.º 3
0
    def set_debug(self, debug):
        with cuisine_sudo():
            settings_file_path = path(self.src_root).joinpath(self.settings_module.replace(".", "/") + ".py")
            settings_content = cuisine.file_read(settings_file_path)

            # replaces "#listen_addresses = 'localhost'	" type of lines
            # with "listen_addresses = '*'"
            settings_content, replaced = text_replace_line_re(settings_content, "^DEBUG\s*=", "DEBUG=%s" % debug)

            return cuisine.file_write(settings_file_path, unix_eol(settings_content)), replaced
Ejemplo n.º 4
0
    def process_pg_hba_conf(self):
        with cuisine_sudo():
            pg_hba = cuisine.file_read(self.pg_hba_path())

            # replaces "host all all 127.0.0.1/32 md5" type of lines
            # with "host all all 0.0.0.0/0 md5"
            host_replaced, replaced = text_replace_line_re(pg_hba, "^host[\s\w\./]+$", "host\tall\tall\t0.0.0.0/0\tmd5")

            local_replaced, replaced = text_replace_line_re(
                host_replaced, "^local\s+all\s+all.*$", "local\tall\tall\t\tmd5"
            )

        return local_replaced