Remove print statements

This commit is contained in:
Rebecca Hsieh 2024-04-15 15:26:05 -07:00
parent cdf053547d
commit 3660932795
No known key found for this signature in database
2 changed files with 12 additions and 37 deletions

View file

@ -1686,48 +1686,41 @@ class Domain(TimeStampedModel, DomainHelper):
logger.error("Error _delete_hosts_if_not_used, code was %s error was %s" % (e.code, e))
def _fix_unknown_state(self, cleaned):
# print("!! GOT INTO _fix_unknown_state")
try:
self._add_missing_contacts(cleaned)
self._add_missing_contacts_if_unknown(cleaned)
except Exception as e:
logger.error(
"%s couldn't _add_missing_contacts, error was %s."
"%s couldn't _add_missing_contacts_if_unknown, error was %s."
"Domain will still be in UNKNOWN state." % (self.name, e)
)
if len(self.nameservers) >= 2:
# print("!! GOT INTO _fix_unknown_state -> have 2 or more nameserver so ready state")
self.ready()
self.save()
@transition(field="state", source=State.UNKNOWN, target=State.DNS_NEEDED)
def _add_missing_contacts(self, cleaned):
def _add_missing_contacts_if_unknown(self, cleaned):
"""
_add_missing_contacts: Add contacts (SECURITY, TECHNICAL, and/or ADMINISTRATIVE)
_add_missing_contacts_if_unknown: Add contacts (SECURITY, TECHNICAL, and/or ADMINISTRATIVE)
if they are missing, AND switch the state to DNS_NEEDED from UNKNOWN (if it
is in an UNKNOWN state, that is an error state)
Note: The transition state change happens at the end of the function
"""
# print("!! GOT INTO _add_missing_contacts ")
missingAdmin = True
missingSecurity = True
missingTech = True
# print("cleaned ", cleaned)
if len(cleaned.get("_contacts")) < 3:
# print("!! GOT INTO _add_missing_contacts -> in if statement")
for contact in cleaned.get("_contacts"):
# this means we see it
if contact.type == "admin":
missingAdmin = False
if contact.type == "security":
if contact.type == PublicContact.ContactTypeChoices.ADMINISTRATIVE:
mitestssingAdmin = False
if contact.type == PublicContact.ContactTypeChoices.SECURITY:
missingSecurity = False
if contact.type == "tech":
if contact.type == PublicContact.ContactTypeChoices.TECHNICAL:
missingTech = False
# we are only creating if it doesn't exist so we don't overwrite
# We are only creating if it doesn't exist so we don't overwrite
if missingAdmin:
administrative_contact = self.get_default_administrative_contact()
administrative_contact.save()
@ -1738,8 +1731,6 @@ class Domain(TimeStampedModel, DomainHelper):
technical_contact = self.get_default_technical_contact()
technical_contact.save()
# print("!! GOT INTO _add_missing_contacts -> if statement finished ")
def _fetch_cache(self, fetch_hosts=False, fetch_contacts=False):
"""Contact registry for info about a domain."""
try:
@ -1749,7 +1740,6 @@ class Domain(TimeStampedModel, DomainHelper):
self._update_hosts_and_contacts(cleaned, fetch_hosts, fetch_contacts)
if self.state == self.State.UNKNOWN:
# print("!! GOT INTO if self.state == self.State.UNKNOWN: ")
self._fix_unknown_state(cleaned)
if fetch_hosts:
self._update_hosts_and_ips_in_db(cleaned)
@ -1951,7 +1941,6 @@ class Domain(TimeStampedModel, DomainHelper):
# Does the item we're grabbing match
# what we have in our DB?
if existing_contact.email != public_contact.email or existing_contact.registry_id != public_contact.registry_id:
print("******* IN IF STATEMENT!!!!! ***********")
existing_contact.delete()
public_contact.save()
logger.warning("Requested PublicContact is out of sync " "with DB.")