[Zope-dev] os.system problem
Arjan Huizer
a.huizer@kennisnet.org
Thu, 19 Jun 2003 12:12:33 +0200
Hi,
I have created an external method that is called when I upload a file. =
This external method will execute the validate_file function from my =
python file in the Extensions directory.=20
The script creates a file and tries to see if it contains a virus. It =
does run, but after creating the file, the os.system and os.remove =
commands do not seem to do anything. When I copy the relevant code from =
the script to a python file and run it on the server directly, the code =
works.=20
Does anyone know what could be wrong? Thanks in advance!
p.s. I am running Zope 2.6.1 with CMF 1.3 on a Linux box.
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
import os
def validate_file(file):
'''
Check is file contains a virus.
'''
filename =3D "/usr/local/Zope/temp/temp.bin"
# Write the file to the local filesystem
temp =3D open(filename, "wb")
temp.write(file.read())
temp.flush
# Call virus checker
error_level =3D os.system("f-prot " + filename)
# Delete temp file
os.remove(filename)
return error_level;