#NEWLINE# def register_ip( domain , hostname , ipaddr ) : #NEWLINE# #INDENT# connection = connect_route53 ( ) #NEWLINE# zone = connection . get_zone ( domain ) #NEWLINE# record = zone . get_a ( hostname ) #NEWLINE# if ( record is not None ) : #NEWLINE# #INDENT# old_ipaddr = record . resource_records [ 0 ] #NEWLINE# if ( ipaddr == ipaddr ) : #NEWLINE# #INDENT# return False #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# zone . update_a ( hostname , ipaddr , 300 ) #NEWLINE# #UNINDENT# except DNSServerError : #NEWLINE# #INDENT# zone . add_a ( hostname , ipaddr , 300 ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# zone . add_a ( hostname , ipaddr , 300 ) #NEWLINE# #UNINDENT# return True