ca9f657a88b60c888dcc72d1ed8eb7a652ddbf2b
gperez2
  Sat Jan 7 13:37:17 2023 -0800
Code review change for the method to create a directory, refs #30442

diff --git src/utils/qa/searchedTermsCron.py src/utils/qa/searchedTermsCron.py
index d5d02df..a8704d2 100755
--- src/utils/qa/searchedTermsCron.py
+++ src/utils/qa/searchedTermsCron.py
@@ -25,31 +25,31 @@
 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])
 
 #Get the last 5 error logs from the RR/euro
 latestLogs=bash("ls /hive/data/inside/wwwstats/RR/2022/hgw1")
 latestLogs_euro=bash("ls /hive/data/inside/wwwstats/euroNode/2022/")
 latestLogs = latestLogs[len(latestLogs)-5:]
 latestLogs_euro=latestLogs_euro[len(latestLogs_euro)-5:]
 
 #Make a directory for the month (Y-M) 
 try:
-   bash("mkdir /hive/users/qateam/searchedTermsCronArchive/"+datetime.now().strftime("%Y-%m"))
+   os.makedirs("/hive/users/qateam/searchedTermsCronArchive/"+datetime.now().strftime("%Y-%m"))
 except subprocess.CalledProcessError:
         print("mkdir: cannot create directory /hive/users/qateam/searchedTermsCronArchive/"+datetime.now().strftime("%Y-%m")+": File exists")
         quit()
 
 #Nodes to check for error logs
 nodes = ['RR', 'asiaNode', 'euroNode']
 machines = ['hgw1','hgw2'] #Add hgw machines to check
 
 #For loop that goes through the RR/euro/asia error logs, trims down the hgSearch line, and writes to a file
 for node in nodes:
     with open('/hive/users/qateam/searchedTermsCronArchive/'+datetime.now().strftime("%Y-%m")+'/hgSearchTrimLogs', 'a') as f:
         if node == 'RR':
             for machine in machines:
                 for log in latestLogs:#Copy the 5 latest error logs for each of the rr machines
                     hgSearch=bash("zcat /hive/data/inside/wwwstats/"+node+"/2022/"+machine+"/"+log+"  | grep 'hgSearch' | tr '?' '\t' | cut -f 2 | grep 'search' | uniq")