myip = os.environ.get('REMOTE_ADDR')
if not myip: # empty string if not present
raise MyipMissing()
+ if not myip is None:
try:
- ip = ipaddr.IPAddress(myip) # throws an exception if the IP address is not valid
+ ipaddr.IPAddress(myip) # throws an exception if the IP address is not valid
except ValueError:
raise MyipInvalid()
# update bind
+ call_params = ['sudo', '/usr/local/bin/nsupdate_dyndns']
if offline:
- call(['sudo', '/usr/local/bin/nsupdate_dyndns', '--delete', hostname])
- else:
- call(['sudo', '/usr/local/bin/nsupdate_dyndns', '--ip', myip, hostname])
+ call_params.append('--delete')
+ if myip is not None:
+ call_params.extend(['--ip', myip])
+ call_params.append(hostname)
+ call(call_params)
# return success
print "Content-Type: text/html"