Marty Pitts a écrit :


Date: Fri, 5 Dec 2008 23:48:32 +0100
From: [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Subject: Re: [Tutor] Writing to a file problem....

zip_command = "c:\Users\Marty\Zip\Zip -!rv '%s' %s" % (target, ' '.join(source))
What if you just double the '\' -- you did it properly for you "j:\\..." path.
denis

I tried that as well a bunch of variations such as r'j:\Backup\ and 
'j:\\Backup\\' and 'j:/Backup/'

None of which seems to have worked.

Sorry.
Also, is the '!' really a valid part of a zip argument?
Have you tried for a test e.g.

c:\Users\Marty\Zip\Zip -!rv 'test_target' test_source.txt

and

c:\Users\Marty\Zip\Zip -!rv 'test_target' test_source1.txt test_source2.txt

on the command line? (test_sources existing)
If yes, meaning that the overall zip_command format is right, then logially the only source of noise precisely is 'source'. Obviously, it must be a sequence of valid name files. Try:

print "%s\n%s\n%s" % (
source
, ' '.join(source)
, ( "c:\Users\Marty\Zip\Zip -!rv '%s' %s" % (target, ' '.join(source)) )
)

to really check how you call zip. There must be something wrong, no?
By the way, I just checked the output format above, and it gave me:
c:\Users\Marty\Zip\Zip -!rv 'test.txt' test1.text test2.txt
How come that the target is surrounded with ''? For zip, all of that arg list is plain text anyway... Is it necessary for zip to identify target? Or for filenames that include spaces? I would try without apostrophes, anyway, and the contrary, meaning to quote source list, too:

' '.join([("'%s'" %name) for name in source]) (untested)

(Now, I think that this last version has higher chances to be right, because of the space_in_file_name issue. Try to use "", too.)
Hope this helps.

denis

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to