fd9de5a36525c1f706433d87a293cd2bc4106bb4 gperez2 Tue Jan 2 17:46:05 2024 -0800 Updating the script to add an exception for January 1st since the script gets the five latest error logs within current year directory, No Redmine diff --git src/utils/qa/searchedTermsCron.py src/utils/qa/searchedTermsCron.py index 0366687..967c3b0 100755 --- src/utils/qa/searchedTermsCron.py +++ src/utils/qa/searchedTermsCron.py @@ -17,32 +17,36 @@ import sys import re import json import io import requests import subprocess from datetime import datetime user = getpass.getuser() def bash(cmd): """Input bash cmd and return stdout""" rawOutput = subprocess.run(cmd,check=True, shell=True, stdout=subprocess.PIPE, universal_newlines=True) return(rawOutput.stdout.split('\n')[0:-1]) -#Variable to get the current year +#Makes a variable for the current year. If the month is January then sets the year to the previous year. +if datetime.now().strftime("%m")=='01': + year=str(int(datetime.now().strftime("%Y"))-1) +else: year=datetime.now().strftime("%Y") + #Get the last 5 error logs from the RR/euro latestLogs=bash("ls /hive/data/inside/wwwstats/RR/"+year+"/hgw1") latestLogs_euro=bash("ls /hive/data/inside/wwwstats/euroNode/"+year+"/") latestLogs = latestLogs[len(latestLogs)-5:] latestLogs_euro=latestLogs_euro[len(latestLogs_euro)-5:] #Make a directory for the month (Y-M) try: os.makedirs("/hive/users/qateam/searchedTermsCronArchive/"+datetime.now().strftime("%Y-%m")) except OSError: print("mkdir: cannot create directory /hive/users/qateam/searchedTermsCronArchive/"+datetime.now().strftime("%Y-%m")+": File exists") sys.exit(1) #Nodes to check for error logs nodes = ['RR', 'asiaNode', 'euroNode']