Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Python: Python

Create TarFile using python

 

 

Python python RSS feed   Index | Next | Previous | View Threaded


isalazar80 at yahoo

Sep 12, 2006, 11:37 AM

Post #1 of 4 (106 views)
Permalink
Create TarFile using python

I have a problem. I'm new in python and I need a script that group a
list of files using Tar file utility and then, compress that block
using a compress utility (gzip i think). I already found some
information and i try to apply it, but my scripy doesn't work. The
first problem is when I had tried to open the file that i want to
group, a IO error appear:

f = open(log, "r")
IOError: [Errno 13] Permission denied: 'C:\\path"

I previusly asigned to "log" the path of the archive that i want to
group....

could sombody helpme???.

--
http://mail.python.org/mailman/listinfo/python-list


peter.maas at somewhere

Sep 12, 2006, 12:11 PM

Post #2 of 4 (83 views)
Permalink
Re: Create TarFile using python [In reply to]

itzel wrote:
> I have a problem. I'm new in python and I need a script that group a
> list of files using Tar file utility and then, compress that block
> using a compress utility (gzip i think). I already found some
> information and i try to apply it, but my scripy doesn't work.

Did you look here?:

http://docs.python.org/lib/tar-examples.html

Peter Maas, Aachen
--
http://mail.python.org/mailman/listinfo/python-list


gerold.penz at tirol

Sep 12, 2006, 2:03 PM

Post #3 of 4 (83 views)
Permalink
Re: Create TarFile using python [In reply to]

itzel schrieb:
> I need a script that group a
> list of files using Tar file utility and then, compress that block
> using a compress utility (gzip i think).

Hi!

This script packs all files and directories inside the ``source_dir``
into the TAR-GZ-Archive (``destination``):


import os.path
import tarfile

def to_tar_gz(source_dir, destination):
"""
:param source_dir: Source directory name.
:param destination: Destination filename.
(TAR-GZ-Archive *.tar.gz)
"""

t = tarfile.open(name = destination, mode = 'w:gz')
t.add(source_dir, os.path.basename(source))
t.close()

return True


Regards,
Gerold
:-)


--
________________________________________________________________________
Gerold Penz - bcom - Programmierung
gerold.penz [at] tirol | http://gerold.bcom.at | http://sw3.at
Ehrliche, herzliche Begeisterung ist einer der
wirksamsten Erfolgsfaktoren. Dale Carnegie
--
http://mail.python.org/mailman/listinfo/python-list


isalazar80 at yahoo

Sep 12, 2006, 2:16 PM

Post #4 of 4 (84 views)
Permalink
Re: Create TarFile using python [In reply to]

yes, i did. I'm checking the link in ASPN and I think that it'll works
for "my problem" ....thanks a lot!! One more question... I'll need do
it frecuently: add more directories into the same block. Is the same
procedure?

Thanks!!!

ps. sorry about gramatic, I don't write english frecuently....


Yu-Xi Lim ha escrito:

> Peter Maas wrote:
>
> > Did you look here?:
> >
> > http://docs.python.org/lib/tar-examples.html
> >
> > Peter Maas, Aachen
>
> It doesn't show him how to archive a directory.

--
http://mail.python.org/mailman/listinfo/python-list

Python python RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.