I wrote a script that collects all our log files to one tar file. The problem is that it doesn’t contain soft link’s data. I tried to use the dereference flag but it is not recognized for python 2.4.3.
I can’t use the command line since there’s a length limit and I want to support many log files.
user ~/Desktop]$python
Python 2.4.3 (#1, Jun 11 2009, 14:09:37)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-44)] on linux2
>>> import tarfile
>>> tarfile.TarFile('test.tar.gz', mode='w', dereference=True)
Traceback (most recent call last):
File "<stdin>", line 1, in ?
TypeError: __init__() got an unexpected keyword argument 'dereference'
>>>
According to the Python 2.4 docs
dereference = Trueis supported. It appears to have been supported sincetarfilewas added in Python 2.3.Unless you’re on a non-Posix system (Windows) you must be doing it wrong. Post your code and the error you get with
dereference = Trueso we can tell you what that is.Also, by soft links I assume you mean symbolic links? Because that’s what
dereference = Trueallows to work.Edit: I just looked at the code for tarfile on Python 2.4. It does not support the
dereferenceparameter to the constructor, but it does seem to have the needed code to actually dereference (Checked against the source for Python 2.6). So,should work. Please, update with your results.