Weird and sparese cgi:error

Φώντας Λαδοπρακόπουλος nikos.gr33k at gmail.com
Thu Feb 18 09:47:01 EST 2016


[root at nexus cgi-bin]# head -10 ./metrites.py 
#!/usr/bin/python3
# coding=utf-8

import cgitb; cgitb.enable()
import cgi, re, os, sys, socket, time, datetime, locale, codecs, random, smtplib, subprocess, pymysql, geoip2.database
from datetime import datetime, timedelta
from http import cookies


#needed line, script does *not* work without it
[root at nexus cgi-bin]# ^C
[root at nexus cgi-bin]# /usr/bin/python3 
Python 3.3.2 (default, Aug 14 2014, 14:25:52) 
[GCC 4.8.2 20140120 (Red Hat 4.8.2-16)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> 
KeyboardInterrupt
>>> 
KeyboardInterrupt
>>> quit()
[root at nexus cgi-bin]# 
[root at nexus cgi-bin]# /usr/bin/python3 ./metrites.py 
Error in sys.excepthook:
ValueError: underlying buffer has been detached

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

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "./metrites.py", line 22, in <module>
    userinfo = os.environ['HTTP_USER_AGENT']
  File "/opt/rh/python33/root/usr/lib64/python3.3/os.py", line 676, in __getitem__
    raise KeyError(key)
KeyError: 'HTTP_USER_AGENT'
[root at nexus cgi-bin]# ^C


More information about the Python-list mailing list