[Zope] Re: [Zope-dev] os.system problem

Jamie Heilman jamie@audible.transient.net
Thu, 19 Jun 2003 03:25:39 -0700


Problems of this nature should be sent to zope@zope.org not zope-dev.

Arjan Huizer wrote:
> def validate_file(file):
>     ''' Check is file contains a virus.  '''
>     filename = "/usr/local/Zope/temp/temp.bin"
>
>     # Write the file to the local filesystem
>     temp = open(filename, "wb")
>     temp.write(file.read())
>     temp.flush

This is not threadsafe and will cause you pain.  Use a threadsafe
temporary file library instead.
 
>     # Call virus checker
>     error_level = os.system("f-prot " + filename)

Chances are 'f-prot' is not in the $PATH of the zope process and thus
the command fails.
 
>     # Delete temp file
>     os.remove(filename)
>     return error_level;

-- 
Jamie Heilman                   http://audible.transient.net/~jamie/
"You came all this way, without saying squat, and now you're trying
 to tell me a '56 Chevy can beat a '47 Buick in a dead quarter mile?
 I liked you better when you weren't saying squat kid."	-Buddy