[Tutor] Writing to a file problem....

spir denis.spir at free.fr
Sat Dec 6 08:50:51 CET 2008


Marty Pitts a écrit :
> 
> 
>> Date: Fri, 5 Dec 2008 23:48:32 +0100
>> From: denis.spir at free.fr
>> To: mortimerp at live.com
>> 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



More information about the Tutor mailing list