Forum Discussion

mcretacci's avatar
mcretacci
New Contributor
4 months ago

Testing with text files

Hi,

i was wondering if anyone has tried testing with log files. im creating a test that looks over text files and put a parameter if the logfile is less than or greater than the value put. this is the code i have so far but it keeps giving me an error with the script im making. Any thoughts or ideas on how i can make this happen?

 

import sys
import os
import aq
def read_text_file_and_test(file_path):
   try:
       with open(file_path, 'r') as file:
if __name__ == "__main__":
   if len(sys.argv) != 2:
       print("Usage: python test_script.py <path_to_text_file>")
       sys.exit(1)
   text_file_path = sys.argv[1]
   if not os.path.isfile(text_file_path):
       print("The provided file does not exist.")
       sys.exit(1)
   read_text_file_and_test(text_file_path)

6 Replies