I'm stuck with setting up file time stamp, also as per python gzip document , the syntax not working like gzip.GzipFile(filename=outputfile,mode='wb',compresslevel=9,mtime=ftime)
, but when I used gzip.GzipFile(outputfile,'wb',9,mtime=ftime)
it's working but except time stamp.
def compresse_file(file,ftime):
data = open(file,'rb')
outputfile = file +".gz"
gzip_file = gzip.GzipFile(outputfile,'wb',9,mtime=ftime)
gzip_file.write(data.read())
gzip_file.flush()
gzip_file.close()
data.close()
os.unlink(file)
Here is output :
root@ubuntu:~/PythonPractice-# python compresses_file.py
Size Date File Name
5 MB 30/12/13 test.sh
Compressing...
test.sh 1388403823.0
file status after compressesion
5 kB 31/12/13 test.sh.gz
root@ubuntu:~/PythonPractice-# date -d @1388403823.0
Mon Dec 30 17:13:43 IST 2013