本文整理汇总了Python中mozprocess.ProcessHandler.kill方法的典型用法代码示例。如果您正苦于以下问题:Python ProcessHandler.kill方法的具体用法?Python ProcessHandler.kill怎么用?Python ProcessHandler.kill使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mozprocess.ProcessHandler
的用法示例。
在下文中一共展示了ProcessHandler.kill方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: lint
# 需要导入模块: from mozprocess import ProcessHandler [as 别名]
# 或者: from mozprocess.ProcessHandler import kill [as 别名]
def lint(files, config, **kwargs):
tests_dir = os.path.join(kwargs['root'], 'testing', 'web-platform', 'tests')
def process_line(line):
try:
data = json.loads(line)
except ValueError:
return
data["level"] = "error"
data["path"] = os.path.relpath(os.path.join(tests_dir, data["path"]), kwargs['root'])
results.append(result.from_config(config, **data))
if files == [tests_dir]:
print >> sys.stderr, ("No specific files specified, running the full wpt lint"
" (this is slow)")
files = ["--all"]
cmd = [os.path.join(tests_dir, 'wpt'), 'lint', '--json'] + files
if platform.system() == 'Windows':
cmd.insert(0, sys.executable)
proc = ProcessHandler(cmd, env=os.environ, processOutputLine=process_line)
proc.run()
try:
proc.wait()
if proc.returncode != 0:
results.append(
result.from_config(config,
message="Lint process exited with return code %s" %
proc.returncode))
except KeyboardInterrupt:
proc.kill()
return results
示例2: _runCmd
# 需要导入模块: from mozprocess import ProcessHandler [as 别名]
# 或者: from mozprocess.ProcessHandler import kill [as 别名]
def _runCmd(self, args, retryLimit=None):
"""
Runs a command using adb
returns: instance of ProcessHandler
"""
retryLimit = retryLimit or self.retryLimit
finalArgs = [self._adbPath]
if self._serverHost is not None:
finalArgs.extend(['-H', self._serverHost])
if self._serverPort is not None:
finalArgs.extend(['-P', str(self._serverPort)])
if self._deviceSerial:
finalArgs.extend(['-s', self._deviceSerial])
finalArgs.extend(args)
self._logger.debug("_runCmd - command: %s" % ' '.join(finalArgs))
retries = 0
while retries < retryLimit:
proc = ProcessHandler(finalArgs, storeOutput=True,
processOutputLine=self._log)
proc.run()
proc.returncode = proc.wait()
if proc.returncode == None:
proc.kill()
retries += 1
else:
return proc
示例3: _run_profile
# 需要导入模块: from mozprocess import ProcessHandler [as 别名]
# 或者: from mozprocess.ProcessHandler import kill [as 别名]
def _run_profile(self):
command_args = utils.GenerateBrowserCommandLine(
self.browser_config["browser_path"],
self.browser_config["extra_args"],
self.profile_dir,
self.browser_config["init_url"]
)
def browser_log(line):
LOG.process_output(browser.pid, line)
browser = ProcessHandler(command_args, env=self.env,
processOutputLine=browser_log)
browser.run()
LOG.process_start(browser.pid, ' '.join(command_args))
try:
exit_code = browser.wait()
except KeyboardInterrupt:
browser.kill()
raise
LOG.process_exit(browser.pid, exit_code)
results_raw = '\n'.join(browser.output)
if not self.PROFILE_REGEX.search(results_raw):
LOG.info("Could not find %s in browser output"
% self.PROFILE_REGEX.pattern)
LOG.info("Raw results:%s" % results_raw)
raise TalosError("browser failed to close after being initialized")
示例4: _run_profile
# 需要导入模块: from mozprocess import ProcessHandler [as 别名]
# 或者: from mozprocess.ProcessHandler import kill [as 别名]
def _run_profile(self):
command_args = utils.GenerateBrowserCommandLine(
self.browser_config["browser_path"],
self.browser_config["extra_args"],
self.profile_dir,
self.browser_config["init_url"]
)
def browser_log(line):
logging.debug('BROWSER_OUTPUT: %s', line)
browser = ProcessHandler(command_args, env=self.env,
processOutputLine=browser_log)
browser.run()
try:
browser.wait()
except KeyboardInterrupt:
browser.kill()
raise
results_raw = '\n'.join(browser.output)
if not self.PROFILE_REGEX.search(results_raw):
logging.info("Could not find %s in browser output",
self.PROFILE_REGEX.pattern)
logging.info("Raw results:%s", results_raw)
raise TalosError("browser failed to close after being initialized")
示例5: _checkCmd
# 需要导入模块: from mozprocess import ProcessHandler [as 别名]
# 或者: from mozprocess.ProcessHandler import kill [as 别名]
def _checkCmd(self, args, timeout=None, retryLimit=None):
"""
Runs a command using adb and waits for the command to finish.
If timeout is specified, the process is killed after <timeout> seconds.
returns: returncode from process
"""
retryLimit = retryLimit or self.retryLimit
finalArgs = [self._adbPath]
if self._deviceSerial:
finalArgs.extend(['-s', self._deviceSerial])
finalArgs.extend(args)
self._logger.debug("_checkCmd - command: %s" % ' '.join(finalArgs))
if not timeout:
# We are asserting that all commands will complete in this
# time unless otherwise specified
timeout = self.default_timeout
timeout = int(timeout)
retries = 0
while retries < retryLimit:
proc = ProcessHandler(finalArgs, processOutputLine=self._log)
proc.run(timeout=timeout)
ret_code = proc.wait()
if ret_code == None:
proc.kill()
retries += 1
else:
return ret_code
raise DMError("Timeout exceeded for _checkCmd call after %d retries." % retries)
示例6: _runCmd
# 需要导入模块: from mozprocess import ProcessHandler [as 别名]
# 或者: from mozprocess.ProcessHandler import kill [as 别名]
def _runCmd(self, args, timeout=None, retryLimit=None):
"""
Runs a command using adb
If timeout is specified, the process is killed after <timeout> seconds.
returns: instance of ProcessHandler
"""
retryLimit = retryLimit or self.retryLimit
finalArgs = [self._adbPath]
if self._serverHost is not None:
finalArgs.extend(['-H', self._serverHost])
if self._serverPort is not None:
finalArgs.extend(['-P', str(self._serverPort)])
if self._deviceSerial:
finalArgs.extend(['-s', self._deviceSerial])
finalArgs.extend(args)
self._logger.debug("_runCmd - command: %s" % ' '.join(finalArgs))
if not timeout:
timeout = self.default_timeout
def _timeout():
self._logger.error("Timeout exceeded for _runCmd call '%s'" % ' '.join(finalArgs))
retries = 0
while retries < retryLimit:
proc = ProcessHandler(finalArgs, storeOutput=True,
processOutputLine=self._log, onTimeout=_timeout)
proc.run(timeout=timeout)
proc.returncode = proc.wait()
if proc.returncode == None:
proc.kill()
retries += 1
else:
return proc
示例7: run_process
# 需要导入模块: from mozprocess import ProcessHandler [as 别名]
# 或者: from mozprocess.ProcessHandler import kill [as 别名]
def run_process():
path = os.path.join(tests_dir, "lint")
proc = ProcessHandler([path, "--json"], env=os.environ,
processOutputLine=process_line)
proc.run()
try:
proc.wait()
except KeyboardInterrupt:
proc.kill()
示例8: ServoTestharnessExecutor
# 需要导入模块: from mozprocess import ProcessHandler [as 别名]
# 或者: from mozprocess.ProcessHandler import kill [as 别名]
class ServoTestharnessExecutor(ProcessTestExecutor):
convert_result = testharness_result_converter
def __init__(self, *args, **kwargs):
ProcessTestExecutor.__init__(self, *args, **kwargs)
self.result_data = None
self.result_flag = None
def run_test(self, test):
self.result_data = None
self.result_flag = threading.Event()
self.command = [self.binary, "--cpu", "--hard-fail",
urlparse.urljoin(self.http_server_url, test.url)]
if self.debug_args:
self.command = list(self.debug_args) + self.command
self.proc = ProcessHandler(self.command,
processOutputLine=[self.on_output],
onFinish=self.on_finish)
self.proc.run()
timeout = test.timeout * self.timeout_multiplier
# Now wait to get the output we expect, or until we reach the timeout
self.result_flag.wait(timeout + 5)
if self.result_flag.is_set() and self.result_data is not None:
self.result_data["test"] = test.url
result = self.convert_result(test, self.result_data)
self.proc.kill()
else:
if self.proc.proc.poll() is not None:
result = (test.result_cls("CRASH", None), [])
else:
self.proc.kill()
result = (test.result_cls("TIMEOUT", None), [])
self.runner.send_message("test_ended", test, result)
def on_output(self, line):
prefix = "ALERT: RESULT: "
line = line.decode("utf8", "replace")
if line.startswith(prefix):
self.result_data = json.loads(line[len(prefix):])
self.result_flag.set()
else:
if self.interactive:
print line
else:
self.logger.process_output(self.proc.pid,
line,
" ".join(self.command))
def on_finish(self):
self.result_flag.set()
示例9: _tooltool_fetch
# 需要导入模块: from mozprocess import ProcessHandler [as 别名]
# 或者: from mozprocess.ProcessHandler import kill [as 别名]
def _tooltool_fetch(self):
def outputHandler(line):
self._log_debug(line)
command = ["python", "tooltool.py", "fetch", "-m", "releng.manifest"]
proc = ProcessHandler(command, processOutputLine=outputHandler, storeOutput=False, cwd=EMULATOR_HOME_DIR)
proc.run()
try:
proc.wait()
except:
if proc.poll() is None:
proc.kill(signal.SIGTERM)
示例10: run_process
# 需要导入模块: from mozprocess import ProcessHandler [as 别名]
# 或者: from mozprocess.ProcessHandler import kill [as 别名]
def run_process(cmdargs):
# flake8 seems to handle SIGINT poorly. Handle it here instead
# so we can kill the process without a cryptic traceback.
orig = signal.signal(signal.SIGINT, signal.SIG_IGN)
proc = ProcessHandler(cmdargs, env=os.environ,
processOutputLine=process_line)
proc.run()
signal.signal(signal.SIGINT, orig)
try:
proc.wait()
except KeyboardInterrupt:
proc.kill()
示例11: _tooltool_fetch
# 需要导入模块: from mozprocess import ProcessHandler [as 别名]
# 或者: from mozprocess.ProcessHandler import kill [as 别名]
def _tooltool_fetch():
def outputHandler(line):
_log_debug(line)
_download_file(TOOLTOOL_URL, "tooltool.py", EMULATOR_HOME_DIR)
command = [sys.executable, "tooltool.py", "fetch", "-o", "-m", "releng.manifest"]
proc = ProcessHandler(command, processOutputLine=outputHandler, storeOutput=False, cwd=EMULATOR_HOME_DIR)
proc.run()
try:
proc.wait()
except:
if proc.poll() is None:
proc.kill(signal.SIGTERM)
示例12: _tooltool_fetch
# 需要导入模块: from mozprocess import ProcessHandler [as 别名]
# 或者: from mozprocess.ProcessHandler import kill [as 别名]
def _tooltool_fetch():
def outputHandler(line):
_log_debug(line)
command = ['python', 'tooltool.py', 'fetch', '-o', '-m', 'releng.manifest']
proc = ProcessHandler(
command, processOutputLine=outputHandler, storeOutput=False,
cwd=EMULATOR_HOME_DIR)
proc.run()
try:
proc.wait()
except:
if proc.poll() is None:
proc.kill(signal.SIGTERM)
示例13: _checkCmd
# 需要导入模块: from mozprocess import ProcessHandler [as 别名]
# 或者: from mozprocess.ProcessHandler import kill [as 别名]
def _checkCmd(self, args, timeout=None, retryLimit=None):
"""
Runs a command using adb and waits for the command to finish.
If timeout is specified, the process is killed after <timeout> seconds.
returns: returncode from process
"""
retryLimit = retryLimit or self.retryLimit
finalArgs = [self._adbPath]
if self._serverHost is not None:
finalArgs.extend(['-H', self._serverHost])
if self._serverPort is not None:
finalArgs.extend(['-P', str(self._serverPort)])
if self._deviceSerial:
finalArgs.extend(['-s', self._deviceSerial])
finalArgs.extend(args)
self._logger.debug("_checkCmd - command: %s" % ' '.join(finalArgs))
if not timeout:
# We are asserting that all commands will complete in this
# time unless otherwise specified
timeout = self.default_timeout
def _timeout():
self._logger.error("Timeout exceeded for _checkCmd call '%s'" % ' '.join(finalArgs))
timeout = int(timeout)
retries = 0
while retries < retryLimit:
proc = ProcessHandler(finalArgs, processOutputLine=self._log, onTimeout=_timeout)
proc.run(timeout=timeout)
ret_code = proc.wait()
if ret_code is None:
self._logger.error("Failed to launch %s (may retry)" % finalArgs)
proc.kill()
retries += 1
else:
if ret_code != 0:
self._logger.error("Non-zero return code (%d) from %s" % (ret_code, finalArgs))
self._logger.error("Output: %s" % proc.output)
output = ''.join(proc.output)
if self._noDevicesOutput in output:
raise DMError(self._noDevicesOutput)
return ret_code
raise DMError("Timeout exceeded for _checkCmd call after %d retries." % retries)
示例14: run_process
# 需要导入模块: from mozprocess import ProcessHandler [as 别名]
# 或者: from mozprocess.ProcessHandler import kill [as 别名]
def run_process(self, cmd, cwd=None, dump=False):
def _processOutput(line):
if self.verbose or dump:
print(line)
if self.verbose:
self.build_obj.log(logging.INFO, "autophone", {},
"Running '%s' in '%s'" % (cmd, cwd))
proc = ProcessHandler(cmd, cwd=cwd, processOutputLine=_processOutput,
processStderrLine=_processOutput)
proc.run()
proc_complete = False
try:
proc.wait()
if proc.proc.returncode == 0:
proc_complete = True
except:
if proc.poll() is None:
proc.kill(signal.SIGTERM)
if not proc_complete:
if not self.verbose:
print(proc.output)
return proc_complete
示例15: ServoRefTestExecutor
# 需要导入模块: from mozprocess import ProcessHandler [as 别名]
# 或者: from mozprocess.ProcessHandler import kill [as 别名]
class ServoRefTestExecutor(ProcessTestExecutor):
convert_result = reftest_result_converter
def __init__(self, browser, server_config, binary=None, timeout_multiplier=1,
screenshot_cache=None, debug_info=None, pause_after_test=False):
do_delayed_imports()
ProcessTestExecutor.__init__(self,
browser,
server_config,
timeout_multiplier=timeout_multiplier,
debug_info=debug_info)
self.protocol = Protocol(self, browser)
self.screenshot_cache = screenshot_cache
self.implementation = RefTestImplementation(self)
self.tempdir = tempfile.mkdtemp()
self.hosts_path = make_hosts_file()
def teardown(self):
try:
os.unlink(self.hosts_path)
except OSError:
pass
os.rmdir(self.tempdir)
ProcessTestExecutor.teardown(self)
def screenshot(self, test, viewport_size, dpi):
full_url = self.test_url(test)
with TempFilename(self.tempdir) as output_path:
debug_args, command = browser_command(
self.binary,
[render_arg(self.browser.render_backend), "--hard-fail", "--exit",
"-u", "Servo/wptrunner", "-Z", "disable-text-aa,load-webfonts-synchronously,replace-surrogates",
"--output=%s" % output_path, full_url],
self.debug_info)
for stylesheet in self.browser.user_stylesheets:
command += ["--user-stylesheet", stylesheet]
for pref in test.environment.get('prefs', {}):
command += ["--pref", pref]
command += ["--resolution", viewport_size or "800x600"]
if dpi:
command += ["--device-pixel-ratio", dpi]
self.command = debug_args + command
env = os.environ.copy()
env["HOST_FILE"] = self.hosts_path
env["RUST_BACKTRACE"] = "1"
if not self.interactive:
self.proc = ProcessHandler(self.command,
processOutputLine=[self.on_output],
env=env)
try:
self.proc.run()
timeout = test.timeout * self.timeout_multiplier + 5
rv = self.proc.wait(timeout=timeout)
except KeyboardInterrupt:
self.proc.kill()
raise
else:
self.proc = subprocess.Popen(self.command,
env=env)
try:
rv = self.proc.wait()
except KeyboardInterrupt:
self.proc.kill()
raise
if rv is None:
self.proc.kill()
return False, ("EXTERNAL-TIMEOUT", None)
if rv != 0 or not os.path.exists(output_path):
return False, ("CRASH", None)
with open(output_path) as f:
# Might need to strip variable headers or something here
data = f.read()
return True, base64.b64encode(data)
def do_test(self, test):
result = self.implementation.run_test(test)
return self.convert_result(test, result)
def on_output(self, line):
line = line.decode("utf8", "replace")
if self.interactive:
print line
else:
self.logger.process_output(self.proc.pid,
line,
#.........这里部分代码省略.........