diff options
author | Robert Loehning <robert.loehning@qt.io> | 2016-05-31 16:20:43 +0200 |
---|---|---|
committer | Robert Loehning <robert.loehning@qt.io> | 2016-05-31 14:52:17 +0000 |
commit | 4117ba7313506db14683ef14e73128bc2f5c80f1 (patch) | |
tree | a2de1dc012301d921e981da5ad023fabe456d931 | |
parent | 7d51d3849abeb3adaaeed9988694a38d7008a848 (diff) | |
download | qt-creator-4117ba7313506db14683ef14e73128bc2f5c80f1.tar.gz |
Squish: Replace remaining shell usages
Change-Id: Id7c2c1a17fed053f2e8601fc4c7716705e260431
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
-rw-r--r-- | tests/system/shared/hook_utils.py | 16 | ||||
-rw-r--r-- | tests/system/shared/qtcreator.py | 12 |
2 files changed, 10 insertions, 18 deletions
diff --git a/tests/system/shared/hook_utils.py b/tests/system/shared/hook_utils.py index 16314fe50f..9fc9e2463e 100644 --- a/tests/system/shared/hook_utils.py +++ b/tests/system/shared/hook_utils.py @@ -316,7 +316,8 @@ def __configureFW__(workingDir, projectName, isReleaseBuild, addToFW=True): # Needs admin privileges on Windows 7 # Using the deprecated "netsh firewall" because the newer # "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 # this doesn't check for other firewalls! @@ -333,11 +334,6 @@ def __isWinFirewallRunning__(): return __isWinFirewallRunning__.fireWallState 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 # Bad: executable/port could be empty strings - you should be aware of this def addExecutableAsAttachableAUT(executable, port, host=None): @@ -348,8 +344,8 @@ def addExecutableAsAttachableAUT(executable, port, host=None): squishSrv = __getSquishServer__() if (squishSrv == None): return False - result = subprocess.call(__fixQuotes__('"%s" --config addAttachableAUT "%s" %s:%s') - % (squishSrv, executable, host, port), shell=True) + result = subprocess.call([squishSrv, "--config", "addAttachableAUT", + executable, "%s:%s" % (host, port)]) if result == 0: test.passes("Added %s as attachable AUT" % executable) else: @@ -366,8 +362,8 @@ def removeExecutableAsAttachableAUT(executable, port, host=None): squishSrv = __getSquishServer__() if (squishSrv == None): return False - result = subprocess.call(__fixQuotes__('"%s" --config removeAttachableAUT "%s" %s:%s') - % (squishSrv, executable, host, port), shell=True) + result = subprocess.call([squishSrv, "--config", "removeAttachableAUT", + executable, "%s:%s" % (host, port)]) if result == 0: test.passes("Removed %s as attachable AUT" % executable) else: diff --git a/tests/system/shared/qtcreator.py b/tests/system/shared/qtcreator.py index b33d5f6170..5e2ebeae64 100644 --- a/tests/system/shared/qtcreator.py +++ b/tests/system/shared/qtcreator.py @@ -99,9 +99,8 @@ def waitForCleanShutdown(timeOut=10): # following work-around because os.kill() works for win not until python 2.7 if appCtxt.pid==-1: break - tasks = subprocess.Popen("tasklist /FI \"PID eq %d\"" % appCtxt.pid, shell=True,stdout=subprocess.PIPE) - output = tasks.communicate()[0] - tasks.stdout.close() + output = getOutputFromCmdline(["tasklist", "/FI", "PID eq %d" % appCtxt.pid], + acceptedError=1) if (output=="INFO: No tasks are running which match the specified criteria." or output=="" or output.find("ERROR")==0): shutdownDone=True @@ -131,14 +130,11 @@ def waitForCleanShutdown(timeOut=10): def checkForStillRunningQmlExecutable(possibleNames): for qmlHelper in possibleNames: - tasks = subprocess.Popen("tasklist /FI \"IMAGENAME eq %s\"" % qmlHelper, shell=True, - stdout=subprocess.PIPE) - output = tasks.communicate()[0] - tasks.stdout.close() + output = getOutputFromCmdline(["tasklist", "/FI", "IMAGENAME eq %s" % qmlHelper]) if "INFO: No tasks are running which match the specified criteria." in output: continue 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 else: print "%s is still running - failed to kill it" % qmlHelper |