how to simulate tar filename substitution across piped subprocess.Popen() calls?

Rebelo puntabluda at gmail.com
Mon Nov 12 17:58:16 CET 2012


Dana četvrtak, 8. studenoga 2012. 19:05:12 UTC+1, korisnik jkn napisao je:
> Hi All
> 
>     i am trying to build up a set of subprocess.Ponen calls to
> 
> replicate the effect of a horribly long shell command. I'm not clear
> 
> how I can do one part of this and wonder if anyone can advise. I'm on
> 
> Linux, fairly obviously.
> 
>     J^n

You should try to do it in pure python, avoiding shell altogether. 
The first step would be to actually write what it is you want to do.

To filter files you want to add to tar file check tarfile (http://docs.python.org/2/library/tarfile.html?highlight=tar#module-tarfile), 
specifically :
TarFile.add(name, arcname=None, recursive=True, exclude=None, filter=None)
which takes filter paramter :
"If filter is specified it must be a function that takes a TarInfo object argument and returns the changed TarInfo object. If it instead returns None the TarInfo object will be excluded from the archive."



More information about the Python-list mailing list