[2.4.3/Newbie] Web script doesn't run

2013-02-11 Thread Gilles
Hello

I have a couple of newbie questions about using Python in a FastCGI
+ Flup context on a shared CentOS server:

1. The following script runs fine...
=
#!/usr/bin/env python2.6

def myapp(environ, start_response):
start_response('200 OK', [('Content-Type', 'text/plain')])
return ['Done!\n']

if __name__ == '__main__':
from flup.server.fcgi import WSGIServer
WSGIServer(myapp).run()
=

... while this triggers an error:
=
#!/usr/bin/env python2.6
# -*- coding: UTF-8 -*-

from cgi import escape
import sys, os

def app(environ, start_response):
start_response('200 OK', [('Content-Type', 'text/html')])

yield 'h1FastCGI Environment/h1'
yield 'table'
for k, v in sorted(environ.items()):
 yield 'trth%s/thtd%s/td/tr' % (escape(k),
escape(v))
yield '/table'

if __name__ == '__main__':
from flup.server.fcgi import WSGIServer
WSGIServer(app).run()
=

Internal Server Error: The server encountered an internal error or
misconfiguration and was unable to complete your request. [...]
Additionally, a 404 Not Found error was encountered while trying to
use an ErrorDocument to handle the request.

2. Generally speaking, what is the right way to investigate an error
in a Python web script? FWIW I have access to the shared server
through SSH.

Thank you.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [2.4.3/Newbie] Web script doesn't run

2013-02-11 Thread Gilles
On Mon, 11 Feb 2013 10:30:01 +0100, Gilles nos...@nospam.com wrote:
   I have a couple of newbie questions about using Python in a FastCGI
+ Flup context on a shared CentOS server:

Please ignore the thread. I found the error, and a way to catch
compile-time errors (log on through SSH, and run python
./myscript.py).
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [2.4.3/Newbie] Web script doesn't run

2013-02-11 Thread Chris Angelico
On Mon, Feb 11, 2013 at 8:39 PM, Gilles nos...@nospam.com wrote:
 On Mon, 11 Feb 2013 10:30:01 +0100, Gilles nos...@nospam.com wrote:
   I have a couple of newbie questions about using Python in a FastCGI
+ Flup context on a shared CentOS server:

 Please ignore the thread. I found the error, and a way to catch
 compile-time errors (log on through SSH, and run python
 ./myscript.py).

That'll catch some forms of error, but not everything. You may also
want to consider looking for your server's error log - that may be
getting the actual traceback. I don't know what your server setup is,
but there's likely to be one somewhere.

A question though. You say 2.4.3 in your subject line, but your
shebang says python2.6 - which version are you actually running? At
very least, I'd recommend using python2.6 to run your script from the
shell; if there's any incompatibility between the system Python (which
quite plausibly would be the 2.4.3 you named) and the one your CGI
script uses (named python2.6 and my guess would be that it's 2.6.6),
you'll confuse yourself when you do your shell test.

ChrisA
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [2.4.3/Newbie] Web script doesn't run

2013-02-11 Thread Gilles
On Mon, 11 Feb 2013 21:30:12 +1100, Chris Angelico ros...@gmail.com
wrote:
That'll catch some forms of error, but not everything. You may also
want to consider looking for your server's error log - that may be
getting the actual traceback. I don't know what your server setup is,
but there's likely to be one somewhere.

Good to know.

A question though. You say 2.4.3 in your subject line, but your
shebang says python2.6 - which version are you actually running?

I didn't pay attention to this. Support says that I should use 2.6,
but running python -V through SSH says 2.4.3. I'll ask support which
to use.

Thank you.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [2.4.3/Newbie] Web script doesn't run

2013-02-11 Thread Chris Angelico
On Mon, Feb 11, 2013 at 10:22 PM, Gilles nos...@nospam.com wrote:
 On Mon, 11 Feb 2013 21:30:12 +1100, Chris Angelico ros...@gmail.com
 wrote:
That'll catch some forms of error, but not everything. You may also
want to consider looking for your server's error log - that may be
getting the actual traceback. I don't know what your server setup is,
but there's likely to be one somewhere.

 Good to know.

A question though. You say 2.4.3 in your subject line, but your
shebang says python2.6 - which version are you actually running?

 I didn't pay attention to this. Support says that I should use 2.6,
 but running python -V through SSH says 2.4.3. I'll ask support which
 to use.

Try running python2.6 -V

Your shebang line says that it's looking for a program named
python2.6, which is quite probably not the same as the one named
just python.

ChrisA
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [2.4.3/Newbie] Web script doesn't run

2013-02-11 Thread Gilles
On Mon, 11 Feb 2013 22:30:45 +1100, Chris Angelico ros...@gmail.com
wrote:
Try running python2.6 -V

Your shebang line says that it's looking for a program named
python2.6, which is quite probably not the same as the one named
just python.

Indeed, they have two versions of Python installed:

# python2.6 -V
Python 2.6.4

# python -V
Python 2.4.3

I'll make sure to use 2.6.

Thank you.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [2.4.3/Newbie] Web script doesn't run

2013-02-11 Thread Chris Angelico
On Mon, Feb 11, 2013 at 10:36 PM, Gilles nos...@nospam.com wrote:
 On Mon, 11 Feb 2013 22:30:45 +1100, Chris Angelico ros...@gmail.com
 wrote:
Try running python2.6 -V

Your shebang line says that it's looking for a program named
python2.6, which is quite probably not the same as the one named
just python.

 Indeed, they have two versions of Python installed:

 # python2.6 -V
 Python 2.6.4

 # python -V
 Python 2.4.3

 I'll make sure to use 2.6.

It's entirely possible you have a third Python, a 3.x, as well.
Different Pythons coexist quite happily on a system.

Anyway, seems your issue's sorted out. Yay!

ChrisA
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [2.4.3/Newbie] Web script doesn't run

2013-02-11 Thread Gilles
On Mon, 11 Feb 2013 22:42:50 +1100, Chris Angelico ros...@gmail.com
wrote:
It's entirely possible you have a third Python, a 3.x, as well.
Different Pythons coexist quite happily on a system.

Thank for the help. I'm on my way to figure out how mod_fcgid, Flup,
and Python scripts work together.
-- 
http://mail.python.org/mailman/listinfo/python-list