On 1/9/2013 09:59, Ferrous Cranus wrote: > Στις 1/9/2013 1:35 μμ, ο/η Dave Angel έγραψε: >> This is my first crack at it (untested): >> >> errout = open("/tmp/err.out", "w") #opens and truncates the error >> output file >> try: >> gi = pygeoip.GeoIP('/usr/local/share/GeoIPCity.dat') >> city = gi.time_zone_by_addr( os.environ['REMOTE_ADDR'] ) or >> gi.time_zone_by_addr( os.environ['HTTP_CF_CONNECTING_IP'] ) >> host =socket.gethostbyaddr( os.environ['REMOTE_ADDR'] )[0] or >> socket.gethostbyaddr( os.environ['HTTP_CF_CONNECTING_IP'] )[0] or >> "Proxy Detected" >> except Exception as e: >> print( "Xyzzy exception-", repr(sys.exc_info()), file=errout) >> errout.flush() >> >> >> Note that I haven't had to use exc_info() in my own code, so I'm sure it >> could be formatted prettier. But right now, you need to stop throwing >> away useful information. > > First of all thank you for your detailed information Dave. > I have tried all you said, the above example you provided me, but i'm > afraid even with your approach which should have given more error > specific information the output of the err file remains. > > > ni...@superhost.gr [~]# cat /tmp/err.out > UnicodeDecodeError('utf-8', b'\xb6\xe3\xed\xf9\xf3\xf4\xef > \xfc\xed\xef\xec\xe1 \xf3\xf5\xf3\xf4\xde\xec\xe1\xf4\xef\xf2', 0, 1, > 'invalid start byte') > > >
See my other response. The above file did NOT result from running the code above. It is missing the "Xyzzy" label. -- Signature file not found -- http://mail.python.org/mailman/listinfo/python-list