def isVPNTaskRunning():
# Return True if the VPN task is still running, or the VPN connection is still active
# Return False if the VPN task is no longer running and the connection is not active
if fakeConnection(): return True
p = getPlatform()
if p == platforms.LINUX or p == platforms.RPI:
try:
command = "pidof openvpn"
if useSudo() : command = "sudo " + command
debugTrace("(Linux) Checking VPN task with " + command)
pid = os.system(command)
# This horrible call returns 0 if it finds a process, it's not returning the PID number
if xbmcaddon.Addon("service.vpn.manager").getSetting("alt_pid_check") == "true":
if pid > 0 : return True
else:
if pid == 0 : return True
debugTrace("(Linux) Didn't find a running process")
return False
except Exception as e:
errorTrace("platform.py", "VPN task list failed")
errorTrace("platform.py", str(e))
return False
if p == platforms.WINDOWS:
try:
command = 'tasklist /FI "IMAGENAME eq OPENVPN.EXE"'
debugTrace("(Windows) Checking VPN task with " + command)
args = shlex.split(command)
out = subprocess.check_output(args, creationflags=subprocess.SW_HIDE, shell=True).strip()
if "openvpn.exe" in out:
return True
else:
debugTrace("(Windows) Didn't find a running process")
return False
except Exception as e:
errorTrace("platform.py", "VPN task list failed")
errorTrace("platform.py", str(e))
return False
# **** ADD MORE PLATFORMS HERE ****
return False
评论列表
文章目录