instant-data-scraper-utils/bin/process-stage-6.py
2024-07-16 18:08:36 -04:00

64 lines
2.5 KiB
Python
Executable file

#!/usr/bin/env python
# Script Name: process-stage-6
import os
import subprocess
from pyfiglet import Figlet
from halo import Halo
# Define the paths based on the project details
PROJECT_ROOT = "/home/ld/mgk-scrapes"
BIN_STAGE_6_DIR = os.path.join(PROJECT_ROOT, 'bin', 'stage-6')
def run_scripts():
"""Run the specified scripts in order."""
scripts = [
os.path.join(BIN_STAGE_6_DIR, "prepare-stage-6.py"),
os.path.join(BIN_STAGE_6_DIR, "pre-sort.py"),
os.path.join(BIN_STAGE_6_DIR, "trim-invalid-rows-from-merger.py"),
os.path.join(BIN_STAGE_6_DIR, "delete-bad-matching-services.py"),
os.path.join(BIN_STAGE_6_DIR, "standardize-capital-letters.py"),
os.path.join(BIN_STAGE_6_DIR, "initial-deduplication.py"),
os.path.join(BIN_STAGE_6_DIR, "business-name-strip-structures.py"),
os.path.join(BIN_STAGE_6_DIR, "business-names-with-locations.py"),
os.path.join(BIN_STAGE_6_DIR, "uuid-business-1-by-gbp-business-phone.py"),
os.path.join(BIN_STAGE_6_DIR, "uuid-business-2-by-root-domain.py"),
os.path.join(BIN_STAGE_6_DIR, "uuid-business-3-by-business-name.py"),
os.path.join(BIN_STAGE_6_DIR, "re-order-columns.py"),
os.path.join(BIN_STAGE_6_DIR, "fill-in-missing-data.py"),
os.path.join(BIN_STAGE_6_DIR, "uuid-business-4-single-location-entries.py"),
os.path.join(BIN_STAGE_6_DIR, "standardize-yib.py"),
os.path.join(BIN_STAGE_6_DIR, "uniqify-pass-1.py"),
os.path.join(BIN_STAGE_6_DIR, "uniqify-pass-2.py"),
os.path.join(BIN_STAGE_6_DIR, "services-gbp-reputation-management.py"),
os.path.join(BIN_STAGE_6_DIR, "services-gbp-optimization.py"),
os.path.join(BIN_STAGE_6_DIR, "services-needs-website.py")
]
# Run scripts that do not require arguments
for script in scripts:
spinner = Halo(text=f'Running {os.path.basename(script)}', spinner='dots')
spinner.start()
try:
subprocess.run(["python", script], check=True)
spinner.succeed(f'Successfully ran {os.path.basename(script)}')
except subprocess.CalledProcessError as e:
spinner.fail(f"Error: {e}")
break
def main():
figlet = Figlet(font='slant')
script_name = "process-stage-6".replace("-", " ").title()
print(figlet.renderText(script_name))
print("Running scripts for Stage 6...\n")
run_scripts()
final_spinner = Halo(spinner='dots', color='green')
final_spinner.start()
final_spinner.succeed("All scripts completed.")
if __name__ == '__main__':
main()