Added error suppression

This commit is contained in:
Bigsk 2023-02-25 01:36:43 +08:00
parent eff8af898c
commit b35bf977f9

View File

@ -50,6 +50,7 @@ class AliDDNS(object):
else:
print("Your ipv4 address is:", self.__v4)
try:
describe_v4 = DescribeDomainRecordsRequest()
describe_v4.set_accept_format('json')
@ -75,6 +76,8 @@ class AliDDNS(object):
self.__client.do_action_with_exception(update_v4)
print('Your ipv4 record has been updated successfully.')
except Exception as e:
print("Failed to update your ipv4 record,", e)
# Get local public ipv6 address
@ -86,6 +89,7 @@ class AliDDNS(object):
else:
print("Your ipv6 address is:", self.__v6)
try:
describe_v6 = DescribeDomainRecordsRequest()
describe_v6.set_accept_format('json')
@ -111,6 +115,8 @@ class AliDDNS(object):
self.__client.do_action_with_exception(update_v6)
print('Your ipv6 record has been updated successfully.')
except Exception as e:
print("Failed to update your ipv4 record,", e)
if __name__ == "__main__":
dns = AliDDNS("MainDomain.com", "SubDomain", "AccessKey ID", "AccessKey Secret")