Пример #1
0
    def call_unrar(self, command, *xargs, **kwargs):
        args = []
        #overwrite flag
        args.append("-o+") if self.overwrite else args.append("-o-")
        
        if self.excludefiles:
            for word in self.excludefiles.split(';'):
                args.append("-x%s" % word )
                
        # assume yes on all queries
        args.append("-y")

        #set a password
        if "password" in kwargs and kwargs["password"]:
            args.append("-p%s" % kwargs["password"])
        else:
            args.append("-p-")

        #NOTE: return codes are not reliable, some kind of threading, cleanup whatever issue
        call = [self.CMD, command] + args + list(xargs)
        self.m.logDebug(" ".join([decode(arg) for arg in call]))

        p = Popen(call, stdout=PIPE, stderr=PIPE)

        return p
Пример #2
0
    def call_unrar(self, command, *xargs, **kwargs):
        args = []
        # overwrite flag
        args.append("-o+") if self.overwrite else args.append("-o-")

        if self.excludefiles:
            for word in self.excludefiles.split(';'):
                args.append("-x%s" % word)

        # assume yes on all queries
        args.append("-y")

        # set a password
        if "password" in kwargs and kwargs["password"]:
            args.append("-p%s" % kwargs["password"])
        else:
            args.append("-p-")

        # NOTE: return codes are not reliable, some kind of threading, cleanup whatever issue
        call = [self.CMD, command] + args + list(xargs)
        self.m.logDebug(" ".join([decode(arg) for arg in call]))

        p = Popen(call, stdout=PIPE, stderr=PIPE)

        return p
Пример #3
0
    def listContent(self):
        command = "vb" if self.fullpath else "lb"
        p = self.call_unrar(command, "-v", fs_encode(self.file), password=self.password)
        out, err = p.communicate()

        if "Cannot open" in err:
            raise ArchiveError("Cannot open file")

        if err.strip(): # only log error at this point
            self.m.logError(err.strip())

        result = set()

        for f in decode(out).splitlines():
            f = f.strip()
            result.add(save_join(self.out, f))

        self.files = result
Пример #4
0
    def listContent(self):
        command = "vb" if self.fullpath else "lb"
        p = self.call_unrar(command, "-v", fs_encode(self.file), password=self.password)
        out, err = p.communicate()

        if "Cannot open" in err:
            raise ArchiveError("Cannot open file")

        if err.strip(): # only log error at this point
            self.m.logError(err.strip())

        result = set()

        for f in decode(out).splitlines():
            f = f.strip()
            result.add(save_join(self.out, f))

        self.files = result