Hi Rankumar -
That's your problem then -
if os.system(zip_command) == 0:
> > > print 'Successful backup to', target
So, os.system() returns 0 for Win 95,98, ME.
For XP, it returns whatever the exit code your programme returns .
So whatever zip returns, is what os.system() returns, which may or may not be 0.
Try rewriting your code to find out like so -
import os
import os.path
import time
source = ['D:\\down', 'D:\\Pics']
target_dir = 'D:\\backup'
target = target_dir + time.strftime('%Y%m%d%H%M%S') + '.zip'
zip_command = "zip -qr '%s' %s" % (target, ' '.join(source))
returnCode=os.system(zip_command)
if os.path.isfile(target):
print "Back-up succeeded!"
print returnCode, " is a successful return code."
else:
print "Back-up failed."
print returnCode, " is an unsuccessful return code."
#if os.system(zip_command) == 0:
#print 'Successful backup to', target
#else:
#print 'Backup FAILED'
os.path.isfile(path) checks if there is a regular existing file there - i.e.
target="c:/windows/win.ini"
if not os.path.isfile(target):
print "I'm in serious trouble here."
Check it out, hope it helps.
Regards,
Liam Clarke
On Fri, 3 Dec 2004 13:01:44 +0600, Ramkumar Parimal Alagan
<[EMAIL PROTECTED]> wrote:
> Thanks for your reply Liam, I am using Windows Xp
>
>
>
>
> On Fri, 3 Dec 2004 19:46:14 +1300, Liam Clarke <[EMAIL PROTECTED]> wrote:
> > As the below quote from the manual shows -
> >
> > On Windows, the return value is that returned by the system shell
> > after running command, given by the Windows environment variable
> > COMSPEC: on command.com systems (Windows 95, 98 and ME) this is always
> > 0; on cmd.exe systems (Windows NT, 2000 and XP) this is the exit
> > status of the command run; on systems using a non-native shell,
> > consult your shell documentation.
> >
> > Your return value is OS specific. What OS are you using? Did you check
> > to see if your zip files were created? It may just be a funky return
> > code.
> >
> >
> >
> > On Fri, 3 Dec 2004 12:08:25 +0600, Ramkumar Parimal Alagan
> > <[EMAIL PROTECTED]> wrote:
> > > This is what i intend to do:
> > >
> > > 1. The files and directories to be backed up are given in a list.
> > > 2. The backup must be stored in a main backup directory.
> > > 3. The files are backed up into a zip file.
> > > 4. The name of the zip archive is the current date and time.
> > >
> > > the coding:
> > >
> > > ______________
> > >
> > > import os
> > > import time
> > >
> > > source = ['D:\\down', 'D:\\Pics']
> > >
> > > target_dir = 'D:\\backup'
> > >
> > > target = target_dir + time.strftime('%Y%m%d%H%M%S') + '.zip'
> > >
> > > zip_command = "zip -qr '%s' %s" % (target, ' '.join(source))
> > >
> > > if os.system(zip_command) == 0:
> > > print 'Successful backup to', target
> > > else:
> > > print 'Backup FAILED'
> > >
> > > _____________________________
> > >
> > > result : Backup FAILED
> > >
> > > whats wrong ?
> > > _______________________________________________
> > > Tutor maillist - [EMAIL PROTECTED]
> > > http://mail.python.org/mailman/listinfo/tutor
> > >
> >
> >
> > --
> > 'There is only one basic human right, and that is to do as you damn well
> > please.
> > And with it comes the only basic human duty, to take the consequences.
> >
>
>
> --
>
> << The end depends upon the beginning. >>
>
--
'There is only one basic human right, and that is to do as you damn well please.
And with it comes the only basic human duty, to take the consequences.
_______________________________________________
Tutor maillist - [EMAIL PROTECTED]
http://mail.python.org/mailman/listinfo/tutor