files.py failing when run via browser while properly executed via terminal

Νικόλαος Κούρας nikos.gr33k at gmail.com
Tue Jun 4 06:05:27 EDT 2013


nikos at superhost.gr [~/www/cgi-bin]#
nikos at superhost.gr [~/www/cgi-bin]# python
Python 3.3.2 (default, Jun  3 2013, 16:18:05)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-3)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> exit()
Okey after compiling from source python 3.3.2 and 'easy_install pymysql' now i'm receiving this error whiuch prohibit my files.py script to run.

=====================================
nikos at superhost.gr [~/www/cgi-bin]# python files.py
Error in sys.excepthook:
ValueError: underlying buffer has been detached

Original exception was:
Traceback (most recent call last):
  File "/usr/local/lib/python3.3/os.py", line 673, in __getitem__
    value = self._data[self.encodekey(key)]
KeyError: b'REMOTE_ADDR'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "files.py", line 17, in <module>
    host = socket.gethostbyaddr( os.environ['REMOTE_ADDR'] )[0]
  File "/usr/local/lib/python3.3/os.py", line 676, in __getitem__
    raise KeyError(key)
KeyError: 'REMOTE_ADDR'
nikos at superhost.gr [~/www/cgi-bin]#
=====================================

host = socket.gethostbyaddr( os.environ['REMOTE_ADDR'] )[0] 

Is not the proeblem here becaus ei ahve the exact same statemnt inside metriets.py and pelatologio.py and they dont provide me an error.

If i run the script from chrome as http://superhost.gr/cgi-bin/files.py
i get na internal server error.

But since it complained i switched the above host to host = "nikos"

then  run python files.py and it compiled properly with no error
but via browser i receive internal server error agian.

So since the script interprets okey i decided to tail the error log to see the live error messages when i call it via browser:

nikos at superhost.gr [~/www/cgi-bin]# tail -F /usr/local/apache/logs/error_log &


[Tue Jun 04 13:02:37 2013] [error] [client 46.12.95.59] Error in sys.excepthook:
[Tue Jun 04 13:02:37 2013] [error] [client 46.12.95.59] ValueError: underlying buffer has been detached
[Tue Jun 04 13:02:37 2013] [error] [client 46.12.95.59]
[Tue Jun 04 13:02:37 2013] [error] [client 46.12.95.59] Original exception was:
[Tue Jun 04 13:02:37 2013] [error] [client 46.12.95.59] Traceback (most recent call last):
[Tue Jun 04 13:02:37 2013] [error] [client 46.12.95.59]   File "files.py", line 67, in <module>
[Tue Jun 04 13:02:37 2013] [error] [client 46.12.95.59]     cur.execute('''SELECT url FROM files WHERE url = %s''', (fullpath,) )
[Tue Jun 04 13:02:37 2013] [error] [client 46.12.95.59]   File "/usr/local/lib/python3.3/site-packages/PyMySQL3-0.5-py3.3.egg/pymysql/cursors.py", line 108, in execute
[Tue Jun 04 13:02:37 2013] [error] [client 46.12.95.59]     query = query.encode(charset)
[Tue Jun 04 13:02:37 2013] [error] [client 46.12.95.59] UnicodeEncodeError: 'utf-8' codec can't encode character '\\udcce' in position 61: surrogates not allowed
[Tue Jun 04 13:02:37 2013] [error] [client 46.12.95.59] Premature end of script headers: files.py
[Tue Jun 04 13:02:37 2013] [error] [client 46.12.95.59] File does not exist: /home/nikos/public_html/500.shtml

I tried anything i can think of, hti sis beyond me, so please shed some light.
Thank you.




More information about the Python-list mailing list