473,405 Members | 2,261 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,405 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 2524
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.