469,097 Members | 1,540 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,097 developers. It's quick & easy.

'name is too long' (tarfile, python 2.2, Debian Woody)

Hi, Pythonistas!

I'm quite new to Python and have a problem with a simple backup script.

This code:

tar = tarfile.open('/home/lars/test.tar.gz', 'w:gz')
tar.addfile('/home/lars')

brings up the following error message:

************************************************** ********************
/usr/lib/python2.2/site-packages/tarfile.py in addfile(self, tarinfo,
fileobj)
1289
1290 if not prefix or len(name) > LENGTH_NAME:
-> 1291 raise ValueError, "name is too long (>%d)" \
1292 % (LENGTH_NAME)
1293

ValueError: name is too long (>100)
************************************************** ********************

Any hints for me?

Thanks in advance
Lars

Jul 18 '05 #1
4 2288
Lars Behrens wrote:
Hi, Pythonistas!

I'm quite new to Python and have a problem with a simple backup script.

This code:

tar = tarfile.open('/home/lars/test.tar.gz', 'w:gz')
tar.addfile('/home/lars')

brings up the following error message:

************************************************** ********************
/usr/lib/python2.2/site-packages/tarfile.py in addfile(self, tarinfo,
fileobj)
1289
1290 if not prefix or len(name) > LENGTH_NAME:
-> 1291 raise ValueError, "name is too long (>%d)" \
1292 % (LENGTH_NAME)
1293

ValueError: name is too long (>100)
************************************************** ********************


The standard tar format allows only names (i.e. complete path) of 100
characters. So in your '/home/lars' are names (fully expanded) which are
longer.
Please have a look at the documentation of tarfile, there is an option
to store extended path names. Most other tar programs (like gnu-tar)
support these, as well.
--
Helmut Jarausch

Lehrstuhl fuer Numerische Mathematik
RWTH - Aachen University
D 52056 Aachen, Germany

Jul 18 '05 #2
Lars Behrens wrote:

I found this in the tarfile doc:

-- snip --
posix=True
If True, create a POSIX 1003.1-1990 compliant archive. GNU extensions
are not used, because they are not part of the POSIX standard. This
limits the length of filenames to at most 256 and linknames to 100
characters. A ValueError is raised, if a pathname exceeds this limit. If
False, create a GNU tar compatible archive. It will not be POSIX
compliant, but can store pathnames of unlimited length.
-- snap --

So, I put this in my script:

tar.posix=True

before

tar.add('bla')

This seems to work. But honestly, I don't quite understand
what I did :-\


Perhaps this is a sign that the problem was really somewhere else. What
you say you did is not likely to have solved the problem given the
documentation above. It says that setting tar.posix to *False* would
allow longer path names, not the other way around. If you think you
just got longer names to work and your problems went away, you
are probably missing something here...

-Peter
Jul 18 '05 #3
Peter Hansen wrote:
Perhaps this is a sign that the problem was really somewhere else. What
you say you did is not likely to have solved the problem given the
documentation above. It says that setting tar.posix to *False* would
allow longer path names, not the other way around. If you think you
just got longer names to work and your problems went away, you
are probably missing something here...


Sorry, a typo, of course I set tar.posix to false.
Mea culpa...

Cheerz Lars

Jul 18 '05 #4
On Wed, 20 Aug 2003 18:45:05 +0200, Lars Behrens wrote:
So, I put this in my script:

tar.posix=True

before

tar.add('bla')

This seems to work. But honestly, I don't quite understand what I did
:-\
The fact that it worked this time seems pure chance to me, it is likely to
fail in the future. For backup purposes you should definitely set
tar.posix=False to enable long pathnames in your tar file.
I also found out, that I can call tarfile.GNUTYPE_LONGNAME but what can
I do with it or how do I use it?

Any hints for me?


tarfile.GNUTYPE_LONGNAME is a constant for internal use only. You don't
need to handle long pathnames yourself. I admit that setting an attribute
to False to turn on a feature may seem a bit cumbersome, but once you got
used to it it feels okay ;-)
tarfile creates POSIX compliant tar files by default because they are more
portable. If you just want to make backups for your personal use you don't
need to bother, so turn off the POSIX mode.

--
Lars Gustäbel
la**@gustaebel.de
Jul 18 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

8 posts views Thread by Jay Donnell | last post: by
2 posts views Thread by Brad Tilley | last post: by
3 posts views Thread by Martijn van Oosterhout | last post: by
1 post views Thread by Erwin Brandstetter | last post: by
6 posts views Thread by Terry Carroll | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by kglaser89 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.