Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(22)

Side by Side Diff: build/android/pylib/chrome_test_server_spawner.py

Issue 10960050: Remove 'shell=True' in Popen and directly execute testserver.py (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: remove shell=True Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 """A "Test Server Spawner" that handles killing/stopping per-test test servers. 5 """A "Test Server Spawner" that handles killing/stopping per-test test servers.
6 6
7 It's used to accept requests from the device to spawn and kill instances of the 7 It's used to accept requests from the device to spawn and kill instances of the
8 chrome test server on the host. 8 chrome test server on the host.
9 """ 9 """
10 10
11 import BaseHTTPServer 11 import BaseHTTPServer
12 import json 12 import json
13 import logging 13 import logging
14 import os 14 import os
15 import select 15 import select
16 import shlex
16 import struct 17 import struct
17 import subprocess 18 import subprocess
18 import threading 19 import threading
19 import time 20 import time
20 import urlparse 21 import urlparse
21 22
22 import constants 23 import constants
23 from forwarder import Forwarder 24 from forwarder import Forwarder
24 import ports 25 import ports
25 26
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 206
206 def run(self): 207 def run(self):
207 logging.info('Start running the thread!') 208 logging.info('Start running the thread!')
208 self.wait_event.clear() 209 self.wait_event.clear()
209 self._GenerateCommandLineArguments() 210 self._GenerateCommandLineArguments()
210 command = '%s %s' % ( 211 command = '%s %s' % (
211 os.path.join(constants.CHROME_DIR, 'net', 'tools', 'testserver', 212 os.path.join(constants.CHROME_DIR, 'net', 'tools', 'testserver',
212 'testserver.py'), 213 'testserver.py'),
213 ' '.join(self.command_line)) 214 ' '.join(self.command_line))
214 logging.info(command) 215 logging.info(command)
215 self.process = subprocess.Popen(command, shell=True) 216 args = shlex.split(command)
Isaac (away) 2012/09/24 07:30:46 Thanks! We might be able to avoid shlex too, if c
217 self.process = subprocess.Popen(args)
216 if self.process: 218 if self.process:
217 if self.pipe_out: 219 if self.pipe_out:
218 self.is_ready = self._WaitToStartAndGetPortFromTestServer() 220 self.is_ready = self._WaitToStartAndGetPortFromTestServer()
219 else: 221 else:
220 self.is_ready = _CheckPortStatus(self.host_port, True) 222 self.is_ready = _CheckPortStatus(self.host_port, True)
221 if self.is_ready: 223 if self.is_ready:
222 self._test_server_forwarder = Forwarder( 224 self._test_server_forwarder = Forwarder(
223 self.adb, [(0, self.host_port)], self.tool, '127.0.0.1', 225 self.adb, [(0, self.host_port)], self.tool, '127.0.0.1',
224 self.build_type) 226 self.build_type)
225 # Check whether the forwarder is ready on the device. 227 # Check whether the forwarder is ready on the device.
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
395 def Start(self): 397 def Start(self):
396 listener_thread = threading.Thread(target=self._Listen) 398 listener_thread = threading.Thread(target=self._Listen)
397 listener_thread.setDaemon(True) 399 listener_thread.setDaemon(True)
398 listener_thread.start() 400 listener_thread.start()
399 time.sleep(1) 401 time.sleep(1)
400 402
401 def Stop(self): 403 def Stop(self):
402 if self.server.test_server_instance: 404 if self.server.test_server_instance:
403 self.server.test_server_instance.Stop() 405 self.server.test_server_instance.Stop()
404 self.server.shutdown() 406 self.server.shutdown()
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698