0

I use a mod_python publisher function which calls the main() function of another python script with a custom built argv list. When I execute the publisher script from shell command line it works. But when I tried it through apache2 with mod_python, I get the error (shown below) that main takes no arguments.


File "/var/www/wabaServ/waba.py", line 15, in index
    aba.main([ "aba.py","-i", "-b"])

TypeError: main() takes no arguments (1 given)

main() in aba.py is defined as:

def main(argv=None):
 --code--

Note: if the list argument is not passed, aba.main() gets executed from mod_python.

The mod_python publisher function looks like:

import sys
sys.path.append("/u/scripts")
import aba
from cStringIO import StringIO

def index():

    old_stdout = sys.stdout
    sys.stdout = mystdout = StringIO()
    aba.main([ "aba.py","-i", "-b"])
    sys.stdout = old_stdout
    return(mystdout.getvalue())
4

1 回答 1

0

第一个日志记录语句说:

aba.main([ "aba.py","-i", "-b"])

你说 main 定义为:

def main(argv=None):

因此aba作为第一个参数传入 main() ,它占用了argv参数,然后没有参数可以传入该列表。

我不认为这与mod_python.

于 2015-01-22T19:17:22.540 回答