473,388 Members | 919 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

'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 2520
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Phillip | last post by:
Some people tipped me off on some possibilities to tackle my https problem. Those have definitely gotten me further in cornering the problem. Thank you. But: No matter what I do to open a...
8
by: Jay Donnell | last post by:
Is there a way to use the tarfile module to recursively compress the contents of a directory and maintain the directory structure in the tar archive? Simply doing os.system('tar -czvf ' +...
5
by: Matt Doucleff | last post by:
Hi everyone! I must be doing something wrong here :) I have a tarball that contains a single file whose contents are a pickled object. I would like to unpickle the object directly from the...
2
by: Brad Tilley | last post by:
I was using Python to tar up some files each day in a directory by calling os.popen("/bin/tar.......). Everything was working well until the app that generated the files was set to generate a file...
4
by: Claudio Grondi | last post by:
I need to unpack on a Windows 2000 machine some Wikipedia media .tar archives which are compressed with TAR 1.14 (support for long file names and maybe some other features) . It seems, that...
3
by: Martijn van Oosterhout | last post by:
Hi, Does anyone have any packages for 7.3.4 for debian woody? Thanks in advance, -- Martijn van Oosterhout <kleptog@svana.org> http://svana.org/kleptog/ > "All that is needed for the...
1
by: Erwin Brandstetter | last post by:
Hi Newsgroup! Some weeks back (2003-11-18), Oliver Elphick wrote in this newsgroup: > A version built for woody (stable) is available at > http://people.debian.org/~elphick/debian This is...
6
by: sebastian.noack | last post by:
Hi, is there a way to or at least a reason why I can not use tarfile to create a gzip or bunzip2 compressed archive in the memory? You might might wanna answer "use StringIO" but this isn't...
6
by: Terry Carroll | last post by:
I am trying to do something with a very large tarfile from within Python, and am running into memory constraints. The tarfile in question is a 4-gigabyte datafile from freedb.org,...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.