On 2 Ιαν, 17:47, Roy Smith <r...@panix.com> wrote: > In article > <6b787f23-5813-4831-a349-02883f564...@q7g2000yqn.googlegroups.com>, > ÉΪÉ«É»όλαος Κούρας <nikos.kou...@gmail.com> wrote: > > > > > > > > > > > On 2 ÉßÉΩÉΥ, 16:00, Heiko Wundram <modeln...@modelnine.org> wrote: > > > Am 02.01.2012 14:25, schrieb ÉΪÉ«É»όλαος Κούρας: > > > > > On 23 Δεκ 2011, 19:14, Νικόλαος Κούρας<nikos.kou...@gmail.com> wrote: > > > >> I dont know why this line host = > > > >> socket.gethostbyaddr( os.environ['REMOTE_ADDR'] )[0] fails sometimes > > > >> and some other times works ok retrieving the hostnames correctly. > > > > > Please i need some help. My webpage doesn't work due to this error... > > > > The error "herror: (1, ...)" says it all: the DNS-name (i.e., the > > > <something>.in-addr.arpa name) you're trying to resolve is unknown. Not > > > all hosts (or rather, IPs) on the internet have reverse lookups: try the > > > IP 81.14.209.35 from which I'm posting, and dig/nslookup will tell you > > > that it has no reverse resolution, which would result in gethostbyaddr() > > > throwing an herror-instance. > > > I see > > > > Basically: make the reverse lookup conditional by wrapping it in a > > > try:/except herror: and assigning an appropriate default for host in > > > case reverse lookup fails. > > > Can tou show me how to write this please? > > try: > host = socket.gethostbyaddr( os.environ['REMOTE_ADDR'] )[0] > except socket.herror: > host = "<unknown host>"
Thank you very much. -- http://mail.python.org/mailman/listinfo/python-list