[spe.pycs.net] tar.gz releases

Guillermo Fernandez Castellanos guillermo.fernandez at epfl.ch
Tue Dec 16 15:36:23 CET 2003


Cheers,

>Question:
>If anyone has a small windows program which can
>convert a directory in a tar.gz with one click (not
>first tar and than gz) I'll can change the zip source
>releases into tar.gz, as windows users will use the
>exe release.
>  
>
Did not try this under windows, but should work just fine (python 
portability ;-)
It's a quick and dirty script, I can improve it later if you wish.

import sys
import tarfile
import gzip

if len(sys.argv)!=3:
    print "Bad number of arguments"
    print sys.argv[0], "outputfile dir_to_add"
    sys.exit(1)
tar = tarfile.open(sys.argv[1]+".tar", "w")
tar.add(sys.argv[2])
tar.close()
gz = gzip.open(sys.argv[1]+".tar.gz","w")
tar=open(sys.argv[1]+".tar","r")
gz.write(tar.read())
gz.close()

Could someone try it under windows and see if the file is readable under 
*NIX?
I'm under Linux rigth now, and the tar.gz file created works just fine :-)

The syntax is:
program outputfile(without the .tar.gz extension) dir_to_add

If it works, I could extend it to read standard input and a list of dirs.

Guille




More information about the Spe-user mailing list