mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-05-31 01:33:56 +02:00
attempt 1 for executing external functions -- note, this doesn't work
Signed-off-by: CocoByte <nicolle.leclair@gmail.com>
This commit is contained in:
parent
c713b8958f
commit
d5c0ac7a0c
2 changed files with 114 additions and 53 deletions
|
@ -297,29 +297,20 @@ class Command(BaseCommand):
|
||||||
)
|
)
|
||||||
TransitionDomain.objects.all().delete()
|
TransitionDomain.objects.all().delete()
|
||||||
|
|
||||||
def handle( # noqa: C901
|
def parse_files(self, # noqa: C901
|
||||||
self,
|
|
||||||
domain_contacts_filename,
|
domain_contacts_filename,
|
||||||
contacts_filename,
|
contacts_filename,
|
||||||
domain_statuses_filename,
|
domain_statuses_filename,
|
||||||
**options,
|
reset_table,
|
||||||
):
|
sep,
|
||||||
"""Parse the data files and create TransitionDomains."""
|
debug_on,
|
||||||
sep = options.get("sep")
|
debug_max_entries_to_parse):
|
||||||
|
|
||||||
# If --resetTable was used, prompt user to confirm
|
# If --resetTable was used, prompt user to confirm
|
||||||
# deletion of table data
|
# deletion of table data
|
||||||
if options.get("resetTable"):
|
if reset_table:
|
||||||
self.prompt_table_reset()
|
self.prompt_table_reset()
|
||||||
|
|
||||||
# Get --debug argument
|
|
||||||
debug_on = options.get("debug")
|
|
||||||
|
|
||||||
# Get --LimitParse argument
|
|
||||||
debug_max_entries_to_parse = int(
|
|
||||||
options.get("limitParse")
|
|
||||||
) # set to 0 to parse all entries
|
|
||||||
|
|
||||||
# print message to terminal about which args are in use
|
# print message to terminal about which args are in use
|
||||||
self.print_debug_mode_statements(debug_on, debug_max_entries_to_parse)
|
self.print_debug_mode_statements(debug_on, debug_max_entries_to_parse)
|
||||||
|
|
||||||
|
@ -522,3 +513,32 @@ class Command(BaseCommand):
|
||||||
duplicate_domain_user_combos, duplicate_domains, users_without_email
|
duplicate_domain_user_combos, duplicate_domains, users_without_email
|
||||||
)
|
)
|
||||||
self.print_summary_status_findings(domains_without_status, outlier_statuses)
|
self.print_summary_status_findings(domains_without_status, outlier_statuses)
|
||||||
|
|
||||||
|
def handle(
|
||||||
|
self,
|
||||||
|
domain_contacts_filename,
|
||||||
|
contacts_filename,
|
||||||
|
domain_statuses_filename,
|
||||||
|
**options,
|
||||||
|
):
|
||||||
|
"""Parse the data files and create TransitionDomains."""
|
||||||
|
# Get --sep argument
|
||||||
|
sep = options.get("sep")
|
||||||
|
|
||||||
|
# Get --resetTable argument
|
||||||
|
reset_table = options.get("resetTable")
|
||||||
|
|
||||||
|
# Get --debug argument
|
||||||
|
debug_on = options.get("debug")
|
||||||
|
|
||||||
|
# Get --limitParse argument
|
||||||
|
debug_max_entries_to_parse = int(
|
||||||
|
options.get("limitParse")
|
||||||
|
) # set to 0 to parse all entries
|
||||||
|
self.parse_files(domain_contacts_filename,
|
||||||
|
contacts_filename,
|
||||||
|
domain_statuses_filename,
|
||||||
|
sep,
|
||||||
|
reset_table,
|
||||||
|
debug_on,
|
||||||
|
debug_max_entries_to_parse)
|
||||||
|
|
|
@ -35,26 +35,39 @@ class Command(BaseCommand):
|
||||||
# The file arguments have default values for running in the sandbox
|
# The file arguments have default values for running in the sandbox
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--loaderDirectory",
|
"--loaderDirectory",
|
||||||
default="migrationData/",
|
default="migrationData",
|
||||||
help="The location of the files used for load_transition_domain migration script"
|
help="The location of the files used for load_transition_domain migration script"
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"domain_contacts_filename",
|
"--loaderFilenames",
|
||||||
default="escrow_domain_contacts.daily.gov.GOV.txt",
|
default="escrow_domain_contacts.daily.gov.GOV.txt escrow_contacts.daily.gov.GOV.txt escrow_domain_statuses.daily.gov.GOV.txt",
|
||||||
help="Data file with domain contact information"
|
help="""The files used for load_transition_domain migration script.
|
||||||
)
|
Must appear IN ORDER and separated by spaces:
|
||||||
parser.add_argument(
|
domain_contacts_filename.txt contacts_filename.txt domain_statuses_filename.txt
|
||||||
"contacts_filename",
|
|
||||||
default="escrow_contacts.daily.gov.GOV.txt",
|
where...
|
||||||
help="Data file with contact information",
|
- domain_contacts_filename is the Data file with domain contact information
|
||||||
)
|
- contacts_filename is the Data file with contact information
|
||||||
parser.add_argument(
|
- domain_statuses_filename is the Data file with domain status information"""
|
||||||
"domain_statuses_filename",
|
|
||||||
default="escrow_domain_statuses.daily.gov.GOV.txt",
|
|
||||||
help="Data file with domain status information"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
parser.add_argument("--sep", default="|", help="Delimiter character")
|
# parser.add_argument(
|
||||||
|
# "domain_contacts_filename",
|
||||||
|
# default="escrow_domain_contacts.daily.gov.GOV.txt",
|
||||||
|
# help="Data file with domain contact information"
|
||||||
|
# )
|
||||||
|
# parser.add_argument(
|
||||||
|
# "contacts_filename",
|
||||||
|
# default="escrow_contacts.daily.gov.GOV.txt",
|
||||||
|
# help="Data file with contact information",
|
||||||
|
# )
|
||||||
|
# parser.add_argument(
|
||||||
|
# "domain_statuses_filename",
|
||||||
|
# default="escrow_domain_statuses.daily.gov.GOV.txt",
|
||||||
|
# help="Data file with domain status information"
|
||||||
|
# )
|
||||||
|
|
||||||
|
parser.add_argument("--sep", default="|", help="Delimiter character for the loader files")
|
||||||
|
|
||||||
parser.add_argument("--debug", action=argparse.BooleanOptionalAction)
|
parser.add_argument("--debug", action=argparse.BooleanOptionalAction)
|
||||||
|
|
||||||
|
@ -165,23 +178,40 @@ class Command(BaseCommand):
|
||||||
)
|
)
|
||||||
|
|
||||||
def run_migration_scripts(self,
|
def run_migration_scripts(self,
|
||||||
file_location,
|
options):
|
||||||
domain_contacts_filename,
|
|
||||||
contacts_filename,
|
file_location = options.get("loaderDirectory")+"/"
|
||||||
domain_statuses_filename):
|
filenames = options.get("loaderFilenames").split()
|
||||||
|
if len(filenames) < 3:
|
||||||
|
filenames_as_string = "{}".format(", ".join(map(str, filenames)))
|
||||||
|
logger.info(f"""
|
||||||
|
{TerminalColors.FAIL}
|
||||||
|
--loaderFilenames expected 3 filenames to follow it,
|
||||||
|
but only {len(filenames)} were given:
|
||||||
|
{filenames_as_string}
|
||||||
|
|
||||||
|
PLEASE MODIFY THE SCRIPT AND TRY RUNNING IT AGAIN
|
||||||
|
============= TERMINATING =============
|
||||||
|
{TerminalColors.ENDC}
|
||||||
|
""")
|
||||||
|
return
|
||||||
|
domain_contacts_filename = filenames[0]
|
||||||
|
contacts_filename = filenames[1]
|
||||||
|
domain_statuses_filename = filenames[2]
|
||||||
|
|
||||||
files_are_correct = TerminalHelper.query_yes_no(
|
files_are_correct = TerminalHelper.query_yes_no(
|
||||||
f"""
|
f"""
|
||||||
{TerminalColors.YELLOW}
|
{TerminalColors.YELLOW}
|
||||||
PLEASE CHECK:
|
*** IMPORTANT: VERIFY THE FOLLOWING ***
|
||||||
The loader scripts expect to find the following files:
|
|
||||||
|
The migration scripts are looking in directory....
|
||||||
|
{file_location}
|
||||||
|
|
||||||
|
....for the following files:
|
||||||
- domain contacts: {domain_contacts_filename}
|
- domain contacts: {domain_contacts_filename}
|
||||||
- contacts: {contacts_filename}
|
- contacts: {contacts_filename}
|
||||||
- domain statuses: {domain_statuses_filename}
|
- domain statuses: {domain_statuses_filename}
|
||||||
|
|
||||||
The files should be at the following directory;
|
|
||||||
{file_location}
|
|
||||||
|
|
||||||
Does this look correct?{TerminalColors.ENDC}"""
|
Does this look correct?{TerminalColors.ENDC}"""
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -190,22 +220,37 @@ class Command(BaseCommand):
|
||||||
logger.info(f"""
|
logger.info(f"""
|
||||||
{TerminalColors.YELLOW}
|
{TerminalColors.YELLOW}
|
||||||
PLEASE Re-Run the script with the correct file location and filenames:
|
PLEASE Re-Run the script with the correct file location and filenames:
|
||||||
EXAMPLE:
|
|
||||||
|
|
||||||
|
EXAMPLE:
|
||||||
|
docker compose run -T app ./manage.py test_domain_migration --runLoaders --loaderDirectory /app/tmp --loaderFilenames escrow_domain_contacts.daily.gov.GOV.txt escrow_contacts.daily.gov.GOV.txt escrow_domain_statuses.daily.gov.GOV.txt
|
||||||
|
|
||||||
""")
|
""")
|
||||||
return
|
return
|
||||||
load_transition_domain_command.handle(
|
|
||||||
domain_contacts_filename,
|
# Get --sep argument
|
||||||
contacts_filename,
|
sep = options.get("sep")
|
||||||
domain_statuses_filename
|
|
||||||
)
|
# Get --resetTable argument
|
||||||
|
reset_table = options.get("resetTable")
|
||||||
|
|
||||||
|
# Get --debug argument
|
||||||
|
debug_on = options.get("debug")
|
||||||
|
|
||||||
|
# Get --limitParse argument
|
||||||
|
debug_max_entries_to_parse = int(
|
||||||
|
options.get("limitParse")
|
||||||
|
) # set to 0 to parse all entries
|
||||||
|
load_transition_domain_command.parse_files(load_transition_domain_command,
|
||||||
|
domain_contacts_filename,
|
||||||
|
contacts_filename,
|
||||||
|
domain_statuses_filename,
|
||||||
|
sep,
|
||||||
|
reset_table,
|
||||||
|
debug_on,
|
||||||
|
debug_max_entries_to_parse)
|
||||||
|
|
||||||
def handle(
|
def handle(
|
||||||
self,
|
self,
|
||||||
# domain_contacts_filename,
|
|
||||||
# contacts_filename,
|
|
||||||
# domain_statuses_filename,
|
|
||||||
**options,
|
**options,
|
||||||
):
|
):
|
||||||
"""
|
"""
|
||||||
|
@ -244,11 +289,7 @@ class Command(BaseCommand):
|
||||||
|
|
||||||
# Run migration scripts if specified by user...
|
# Run migration scripts if specified by user...
|
||||||
if run_loaders_on:
|
if run_loaders_on:
|
||||||
file_location = options.get("loaderDirectory")
|
|
||||||
# domain_contacts_filename = options.get("domain_contacts_filename")
|
# domain_contacts_filename = options.get("domain_contacts_filename")
|
||||||
# contacts_filename = options.get("contacts_filename")
|
# contacts_filename = options.get("contacts_filename")
|
||||||
# domain_statuses_filename = options.get("domain_statuses_filename")
|
# domain_statuses_filename = options.get("domain_statuses_filename")
|
||||||
# self.run_migration_scripts(file_location,
|
self.run_migration_scripts(options)
|
||||||
# domain_contacts_filename,
|
|
||||||
# contacts_filename,
|
|
||||||
# domain_statuses_filename)
|
|
Loading…
Add table
Add a link
Reference in a new issue