Ejemplo n.º 1
0
    def list(self, listfile):
        cparser = A.AnyConfigParser(self.itype)
        data = cparser.load(listfile)

        if not data.get("files", False):
            raise RuntimeError(
                "'files' not defined in given filelist: " + listfile
            )

        return U.unique(U.concat(self._parse(o) for o in data.files))
Ejemplo n.º 2
0
    def list(self, listfile):
        """
        Read paths from given file line by line and returns path list sorted by
        dir names. There some speical parsing rules for the file list:

        * Empty lines or lines start with "#" are ignored.
        * The lines contain "*" (glob match) will be expanded to real dir or
          file names: ex. "/etc/httpd/conf/*" will be
          ["/etc/httpd/conf/httpd.conf", "/etc/httpd/conf/magic", ...] .

        :param listfile: Path list file name or "-" (read list from stdin)
        """
        return U.unique(
            U.concat(self._parse(l) for l in lopen(listfile).readlines() if l)
        )
Ejemplo n.º 3
0
    "/etc/httpd/conf.d",
    "/etc/httpd/conf.d/*",  # glob
    "/etc/modprobe.d/*",  # glob
    "/etc/rc.d/init.d",  # dir, not file
    "/etc/rc.d/rc",
    "/etc/resolv.conf",
    "/etc/reslv.conf",  # should not exist
    "/etc/grub.conf",  # should not be able to read
    "/usr/share/automake-*/am/*.am",  # glob
    "/var/run/*",  # glob, and some of them should not be able to read
    "/root/*",  # likewise.
]

PATHS_EXPANDED = U.unique(
    U.concat(
        "*" in p and glob.glob(p) or [p] for p in PATHS \
            if not p.startswith("#")
    )
)


def setup_workdir():
    return tempfile.mkdtemp(dir="/tmp", prefix="pmaker-tests")


def cleanup_workdir(workdir):
    U.rm_rf(workdir)


def selfdir():
    return os.path.dirname(__file__)