creating a tar file with python
Brian McCann
Brian.McCann at viziant.net
Thu Aug 23 20:53:03 EDT 2007
Hi,
I'm now getting this error
any ideas?
Thanks,
Brian
Traceback (most recent call last):
File "./tarup.py", line 25, in ?
tar = tarfile.open("test.xml","sample.tar.gz", 'w:gz')
File "/usr/lib64/python2.4/tarfile.py", line 929, in open
raise ValueError, "undiscernible mode"
ValueError: undiscernible mode
############################################################
#!/usr/bin/python
import string
import os
import sys
import time
import errno
import shutil
import tarfile
tar = tarfile.open(test.xml","sample.tar.gz", 'w:gz')
<mailto:brian.mccann at viziant.net>
________________________________
From: python-list-bounces+brian.mccann=viziant.net at python.org on behalf of Steve Holden
Sent: Thu 8/23/2007 5:24 PM
To: python-list at python.org
Subject: Re: creating a tar file with python
Brian McCann wrote:
> Hi,
>
> I'm trying to create a tar file of the contents of the current directory
>
> right now there is only one file "text.xml" in the current dir, I'm
> using"." current dir as source
> but that gives syntax error
>
> any help would be greatly appreciated
> --Brian
>
>
> #!/usr/bin/python
> import string
> import os
> import sys
> import time
> import errno
> import shutil
> import tarfile
>
>
> tar = tarfile.open(.,"test.tar.gz", "w:gz)
> <mailto:brian.mccann at viziant.net>
>
>
well, /probably/ (meaning I haven't done any testing) you need quotes
around the name of the current directory just like you do around the
name of the file. Try
tar = tarfile(".", "test.tar.gz", "w:gz")
regards
Steve
--
Steve Holden +1 571 484 6266 +1 800 494 3119
Holden Web LLC/Ltd http://www.holdenweb.com
Skype: holdenweb http://del.icio.us/steve.holden
--------------- Asciimercial ------------------
Get on the web: Blog, lens and tag the Internet
Many services currently offer free registration
----------- Thank You for Reading -------------
--
http://mail.python.org/mailman/listinfo/python-list
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20070823/18a157cf/attachment.html>
More information about the Python-list
mailing list