• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python mozprocess.ProcessHandler类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中mozprocess.ProcessHandler的典型用法代码示例。如果您正苦于以下问题:Python ProcessHandler类的具体用法?Python ProcessHandler怎么用?Python ProcessHandler使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了ProcessHandler类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: setup_avds

    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()
开发者ID:subsevenx2001,项目名称:gecko-dev,代码行数:35,代码来源:android_emulator_unittest.py


示例2: build_script

    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()
开发者ID:nhirata,项目名称:b2g-commands,代码行数:30,代码来源:build_commands.py


示例3: test_relative_path

    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)
        code = process.waitForFinish(timeout=120)
        self.assertEqual(code, 0)

        # cleanup
        shutil.rmtree(tempdir)
开发者ID:vladmaniac,项目名称:mozmill,代码行数:26,代码来源:testprofilepath.py


示例4: flash

 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
开发者ID:nhirata,项目名称:b2g-commands,代码行数:7,代码来源:build_commands.py


示例5: test_relative_path

    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)
开发者ID:EricRahm,项目名称:mozmill,代码行数:30,代码来源:test_profile_relative_path.py


示例6: gdb

    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()
开发者ID:nhirata,项目名称:b2g-commands,代码行数:9,代码来源:run_commands.py


示例7: __init__

    def __init__(self, cmd,
                       args=None, cwd=None,
                       env=os.environ.copy(),
                       ignore_children=False,
                       **kwargs):

        ProcessHandler.__init__(self, cmd, args=args, cwd=cwd, env=env,
                                ignore_children=ignore_children, **kwargs)

        self.logger = mozlog.getLogger('PEP')
开发者ID:gayomard,项目名称:peptest,代码行数:10,代码来源:pepprocess.py


示例8: pushDir

 def pushDir(self, localDir, remoteDir, retryLimit=None, timeout=None):
     # adb "push" accepts a directory as an argument, but if the directory
     # contains symbolic links, the links are pushed, rather than the linked
     # files; we either zip/unzip or re-copy the directory into a temporary
     # one to get around this limitation
     retryLimit = retryLimit or self.retryLimit
     if self._useZip:
         self.removeDir(remoteDir)
         self.mkDirs(remoteDir + "/x")
         try:
             localZip = tempfile.mktemp() + ".zip"
             remoteZip = remoteDir + "/adbdmtmp.zip"
             proc = ProcessHandler(["zip", "-r", localZip, '.'], cwd=localDir,
                                   processOutputLine=self._log)
             proc.run()
             proc.wait()
             self.pushFile(localZip, remoteZip, retryLimit=retryLimit, createDir=False)
             mozfile.remove(localZip)
             data = self._runCmd(["shell", "unzip", "-o", remoteZip,
                                  "-d", remoteDir]).output[0]
             self._checkCmd(["shell", "rm", remoteZip],
                            retryLimit=retryLimit, timeout=self.short_timeout)
             if re.search("unzip: exiting", data) or re.search("Operation not permitted", data):
                 raise Exception("unzip failed, or permissions error")
         except Exception:
             self._logger.warning(traceback.format_exc())
             self._logger.warning("zip/unzip failure: falling back to normal push")
             self._useZip = False
             self.pushDir(localDir, remoteDir, retryLimit=retryLimit, timeout=timeout)
     else:
         localDir = os.path.normpath(localDir)
         remoteDir = os.path.normpath(remoteDir)
         tempParent = tempfile.mkdtemp()
         remoteName = os.path.basename(remoteDir)
         newLocal = os.path.join(tempParent, remoteName)
         dir_util.copy_tree(localDir, newLocal)
         # See do_sync_push in
         # https://android.googlesource.com/platform/system/core/+/master/adb/file_sync_client.cpp
         # Work around change in behavior in adb 1.0.36 where if
         # the remote destination directory exists, adb push will
         # copy the source directory *into* the destination
         # directory otherwise it will copy the source directory
         # *onto* the destination directory.
         if self._adb_version >= '1.0.36':
             remoteDir = '/'.join(remoteDir.rstrip('/').split('/')[:-1])
         try:
             if self._checkCmd(["push", newLocal, remoteDir],
                               retryLimit=retryLimit, timeout=timeout):
                 raise DMError("failed to push %s (copy of %s) to %s" %
                               (newLocal, localDir, remoteDir))
         except BaseException:
             raise
         finally:
             mozfile.remove(tempParent)
开发者ID:luke-chang,项目名称:gecko-1,代码行数:54,代码来源:devicemanagerADB.py


示例9: _isLocalZipAvailable

 def _isLocalZipAvailable(self):
     def _noOutput(line):
         # suppress output from zip ProcessHandler
         pass
     try:
         proc = ProcessHandler(["zip", "-?"], storeOutput=False, processOutputLine=_noOutput)
         proc.run()
         proc.wait()
     except:
         return False
     return True
开发者ID:kilikkuo,项目名称:gecko-dev,代码行数:11,代码来源:devicemanagerADB.py


示例10: start_logcat

 def start_logcat(self, serial, logfile=None, stream=None, filterspec=None):
     logcat_args = [self.app_ctx.adb, '-s', '%s' % serial,
                    'logcat', '-v', 'time', '-b', 'main', '-b', 'radio']
     # only log filterspec
     if filterspec:
         logcat_args.extend(['-s', filterspec])
     process_args = {}
     if logfile:
         process_args['logfile'] = logfile
     elif stream:
         process_args['stream'] = stream
     proc = ProcessHandler(logcat_args, **process_args)
     proc.run()
     return proc
开发者ID:luke-chang,项目名称:gecko-1,代码行数:14,代码来源:base.py


示例11: test_no_option

    def test_no_option(self):
        process = ProcessHandler(['mozmill',
                                  '-b', os.environ['BROWSER_PATH'],
                                  '-t', os.path.join(testdir,
                                                     'useMozmill',
                                                     'testServerRoot.js')
                                  ],
                                 # stop mozmill from printing output to console
                                 processOutputLine=[lambda line: None])
        process.run()
        process.wait()

        self.assertEqual(process.proc.poll(), 1,
                         'Test failed')
开发者ID:EricRahm,项目名称:mozmill,代码行数:14,代码来源:test_server-root.py


示例12: __init__

    def __init__(self, cmd,
                       args=None, cwd=None,
                       env=None,
                       ignore_children=False,
                       logfile=None,
                       **kwargs):

        self.firstTime = int(time.time()) * 1000
        self.logfile = logfile
        self.results_file = None
        if env is None:
            env = os.environ.copy()

        ProcessHandler.__init__(self, cmd, args=args, cwd=cwd, env=env,
                                ignore_children=ignore_children, logfile=self.logfile, **kwargs)
开发者ID:lundjordan,项目名称:build-talos,代码行数:15,代码来源:talosProcess.py


示例13: test_options

    def test_options(self):
        absdir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
        testdir = os.path.join(absdir, 'js-tests')

        process = ProcessHandler(['mozmill',
                                  '-b', os.environ['BROWSER_PATH'],
                                  '-t', os.path.join(testdir,
                                                     'test_module1.js'),
                                  '-m', os.path.join(testdir, 'example.ini')
                                 ])
        process.run()
        process.waitForFinish()

        self.assertNotEqual(process.proc.poll(), 0,
                            'Parser error due to -t and -m are mutually exclusive')
开发者ID:ahal,项目名称:mozmill,代码行数:15,代码来源:options_tests_and_manifest.py


示例14: screenshot

    def screenshot(self, test):
        full_url = self.test_url(test)

        with TempFilename(self.tempdir) as output_path:
            debug_args, command = browser_command(
                self.binary,
                [
                    "--cpu",
                    "--hard-fail",
                    "--exit",
                    "-u",
                    "Servo/wptrunner",
                    "-Z",
                    "disable-text-aa",
                    "--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]

            self.command = debug_args + command

            env = os.environ.copy()
            env["HOST_FILE"] = self.hosts_path

            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)
开发者ID:DINKIN,项目名称:Waterfox,代码行数:60,代码来源:executorservo.py


示例15: start

    def start(self):
        """
        Starts a new emulator.
        """
        if self.proc:
            return

        original_devices = set(self._get_online_devices())

        qemu_log = None
        qemu_proc_args = {}
        if self.logdir:
            # save output from qemu to logfile
            qemu_log = os.path.join(self.logdir, 'qemu.log')
            if os.path.isfile(qemu_log):
                self._rotate_log(qemu_log)
            qemu_proc_args['logfile'] = qemu_log
        else:
            qemu_proc_args['processOutputLine'] = lambda line: None
        self.proc = ProcessHandler(self.args, **qemu_proc_args)
        self.proc.run()

        devices = set(self._get_online_devices())
        now = datetime.datetime.now()
        while (devices - original_devices) == set([]):
            time.sleep(1)
            if datetime.datetime.now() - now > datetime.timedelta(seconds=60):
                raise TimeoutException('timed out waiting for emulator to start')
            devices = set(self._get_online_devices())
        devices = devices - original_devices
        self.serial = devices.pop()
        self.connect()
开发者ID:yati-sagade,项目名称:PerlitoMonkey,代码行数:32,代码来源:emulator.py


示例16: screenshot

    def screenshot(self, test):
        full_url = self.test_url(test)

        with TempFilename(self.tempdir) as output_path:
            self.command = [self.binary, "--cpu", "--hard-fail", "--exit",
                            "-Z", "disable-text-aa", "--output=%s" % output_path,
                            full_url]

            env = os.environ.copy()
            env["HOST_FILE"] = self.hosts_path

            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

            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)
开发者ID:lgarner,项目名称:mozilla-central,代码行数:34,代码来源:executorservo.py


示例17: _runCmd

    def _runCmd(self, args):
        """
        Runs a command using adb

        returns: instance of ProcessHandler
        """
        finalArgs = [self._adbPath]
        if self._deviceSerial:
            finalArgs.extend(['-s', self._deviceSerial])
        finalArgs.extend(args)
        self._logger.debug("_runCmd - command: %s" % ' '.join(finalArgs))
        proc = ProcessHandler(finalArgs, storeOutput=True,
                processOutputLine=self._log)
        proc.run()
        proc.returncode = proc.wait()
        return proc
开发者ID:qiuyang001,项目名称:Spidermonkey,代码行数:16,代码来源:devicemanagerADB.py


示例18: start

 def start(self):
     """
        Launch the emulator.
     """
     def outputHandler(line):
         self.emulator_log.write("<%s>\n" % line)
     env = os.environ
     env['ANDROID_AVD_HOME'] = os.path.join(EMULATOR_HOME_DIR, "avd")
     command = [self.emulator_path, "-avd",
                self.avd_info.name, "-port", "5554"]
     if self.avd_info.extra_args:
         # -enable-kvm option is not valid on OSX
         if _get_host_platform() == 'macosx64' and '-enable-kvm' in self.avd_info.extra_args:
             self.avd_info.extra_args.remove('-enable-kvm')
         command += self.avd_info.extra_args
     log_path = os.path.join(EMULATOR_HOME_DIR, 'emulator.log')
     self.emulator_log = open(log_path, 'w')
     _log_debug("Starting the emulator with this command: %s" %
                     ' '.join(command))
     _log_debug("Emulator output will be written to '%s'" %
                     log_path)
     self.proc = ProcessHandler(
         command, storeOutput=False, processOutputLine=outputHandler,
         env=env)
     self.proc.run()
     _log_debug("Emulator started with pid %d" %
                     int(self.proc.proc.pid))
开发者ID:psvramaraju,项目名称:gecko-dev,代码行数:27,代码来源:android_device.py


示例19: run_test

    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)
开发者ID:marshall,项目名称:gecko-dev,代码行数:32,代码来源:executorservo.py


示例20: test_option

    def test_option(self):
        process = ProcessHandler(['mozmill',
                                  '-b', os.environ['BROWSER_PATH'],
                                  '-t', os.path.join(testdir,
                                                     'useMozmill',
                                                     'testServerRoot.js'),
                                  '--server-root', os.path.join(testdir,
                                                                '../../data'),
                                  ],
                                 # stop mozmill from printing output to console
                                 processOutputLine=[lambda line: None])
        process.run()
        process.wait()

        self.assertEqual(process.proc.poll(), 0,
                         'Test was run successful')
开发者ID:EricRahm,项目名称:mozmill,代码行数:16,代码来源:test_server-root.py



注:本文中的mozprocess.ProcessHandler类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python mozprocess.ProcessHandlerMixin类代码示例发布时间:2022-05-27
下一篇:
Python sql.get_conn函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap