Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _process_output(cmd, reg_pattern):
sys_ifname = ["lo", "sit0", "virbr0"]
try:
output = session.cmd_output_safe(cmd)
ifname_list = re.findall(reg_pattern, output, re.I)
if not ifname_list:
return None
if mac_address:
return ifname_list[0]
for ifname in sys_ifname:
if ifname in ifname_list:
ifname_list.remove(ifname)
return ifname_list
except aexpect.ShellCmdError:
return None
pgrep_process = "'^gdm$'"
else:
command = "Xorg"
pgrep_process = "Xorg"
try:
pid = session.cmd("pgrep %s" % pgrep_process)
session.cmd("killall %s" % command)
utils_misc.wait_for(lambda: _is_pid_alive(session, pid), 10,
timeout, 0.2)
except Exception:
pass
try:
session.cmd("ps -C %s" % command)
except ShellCmdError:
raise exceptions.TestFail("X/gdm not running")