本文整理汇总了Python中mozprocess.ProcessHandler.run方法的典型用法代码示例。如果您正苦于以下问题:Python ProcessHandler.run方法的具体用法?Python ProcessHandler.run怎么用?Python ProcessHandler.run使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mozprocess.ProcessHandler
的用法示例。
在下文中一共展示了ProcessHandler.run方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: perform_build
# 需要导入模块: from mozprocess import ProcessHandler [as 别名]
# 或者: from mozprocess.ProcessHandler import run [as 别名]
def perform_build(self, history_line):
import pdb
pdb.set_trace()
self.build_number += 1
self.start_time = datetime.now()
log.debug("Performing build %d on history line: %s" % (self.build_number, history_line))
build_proc = ProcessHandler(cmd = ['/home/ctalbert/projects/b2g-hamachi/build.sh'],
cwd = self.build_info['workdir'],
env=self.build_info['env'],
processOutputLine=[self.notify_status],
kill_on_timeout=True,
onTimeout=[self.notify_timeout],
onFinish=[self.notify_finished],
shell=True)
try:
sys.stdout.write("Starting Build %d:" % self.build_number)
build_proc.run(timeout=7200)
build_proc.processOutput()
exitcode = build_proc.wait()
except (KeyboardInterrupt, SystemExit):
print "User Canceled Operation!"
log.debug("Build canceled by user")
raise
finally:
self.build_log.close()
if exitcode == 0:
print "Build %d Completed Successfully" % self.build_number
log.debug("Build %d for history line: %s completed successfully" % (self.build_number, history_line))
else:
print "Build %d Failed" % self.build_number
log.debug("Build %d for history line: %s FAILED" % (self.build_number, history_line))
示例2: build_script
# 需要导入模块: from mozprocess import ProcessHandler [as 别名]
# 或者: from mozprocess.ProcessHandler import run [as 别名]
def build_script(self, modules=None, debug=False, profiling=False,
noftu=False, noopt=False, valgrind=False):
command = [os.path.join(self.b2g_home, 'build.sh')]
if modules:
command.extend(modules)
if debug:
command.insert(0, 'B2G_DEBUG=1')
if profiling:
command.insert(0, 'MOZ_PROFILING=1')
if noftu:
command.insert(0, 'NOFTU=1')
if noopt:
if profiling:
print("Can't perform profiling if optimizer is disabled")
return 1
command.insert(0, 'B2G_NOOPT=1')
if valgrind:
command.insert(0, 'B2G_VALGRIND=1')
p = ProcessHandler(command)
p.run()
#TODO: Error checking.
return p.wait()
示例3: test_relative_path
# 需要导入模块: from mozprocess import ProcessHandler [as 别名]
# 或者: from mozprocess.ProcessHandler import run [as 别名]
def test_relative_path(self):
tempdir = tempfile.mkdtemp()
# make a dummy profile
profile = FirefoxProfile(os.path.join(tempdir, 'testprofilepath'),
restore=False)
self.assertTrue(os.path.exists(os.path.join(tempdir,
'testprofilepath',
'user.js')))
# make a dummy test
test = """var test = function () { };"""
f = file(os.path.join(tempdir, 'test_dummy.js'), 'w')
f.write(test)
f.close()
# run mozmill on it
process = ProcessHandler(['mozmill',
'-t', 'test_dummy.js',
'--profile=testprofilepath'],
cwd=tempdir)
process.run()
process.waitForFinish()
self.assertNotEqual(process.proc.poll(), None)
# cleanup
shutil.rmtree(tempdir)
示例4: test_relative_path
# 需要导入模块: from mozprocess import ProcessHandler [as 别名]
# 或者: from mozprocess.ProcessHandler import run [as 别名]
def test_relative_path(self):
tempdir = tempfile.mkdtemp()
# make a dummy profile
profile = FirefoxProfile(os.path.join(tempdir, 'testprofilepath'),
restore=False)
self.assertTrue(os.path.exists(os.path.join(tempdir,
'testprofilepath',
'user.js')))
# make a dummy test
test = """function test() { };"""
f = file(os.path.join(tempdir, 'test_dummy.js'), 'w')
f.write(test)
f.close()
# run mozmill on it
process = ProcessHandler(['mozmill',
'-t', 'test_dummy.js',
'--profile=testprofilepath'],
cwd=tempdir,
# stop mozmill from printing output to console
processOutputLine=[lambda line: None])
process.run()
process.wait()
self.assertNotEqual(process.proc.poll(), None)
# cleanup
shutil.rmtree(tempdir)
示例5: _runCmd
# 需要导入模块: from mozprocess import ProcessHandler [as 别名]
# 或者: from mozprocess.ProcessHandler import run [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
示例6: lint
# 需要导入模块: from mozprocess import ProcessHandler [as 别名]
# 或者: from mozprocess.ProcessHandler import run [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
示例7: flash
# 需要导入模块: from mozprocess import ProcessHandler [as 别名]
# 或者: from mozprocess.ProcessHandler import run [as 别名]
def flash(self):
command = os.path.join(self.b2g_home, 'flash.sh')
p = ProcessHandler(command)
if _is_device_attached():
p.run()
return p.wait()
return 1
示例8: setup_avds
# 需要导入模块: from mozprocess import ProcessHandler [as 别名]
# 或者: from mozprocess.ProcessHandler import run [as 别名]
def setup_avds(self):
'''
If tooltool cache mechanism is enabled, the cached version is used by
the fetch command. If the manifest includes an "unpack" field, tooltool
will unpack all compressed archives mentioned in the manifest.
'''
c = self.config
dirs = self.query_abs_dirs()
# FIXME
# Clobbering and re-unpacking would not be needed if we had a way to
# check whether the unpacked content already present match the
# contents of the tar ball
self.rmtree(dirs['abs_avds_dir'])
self.mkdir_p(dirs['abs_avds_dir'])
if 'avd_url' in c:
# Intended for experimental setups to evaluate an avd prior to
# tooltool deployment.
url = c['avd_url']
self.download_unpack(url, dirs['abs_avds_dir'])
else:
url = self._get_repo_url(c["tooltool_manifest_path"])
self._tooltool_fetch(url, dirs['abs_avds_dir'])
avd_home_dir = self.abs_dirs['abs_avds_dir']
if avd_home_dir != "/home/cltbld/.android":
# Modify the downloaded avds to point to the right directory.
cmd = [
'bash', '-c',
'sed -i "s|/home/cltbld/.android|%s|" %s/test-*.ini' %
(avd_home_dir, os.path.join(avd_home_dir, 'avd'))
]
proc = ProcessHandler(cmd)
proc.run()
proc.wait()
示例9: _runCmd
# 需要导入模块: from mozprocess import ProcessHandler [as 别名]
# 或者: from mozprocess.ProcessHandler import run [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
示例10: _checkCmd
# 需要导入模块: from mozprocess import ProcessHandler [as 别名]
# 或者: from mozprocess.ProcessHandler import run [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)
示例11: _run_profile
# 需要导入模块: from mozprocess import ProcessHandler [as 别名]
# 或者: from mozprocess.ProcessHandler import run [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")
示例12: _run_profile
# 需要导入模块: from mozprocess import ProcessHandler [as 别名]
# 或者: from mozprocess.ProcessHandler import run [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")
示例13: ServoTestharnessExecutor
# 需要导入模块: from mozprocess import ProcessHandler [as 别名]
# 或者: from mozprocess.ProcessHandler import run [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()
示例14: run_process
# 需要导入模块: from mozprocess import ProcessHandler [as 别名]
# 或者: from mozprocess.ProcessHandler import run [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()
示例15: gdb
# 需要导入模块: from mozprocess import ProcessHandler [as 别名]
# 或者: from mozprocess.ProcessHandler import run [as 别名]
def gdb(self):
command = os.path.join(self.b2g_home, 'run-gdb.sh')
p = ProcessHandler(command)
p.run()
#TODO The emulator requires adb to run, we should check if that is
#running, catch that error or better yet, start adb.
return p.wait()