473,382 Members | 1,441 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,382 software developers and data experts.

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???.

Sep 12 '06 #1
3 3581
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
Sep 12 '06 #2
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
ge*********@tirol.utanet.at | http://gerold.bcom.at | http://sw3.at
Ehrliche, herzliche Begeisterung ist einer der
wirksamsten Erfolgsfaktoren. Dale Carnegie
Sep 12 '06 #3
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.
Sep 12 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Josh Smith | last post by:
In Python 2.3 there is a new library for handling tarfiles. However, there doesn't seem to be any documentation on handling end-of-tape conditions. I've googled for it and checked the docs, I've...
4
by: Lars Behrens | last post by:
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...
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 ' +...
1
by: Beowulf | last post by:
Hello, I'm using Python to automate admin tasks on my job. We use Windoze 2000 as desktop platform. When executing this daily backup scripts I get the following error: Traceback (most recent...
1
by: Matthew Thorley | last post by:
I've been using tarfile like this import tarfile tar = tarfile.open('path_to_tar_archive', 'r:gz') But I need to use it like this: archive = open('path_to_tar_archive', 'r') tar =...
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...
7
by: aurora00 | last post by:
I have a program that generates a number of files that will be packaged into a tarball. Can I stream the content into TarFile without first writing them out to the file system? All add(), addfile()...
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,...
1
by: boblatest | last post by:
Hello, I'm trying to catch an "EOFError" exception that occurs when reading truncated tarfile. Here's my routine, and below that the callback trace. Note that although I'm trying to catch all...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...

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.