f51804811274cbfc28fe8a5b77bfcc3df95048bf gperez2 Sun Sep 15 15:38:46 2024 -0700 Code review feedback edit, refs #34409 diff --git src/utils/qa/qaTestScript.py src/utils/qa/qaTestScript.py index a25f0b3..9efbc4b 100755 --- src/utils/qa/qaTestScript.py +++ src/utils/qa/qaTestScript.py @@ -31,41 +31,51 @@ from selenium.webdriver.common.action_chains import ActionChains from selenium import webdriver from selenium.webdriver.common.keys import Keys from selenium.webdriver.support.ui import Select from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as EC from selenium.common.exceptions import NoSuchElementException from selenium.common.exceptions import NoAlertPresentException import unittest, time, re, sys, argparse import getpass import os import psutil user = getpass.getuser() -# List of process names to check -proc_names_to_check = ["chrome", "chromedriver", "google-chrome", "chrome_crashpad_handler"] +def kill_user_processes(proc_names_to_check): + """ + Kills processes with names in the specified list that belong to the user. + + Parameters: + proc_names_to_check (list): A list of process names to check. + """ # Iterate over all running processes for proc in psutil.process_iter(): # Check if the process name matches any in the list if proc.name() in proc_names_to_check: - # Check if the process belongs to the specified user + # Check if the process belongs to the user if proc.username() == user: # Kill the process proc.kill() +# List of process names to check +proc_names_to_check = ["chrome", "chromedriver", "google-chrome", "chrome_crashpad_handler"] +# Call the function to kill processes matching the names in the list for the user +kill_user_processes(proc_names_to_check) + #Make tmpdir for the cron try: os.makedirs("/hive/users/"+user+"/selenium/chrom113/cron/TMP", exist_ok=True) except OSError as e: print(f"Error creating directory: {e}") os.environ['TMPDIR'] = "/hive/users/"+user+"/selenium/chrom113/cron/TMP" def initialize_driver(headless): """Initiates which webdriver to run for headless mode or local mode""" options = Options() if headless: options.add_argument('--headless') options.add_argument('--no-sandbox') options.add_argument("--headless") options.add_argument('--disable-dev-shm-usage')