a5f3fff630cd9743abf97b1984c0b9869eb85cfc
lrnassar
  Wed Jun 4 07:58:10 2025 -0700
Wrapping the request function in a try statement so that when the server is entirely unresponsive we don't get a spam requests lib spam, but instead get a two line email about the issue. No RM.

diff --git src/utils/qa/hgTracksTiming.py src/utils/qa/hgTracksTiming.py
index fc2e325b8bf..d062906014d 100644
--- src/utils/qa/hgTracksTiming.py
+++ src/utils/qa/hgTracksTiming.py
@@ -235,30 +235,31 @@
         for filename in os.listdir(save_dir):
             if filename.startswith("monthFile") and os.path.isfile(filename):
                 os.remove(filename)
 
         # Create a new blank file with the specified path
         with open(fileToCheckAndReport, 'w') as new_file:
             pass  # Creates an empty file
 
         print("Monthly reminder to check the hgTracksTiming information for any abnormalities:\n")
         if user == 'qateam':
             print("https://genecats.gi.ucsc.edu/qa/test-results/hgTracksTiming/")
         else:
             print("https://hgwdev.gi.ucsc.edu/~"+user+"/cronResults/hgTracksTiming/")   
 
 def queryServersAndReport(server,url,filePath,today,n,user):
+    try:
         start_time = time.time()
         response = requests.get(url, verify=False)  # Disable SSL verification
         end_time = time.time()
         load_time = end_time - start_time
         page_content = response.text  # Get the page content
     
         # Check if the expected string is in the response
         if "END hgTracks" in page_content:
             if load_time < 15:
                 problem = False
                 status = "SUCCESS"
             else:
                 problem = True
                 status = "FAIL - hgTracks page loaded, but load time over 15s"
         else:
@@ -268,30 +269,34 @@
         if problem == True:
             print("Potential problem with Genome Browser server.")
             print(f"URL: {url} | Status: {response.status_code} | Load Time: {load_time:.3f}s | Check: {status}")
             print("\nSee the latest timing numbers:")
             if user == 'qateam':
                 print("https://genecats.gi.ucsc.edu/qa/test-results/hgTracksTiming/")
             else:
                 print("https://hgwdev.gi.ucsc.edu/~"+user+"/cronResults/hgTracksTiming/")
     
         # Add a check here to make sure we are not writing out bad 200 or captcha failures, but still 
         # writing out problematic > 15s load times
         if load_time > .2:
             with open(filePath, "a") as file:
                 file.write(f"{today}\t{load_time:.3f}s\t{response.status_code}\n")
         
+    except:
+        print("Potential problem with Genome Browser server.")
+        print("Failed to connect to server: " + url)
+    
 def main():
     #Don't try to display the plot, this is for jupyter
     matplotlib.use('Agg')
     # Suppress SSL warnings - was due to an asia issue
     urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
     
     user = getpass.getuser()
     save_dir = create_save_dir(user)
     today = datetime.datetime.today().strftime("%Y-%m-%d-%H:%M")
 
     #Parse which servers to query
     options = parseArgs()
     servers = options.servers
 
     if servers == 'all':