repeat with i from 1 to 2
try
do shell script "ping -o -t 2 www.apple.com"
exit repeat
--set value of variable "Internet" to "true"
tell application "IndigoServer"
set value of variable "Internet" to "true"
on error
--set Internet to "false"
delay 2
tell application "IndigoServer"
set value of variable "Internet" to "false"
end tell
end try
end repeat
repeat with i from 1 to 2
try
do shell script "ping -o -t 2 www.apple.com"
--set value of variable "Internet" to "true"
tell application "IndigoServer"
set value of variable "Internet" to "true"
exit repeat
on error
--set Internet to "false"
delay 2
tell application "IndigoServer"
set value of variable "Internet" to "false"
end tell
end try
end repeat
repeat with i from 1 to 2
try
do shell script "ping -o -t 2 www.apple.com"
exit repeat
on error
delay 2
tell application "IndigoServer"
set value of variable "Internet" to "false"
if i = 2 then error number -128
end tell
end try
end repeat
tell application "IndigoServer"
set value of variable "Internet" to "true"
end tell
import subprocess, sys
try:
try: indigo.variable.create("Internet")
except: pass
try: indigo.variable.create("my_IP_address")
except: pass
ip= subprocess.Popen("/usr/bin/curl --max-time 4 ip.appspot.com",shell=True,stdout=subprocess.PIPE,stderr=subprocess.PIPE).communicate()[0]
ipitems= ip.split(".")
if "This application is temporarily over its serving quota" not in ip and len(ip) > 10 and len(ipitems) ==4:
indigo.variable.updateValue("my_IP_address", ip )
indigo.server.log("publicIpnumber:"+ ip)
indigo.variable.updateValue("Internet", "True" )
return
else:
msg= subprocess.Popen("/usr/bin/curl --max-time 4 http://checkip.dyndns.org",shell=True,stdout=subprocess.PIPE,stderr=subprocess.PIPE).communicate()[0]
ip = msg.split("Current IP Address: ")
if len(ip) > 1:
ip = ip[1].split("</body>")[0]
ipitems= ip.split(".")
if len(ip) > 10 and len(ipitems) ==4:
indigo.variable.updateValue("my_IP_address", ip )
indigo.server.log("publicIpnumber:"+ ip)
indigo.variable.updateValue("Internet", "True" )
return
indigo.variable.updateValue("Internet", "False" )
indigo.server.log("trying to get publicIpnumber, return: "+ msg)
except Exception, e:
indigo.server.log(u"in Line '%s' has error='%s'" % (sys.exc_traceback.tb_lineno, e))
indigo.variable.updateValue("Internet", "False" )
Users browsing this forum: No registered users and 7 guests