示例#1
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
示例#2
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
示例#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