Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #18326 > unrolled thread
| Started by | Νικόλαος Κούρας <nikos.kouras@gmail.com> |
|---|---|
| First post | 2012-01-02 05:25 -0800 |
| Last post | 2012-01-02 10:17 -0800 |
| Articles | 5 — 3 participants |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: socket.gethostbyaddr( os.environ['REMOTE_ADDR'] error Νικόλαος Κούρας <nikos.kouras@gmail.com> - 2012-01-02 05:25 -0800
Re: socket.gethostbyaddr( os.environ['REMOTE_ADDR'] error Heiko Wundram <modelnine@modelnine.org> - 2012-01-02 15:00 +0100
Re: socket.gethostbyaddr( os.environ['REMOTE_ADDR'] error Νικόλαος Κούρας <nikos.kouras@gmail.com> - 2012-01-02 07:29 -0800
Re: socket.gethostbyaddr( os.environ['REMOTE_ADDR'] error Roy Smith <roy@panix.com> - 2012-01-02 10:47 -0500
Re: socket.gethostbyaddr( os.environ['REMOTE_ADDR'] error Νικόλαος Κούρας <nikos.kouras@gmail.com> - 2012-01-02 10:17 -0800
| From | Νικόλαος Κούρας <nikos.kouras@gmail.com> |
|---|---|
| Date | 2012-01-02 05:25 -0800 |
| Subject | Re: socket.gethostbyaddr( os.environ['REMOTE_ADDR'] error |
| Message-ID | <5c874675-ec98-445f-af91-9741413c512d@z1g2000vbx.googlegroups.com> |
On 23 Δεκ 2011, 19:14, Νικόλαος Κούρας <nikos.kou...@gmail.com> wrote: > On 23 Äåê, 12:41, becky_lewis <bex.le...@gmail.com> wrote: > > > Is there any possibility that you can tell us what the script actually > > is or provide a code listing (use pastebin if it's big)? > > The script is about retrieving and storing the visitros hostnames to > mysql database creating a log file. > > 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. > > What do you understand from the traceback?! Please i need some help. My webpage doesn't work due to this error...
[toc] | [next] | [standalone]
| From | Heiko Wundram <modelnine@modelnine.org> |
|---|---|
| Date | 2012-01-02 15:00 +0100 |
| Message-ID | <mailman.4313.1325513347.27778.python-list@python.org> |
| In reply to | #18326 |
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. 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. -- --- Heiko.
[toc] | [prev] | [next] | [standalone]
| From | Νικόλαος Κούρας <nikos.kouras@gmail.com> |
|---|---|
| Date | 2012-01-02 07:29 -0800 |
| Message-ID | <6b787f23-5813-4831-a349-02883f564da4@q7g2000yqn.googlegroups.com> |
| In reply to | #18327 |
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?
[toc] | [prev] | [next] | [standalone]
| From | Roy Smith <roy@panix.com> |
|---|---|
| Date | 2012-01-02 10:47 -0500 |
| Message-ID | <roy-C5BA54.10470902012012@news.panix.com> |
| In reply to | #18329 |
In article <6b787f23-5813-4831-a349-02883f564da4@q7g2000yqn.googlegroups.com>, ÉΪɫɻόλαος Κούρας <nikos.kouras@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>"
[toc] | [prev] | [next] | [standalone]
| From | Νικόλαος Κούρας <nikos.kouras@gmail.com> |
|---|---|
| Date | 2012-01-02 10:17 -0800 |
| Message-ID | <7a9e8fce-3a6a-4b16-b8f0-411106a1d1e3@e2g2000vbb.googlegroups.com> |
| In reply to | #18330 |
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.
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web