Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #46863 > unrolled thread

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

Started byΝικόλαος Κούρας <nikos.gr33k@gmail.com>
First post2013-06-04 03:05 -0700
Last post2013-06-04 04:22 -0700
Articles 2 — 1 participant

Back to article view | Back to comp.lang.python


Contents

  files.py failing when run via browser while properly executed via terminal Νικόλαος Κούρας <nikos.gr33k@gmail.com> - 2013-06-04 03:05 -0700
    Re: files.py failing when run via browser while properly executed via terminal Νικόλαος Κούρας <nikos.gr33k@gmail.com> - 2013-06-04 04:22 -0700

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

FromΝικόλαος Κούρας <nikos.gr33k@gmail.com>
Date2013-06-04 03:05 -0700
Subjectfiles.py failing when run via browser while properly executed via terminal
Message-ID<2ecf267a-cd92-4472-9323-92a41288cb5e@googlegroups.com>
nikos@superhost.gr [~/www/cgi-bin]#
nikos@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@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@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@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.

[toc] | [next] | [standalone]


#46870

FromΝικόλαος Κούρας <nikos.gr33k@gmail.com>
Date2013-06-04 04:22 -0700
Message-ID<48f73ef8-3dba-4043-b2bd-6f50be131e3d@googlegroups.com>
In reply to#46863
i tried somehtign else too.

uploaded 1.mp3 and 1.exe from windows 8 via FileZilla to linux webhost

and then renamed them both  to Greek letters so that the renaming take place from within the CentOS and after that i tried:

http://superhost.gr/cgi-bin/files.py

Guess what? Still same error :(

[Tue Jun 04 14:21:05 2013] [error] [client 46.12.95.59] Error in sys.excepthook:
[Tue Jun 04 14:21:05 2013] [error] [client 46.12.95.59] ValueError: underlying buffer has been detached
[Tue Jun 04 14:21:05 2013] [error] [client 46.12.95.59]
[Tue Jun 04 14:21:05 2013] [error] [client 46.12.95.59] Original exception was:
[Tue Jun 04 14:21:05 2013] [error] [client 46.12.95.59] Traceback (most recent call last):
[Tue Jun 04 14:21:05 2013] [error] [client 46.12.95.59]   File "files.py", line 67, in <module>
[Tue Jun 04 14:21:05 2013] [error] [client 46.12.95.59]     cur.execute('''SELECT url FROM files WHERE url = %s''', (fullpath,) )
[Tue Jun 04 14:21:05 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 14:21:05 2013] [error] [client 46.12.95.59]     query = query.encode(charset)
[Tue Jun 04 14:21:05 2013] [error] [client 46.12.95.59] UnicodeEncodeError: 'utf-8' codec can't encode character '\\udcd3' in position 61: surrogates not allowed
[Tue Jun 04 14:21:05 2013] [error] [client 46.12.95.59] Premature end of script headers: files.py
[Tue Jun 04 14:21:05 2013] [error] [client 46.12.95.59] File does not exist: /home/nikos/public_html/500.shtml


What the hell is it with these Greek filenames, why everyhting breaks?

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web