Il 14 marzo 2012 12:14, Val <[email protected]> ha scritto:
>
>
> Premessa: sono uno sviluppatore professionista da 20 anni in vari linguaggi,
> ma Pythonista amatoriale (ed entusiasta) da 1, vi leggo solo, senza mai
> scrivere.
> Per risolvere un problema simile ho goggleato vari tipi di soluzioni
> possibili e ne ho trovata una che ha il difetto delle basse performance, ma è
> sicuramente alternativa:
> Nella variabile IP_curr c'è ovviamente l'IP da pingare.
>
>
> import socket
>
>
> try:
> host = socket.gethostbyaddr(IP_curr)[0]
> except socket.herror:
> host = 0
>
>
> if host == 0:
> msg = msg + "OFFLINE"
> else:
> msg = msg + str(host)
>
> print msg
Non mi pare molto affidabile. Col mio provider ad esempio non funziona:
>>> socket.gethostbyaddr('adksndkasndk.com') # dominio non registrato
('ar.libero.it', [], ['212.52.82.27'])
>>>
--- Giampaolo
http://code.google.com/p/pyftpdlib/
http://code.google.com/p/psutil/
http://code.google.com/p/pysendfile/
_______________________________________________
Python mailing list
[email protected]
http://lists.python.it/mailman/listinfo/python