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 call last):
File "C:\UTILS\backu p.py", line 8, in ?
TarFileBackup = tarfile.open(Ne wBackupFilename , 'w:bz2')
File "C:\Python23\li b\tarfile.py", line 875, in open
return func(name, filemode, fileobj)
File "C:\Python23\li b\tarfile.py", line 980, in bz2open
raise ReadError, "not a bzip2 file"
tarfile.ReadErr or: not a bzip2 file
----
Here's the code:
----
import tarfile
from datetime import datetime
DirBackup = r'\\skpdc01\Bac kups'
DirOrig = r'C:\WUTemp'
NewBackupFilena me = DirBackup + '\\' + '%s' % (datetime.today ()) +
'.tar.bz2'
TarFileBackup = tarfile.open(Ne wBackupFilename , 'w:bz2')
TarFileBackup.a dd(DirOrig)
TarFileBackup.c lose()
----
What am I doing wrong? From the error message I gues the library is
expecting the bzip file to exists, but I am explicitly open it whit
'w:bz2' Any ideas?
Thanks. 1 1922
Your NewBackupFilena me contains ":" which is not a valid character in a
filename in Windows.
You could do something like this: NewBackupFilena me = DirBackup + '\\' + '%s' %
str(datetime.to day()).replace( ':', '-') + '.tar.bz2' NewBackupFilena me
'c:\\\\skpdc01\ \\\Backups\\200 5-01-21 12-26-21.373000.tar.b z2' TarFileBackup = tarfile.open(Ne wBackupFilename , 'w:bz2') # Works!
I changed your DirBackup to 'C:\skpdc01\Bac kups'
Thanks,
--Kartic This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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 ' + fileName +'.tar.gz ' +
directory)
works great on linux, but I need this script to work on windows as
well :(
|
by: Dennis Hotson |
last post by:
Hi,
I'm trying to write a function that adds a file-like-object to a
compressed tarfile... eg ".tar.gz" or ".tar.bz2"
I've had a look at the tarfile module but the append mode doesn't support
compressed tarfiles... :(
Any thoughts on what I can do to get around this?
|
by: Uwe Mayer |
last post by:
Hi,
is it possible to delete a file from a tar-archive using the tarfile module?
Thanks
Uwe
|
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 Pythons tarfile module is able to list far
more files inside the archives than WinRAR or 7zip or
TotalCommander, but will it unpack all available files
(largest archive size 17 GByte)?
If tarfile is build on TAR 1.14 or TAR 1.15 it will be
|
by: justin.vanwinkle |
last post by:
Hello everyone,
I need some tar functionality for my program. Currently the following
code properly displays tar archives, and tar.gz archives. However, it
chokes on tar.bz2 archives with the following error:
File "mail_filter.py", line 262, in extract_archive
tar_archive = tarfile.open('', 'r', fileobj)
File "/usr/lib/python2.3/tarfile.py", line 900, in open
return func(name, "r", fileobj)
| |
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() and
gettarinfo() seems to assume there is a file in the disk. But for me I
seems inefficient to write all the content to the disk and then have
it read back by the TarFile module.
Thank you for your help
wy
|
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 such easy
as it seems to be. ;) I am using Python 2.5.2, by the way. I think
this is a bug in at least in this version of python, but maybe
StringIO isn't just file-like enough for this "korky" tarfile module.
But this would conflict with its...
|
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,
http://ftp.freedb.org/pub/freedb/ , and has about 2.5 million members
in it.
Here's a simple toy program that just goes through and counts the
number of members in the tarfile, printing a status message every N
records (N=10,000 for the smaller file;...
|
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 TarFile exceptions,
the tarfile.EOFError ecxeption, and the global EOFError exception, the
program still falls through and fails.
def query_archive(batch_base):
arc_name = os.path.join(archive_dir, 'B_'+batch_base+'.tar.bz2')
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |