mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-05-31 01:33:56 +02:00
Logging updates
This commit is contained in:
parent
a2f0be72ce
commit
a19f2dde3a
4 changed files with 61 additions and 17 deletions
|
@ -273,7 +273,7 @@ class Command(BaseCommand):
|
|||
|
||||
--------------------------------------------
|
||||
Found {total_outlier_statuses} unaccounted
|
||||
for statuses-
|
||||
for statuses
|
||||
--------------------------------------------
|
||||
|
||||
No mappings found for the following statuses
|
||||
|
@ -601,15 +601,6 @@ class Command(BaseCommand):
|
|||
|
||||
TransitionDomain.objects.bulk_create(to_create)
|
||||
|
||||
logger.info(
|
||||
f"""{TerminalColors.OKGREEN}
|
||||
============= FINISHED ===============
|
||||
Created {total_new_entries} transition domain entries,
|
||||
updated {total_updated_domain_entries} transition domain entries
|
||||
{TerminalColors.ENDC}
|
||||
"""
|
||||
)
|
||||
|
||||
# Print a summary of findings (duplicate entries,
|
||||
# missing data..etc.)
|
||||
self.print_summary_duplications(
|
||||
|
@ -617,10 +608,32 @@ class Command(BaseCommand):
|
|||
)
|
||||
self.print_summary_status_findings(domains_without_status, outlier_statuses)
|
||||
|
||||
|
||||
logger.info(
|
||||
f"""{TerminalColors.OKGREEN}
|
||||
============= FINISHED ===============
|
||||
Created {total_new_entries} transition domain entries,
|
||||
Updated {total_updated_domain_entries} transition domain entries
|
||||
|
||||
{TerminalColors.YELLOW}
|
||||
----- DUPLICATES FOUND -----
|
||||
{len(duplicate_domain_user_combos)} DOMAIN - USER pairs
|
||||
were NOT unique in the supplied data files.
|
||||
{len(duplicate_domains)} DOMAINS were NOT unique in
|
||||
the supplied data files.
|
||||
|
||||
----- STATUSES -----
|
||||
{len(domains_without_status)} DOMAINS had NO status (defaulted to READY).
|
||||
{len(outlier_statuses)} Statuses were invalid (defaulted to READY).
|
||||
|
||||
{TerminalColors.ENDC}
|
||||
"""
|
||||
)
|
||||
|
||||
# Prompt the user if they want to load additional data on the domains
|
||||
title = "Do you wish to load additional data for TransitionDomains?"
|
||||
proceed = TerminalHelper.prompt_for_execution(
|
||||
system_exit_on_terminate=False,
|
||||
system_exit_on_terminate=True,
|
||||
info_to_inspect=f"""
|
||||
!!! ENSURE THAT ALL FILENAMES ARE CORRECT BEFORE PROCEEDING
|
||||
==Master data file==
|
||||
|
|
|
@ -309,7 +309,7 @@ class Command(BaseCommand):
|
|||
proceed = False
|
||||
if prompts_enabled:
|
||||
proceed = TerminalHelper.prompt_for_execution(
|
||||
False,
|
||||
True,
|
||||
command_string,
|
||||
"Running load_transition_domain script",
|
||||
)
|
||||
|
@ -337,7 +337,7 @@ class Command(BaseCommand):
|
|||
proceed = False
|
||||
if prompts_enabled:
|
||||
proceed = TerminalHelper.prompt_for_execution(
|
||||
False,
|
||||
True,
|
||||
command_string,
|
||||
"Running transfer_transition_domains_to_domains script",
|
||||
)
|
||||
|
|
|
@ -8,6 +8,7 @@ import re
|
|||
import logging
|
||||
|
||||
import os
|
||||
import sys
|
||||
from typing import List, Tuple
|
||||
|
||||
from registrar.models.transition_domain import TransitionDomain
|
||||
|
@ -232,9 +233,25 @@ class LoadExtraTransitionDomain:
|
|||
{TerminalColors.ENDC}
|
||||
"""
|
||||
)
|
||||
# TODO
|
||||
if TransitionDomain.objects.all().count() != len(updated_transition_domains):
|
||||
logger.error("Something bad happened")
|
||||
|
||||
# DATA INTEGRITY CHECK
|
||||
# Make sure every Transition Domain got updated
|
||||
total_transition_domains = TransitionDomain.objects.all().count()
|
||||
total_updates_made = TransitionDomain.objects.all().count()
|
||||
if total_transition_domains != total_updates_made:
|
||||
logger.error(f"""{TerminalColors.Fail}
|
||||
WARNING: something went wrong processing domain information data.
|
||||
|
||||
Total Transition Domains expecting a data update: {total_transition_domains}
|
||||
Total updates made: {total_updates_made}
|
||||
|
||||
^ These totals should match, but they don't. This
|
||||
error should never occur, but could indicate
|
||||
corrupt data. Please check logs to diagnose.
|
||||
|
||||
----- TERMINATING ----
|
||||
""")
|
||||
sys.exit()
|
||||
|
||||
def parse_creation_expiration_data(self, domain_name, transition_domain):
|
||||
"""Grabs expiration_date from the parsed files and associates it
|
||||
|
|
|
@ -185,9 +185,23 @@ class TerminalHelper:
|
|||
li = file.readlines()
|
||||
total_line = len(li)
|
||||
return total_line
|
||||
|
||||
|
||||
@staticmethod
|
||||
def print_to_file_conditional(print_condition: bool, filename: str, file_directory: str, file_contents: str):
|
||||
"""Sometimes logger outputs get insanely huge.
|
||||
"""
|
||||
if (print_condition):
|
||||
# Add a slash if the last character isn't one
|
||||
if file_directory and file_directory[-1] != "/":
|
||||
file_directory += "/"
|
||||
# Assemble filepath
|
||||
filepath = f"{file_directory}{filename}.txt"
|
||||
# Write to file
|
||||
logger.info(f"{TerminalColors.MAGENTA}Writing to file {filepath}...{TerminalColors.ENDC}")
|
||||
with open(f"{filepath}", "w+") as f:
|
||||
f.write(file_contents)
|
||||
|
||||
|
||||
@staticmethod
|
||||
def printProgressBar (iteration, total, prefix = 'Progress:', suffix = 'Complete', decimals = 1, length = 100, fill = '█', printEnd = "\r"):
|
||||
"""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue