how to tar with python
Gabriel Genellina
gagsl-py2 at yahoo.com.ar
Fri Aug 24 15:21:25 EDT 2007
En Fri, 24 Aug 2007 10:03:30 -0300, Brian McCann
<Brian.McCann at viziant.net> escribi�:
> I'm trying to tar the contents of a directory "test" which contains
> 3 files foo1.xml ,foo2.xml, foo3.xml
> in my current directory /home/pythonbox/tmp I have the directory "test"
> if I run the below script it fails with the below error, but the files
> exist in the directory test
Add a print statement and see what you get:
> tfile = tarfile.open("files.tar.gz", 'w:gz')
> files = os.listdir("test")
> for f in files:
print f
> tfile.add(f)
> tfile.close
See <http://docs.python.org/lib/module-os.path.html#l2h-2176>
--
Gabriel Genellina
More information about the Python-list
mailing list