forked from qt-creator/qt-creator
Squish: Replace remaining shell usages
Change-Id: Id7c2c1a17fed053f2e8601fc4c7716705e260431 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -316,7 +316,8 @@ def __configureFW__(workingDir, projectName, isReleaseBuild, addToFW=True):
|
|||||||
# Needs admin privileges on Windows 7
|
# Needs admin privileges on Windows 7
|
||||||
# Using the deprecated "netsh firewall" because the newer
|
# Using the deprecated "netsh firewall" because the newer
|
||||||
# "netsh advfirewall" would need admin privileges on Windows Vista, too.
|
# "netsh advfirewall" would need admin privileges on Windows Vista, too.
|
||||||
return subprocess.call('netsh firewall %s allowedprogram "%s.exe" %s %s' % (mode, path, projectName, enable))
|
return subprocess.call(["netsh", "firewall", mode, "allowedprogram",
|
||||||
|
"%s.exe" % path, projectName, enable])
|
||||||
|
|
||||||
# helper to check whether win firewall is running or not
|
# helper to check whether win firewall is running or not
|
||||||
# this doesn't check for other firewalls!
|
# this doesn't check for other firewalls!
|
||||||
@@ -333,11 +334,6 @@ def __isWinFirewallRunning__():
|
|||||||
return __isWinFirewallRunning__.fireWallState
|
return __isWinFirewallRunning__.fireWallState
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def __fixQuotes__(string):
|
|
||||||
if platform.system() in ('Windows', 'Microsoft'):
|
|
||||||
string = '"' + string + '"'
|
|
||||||
return string
|
|
||||||
|
|
||||||
# this function adds the given executable as an attachable AUT
|
# this function adds the given executable as an attachable AUT
|
||||||
# Bad: executable/port could be empty strings - you should be aware of this
|
# Bad: executable/port could be empty strings - you should be aware of this
|
||||||
def addExecutableAsAttachableAUT(executable, port, host=None):
|
def addExecutableAsAttachableAUT(executable, port, host=None):
|
||||||
@@ -348,8 +344,8 @@ def addExecutableAsAttachableAUT(executable, port, host=None):
|
|||||||
squishSrv = __getSquishServer__()
|
squishSrv = __getSquishServer__()
|
||||||
if (squishSrv == None):
|
if (squishSrv == None):
|
||||||
return False
|
return False
|
||||||
result = subprocess.call(__fixQuotes__('"%s" --config addAttachableAUT "%s" %s:%s')
|
result = subprocess.call([squishSrv, "--config", "addAttachableAUT",
|
||||||
% (squishSrv, executable, host, port), shell=True)
|
executable, "%s:%s" % (host, port)])
|
||||||
if result == 0:
|
if result == 0:
|
||||||
test.passes("Added %s as attachable AUT" % executable)
|
test.passes("Added %s as attachable AUT" % executable)
|
||||||
else:
|
else:
|
||||||
@@ -366,8 +362,8 @@ def removeExecutableAsAttachableAUT(executable, port, host=None):
|
|||||||
squishSrv = __getSquishServer__()
|
squishSrv = __getSquishServer__()
|
||||||
if (squishSrv == None):
|
if (squishSrv == None):
|
||||||
return False
|
return False
|
||||||
result = subprocess.call(__fixQuotes__('"%s" --config removeAttachableAUT "%s" %s:%s')
|
result = subprocess.call([squishSrv, "--config", "removeAttachableAUT",
|
||||||
% (squishSrv, executable, host, port), shell=True)
|
executable, "%s:%s" % (host, port)])
|
||||||
if result == 0:
|
if result == 0:
|
||||||
test.passes("Removed %s as attachable AUT" % executable)
|
test.passes("Removed %s as attachable AUT" % executable)
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -99,9 +99,8 @@ def waitForCleanShutdown(timeOut=10):
|
|||||||
# following work-around because os.kill() works for win not until python 2.7
|
# following work-around because os.kill() works for win not until python 2.7
|
||||||
if appCtxt.pid==-1:
|
if appCtxt.pid==-1:
|
||||||
break
|
break
|
||||||
tasks = subprocess.Popen("tasklist /FI \"PID eq %d\"" % appCtxt.pid, shell=True,stdout=subprocess.PIPE)
|
output = getOutputFromCmdline(["tasklist", "/FI", "PID eq %d" % appCtxt.pid],
|
||||||
output = tasks.communicate()[0]
|
acceptedError=1)
|
||||||
tasks.stdout.close()
|
|
||||||
if (output=="INFO: No tasks are running which match the specified criteria."
|
if (output=="INFO: No tasks are running which match the specified criteria."
|
||||||
or output=="" or output.find("ERROR")==0):
|
or output=="" or output.find("ERROR")==0):
|
||||||
shutdownDone=True
|
shutdownDone=True
|
||||||
@@ -131,14 +130,11 @@ def waitForCleanShutdown(timeOut=10):
|
|||||||
|
|
||||||
def checkForStillRunningQmlExecutable(possibleNames):
|
def checkForStillRunningQmlExecutable(possibleNames):
|
||||||
for qmlHelper in possibleNames:
|
for qmlHelper in possibleNames:
|
||||||
tasks = subprocess.Popen("tasklist /FI \"IMAGENAME eq %s\"" % qmlHelper, shell=True,
|
output = getOutputFromCmdline(["tasklist", "/FI", "IMAGENAME eq %s" % qmlHelper])
|
||||||
stdout=subprocess.PIPE)
|
|
||||||
output = tasks.communicate()[0]
|
|
||||||
tasks.stdout.close()
|
|
||||||
if "INFO: No tasks are running which match the specified criteria." in output:
|
if "INFO: No tasks are running which match the specified criteria." in output:
|
||||||
continue
|
continue
|
||||||
else:
|
else:
|
||||||
if subprocess.call("taskkill /F /FI \"IMAGENAME eq %s\"" % qmlHelper, shell=True) == 0:
|
if subprocess.call(["taskkill", "/F", "/FI", "IMAGENAME eq %s" % qmlHelper]) == 0:
|
||||||
print "Killed still running %s" % qmlHelper
|
print "Killed still running %s" % qmlHelper
|
||||||
else:
|
else:
|
||||||
print "%s is still running - failed to kill it" % qmlHelper
|
print "%s is still running - failed to kill it" % qmlHelper
|
||||||
|
|||||||
Reference in New Issue
Block a user