From 83888cd2f9c628153349b5d63e38dd8e1acc1f47 Mon Sep 17 00:00:00 2001 From: tyrin Date: Thu, 12 Sep 2024 13:53:09 +0300 Subject: [PATCH] removed script --- cycle.sh | 31 ------------------------------- management/commands/ingester.py | 10 +++++----- 2 files changed, 5 insertions(+), 36 deletions(-) delete mode 100644 cycle.sh diff --git a/cycle.sh b/cycle.sh deleted file mode 100644 index 67a7373..0000000 --- a/cycle.sh +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/bash - -# Function to run the command -run_command() { - python manage.py ingester & - PID=$! - echo "Started process with PID: $PID" -} - -# Function to terminate the command -interrupt_command() { - kill -SIGINT $PID - echo "Interrupted process with PID: $PID" -} - -# Run the command initially -run_command - -# Loop to restart the command every 2 hours until ingester_done.flag is found -while [ ! -f ingester_done.flag ]; do - # Wait for 2 hours (7200 seconds) - sleep 7200 - - # Terminate the command - interrupt_command - - # Restart the command - run_command -done - -echo "ingester_done.flag found. Exiting script." diff --git a/management/commands/ingester.py b/management/commands/ingester.py index 0a513b2..b9cc56c 100644 --- a/management/commands/ingester.py +++ b/management/commands/ingester.py @@ -42,7 +42,7 @@ class Command(BaseCommand): #fetching the file list - directory = input_with_timeout(f"Please enter the path to the directory containing the csv files [{previous_choice}]: ", 30) + directory = input_with_timeout(f"[{current_time()}] Please enter the path to the directory containing the csv files [{previous_choice}]: ", 30) if not directory: directory = previous_choice @@ -53,8 +53,8 @@ class Command(BaseCommand): csv_files = glob.glob(os.path.join(directory, '*csv*')) - self.stdout.write(f"Files found: {len(csv_files)}.") - self.stdout.write("Populating the file database...") + self.stdout.write(f"[{current_time()}] Files found: {len(csv_files)}.") + self.stdout.write(f"[{current_time()}] Populating the file database...") @@ -72,7 +72,7 @@ class Command(BaseCommand): if created: new_files_count += 1 #show how many duplicates were already in db - self.stdout.write(f"File database populated. \n{len(csv_files) - new_files_count} were already in the database.") + self.stdout.write(f"[{current_time()}] File database populated. \n{len(csv_files) - new_files_count} were already in the database.") @@ -114,7 +114,7 @@ class Command(BaseCommand): for catalog_file in catalog_files: if catalog_file.status == 'INGESTED': - self.stdout.write(f"[{current_time()}]Skipping {catalog_file.name} as it is already ingested.") + self.stdout.write(f"[{current_time()}] Skipping {catalog_file.name} as it is already ingested.") continue file_path = os.path.join(directory, catalog_file.name)