当前位置: 首页>>代码示例>>Python>>正文


Python EmulatorGeo.set_default_location方法代码示例

本文整理汇总了Python中emulator_geo.EmulatorGeo.set_default_location方法的典型用法代码示例。如果您正苦于以下问题:Python EmulatorGeo.set_default_location方法的具体用法?Python EmulatorGeo.set_default_location怎么用?Python EmulatorGeo.set_default_location使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在emulator_geo.EmulatorGeo的用法示例。


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

示例1: Emulator

# 需要导入模块: from emulator_geo import EmulatorGeo [as 别名]
# 或者: from emulator_geo.EmulatorGeo import set_default_location [as 别名]

#.........这里部分代码省略.........

        qemu_args = self.args[:]
        if self.copy_userdata:
            # Make a copy of the userdata.img for this instance of the emulator to use.
            self._tmp_userdata = tempfile.mktemp(prefix="marionette")
            shutil.copyfile(self.dataImg, self._tmp_userdata)
            qemu_args[qemu_args.index("-data") + 1] = self._tmp_userdata

        original_online, original_offline = self._get_adb_devices()

        filename = None
        if self.logcat_dir:
            filename = os.path.join(self.logcat_dir, "qemu.log")
            if os.path.isfile(filename):
                self.rotate_log(filename)

        self.proc = LogOutputProc(qemu_args, filename)
        self.proc.run()

        online, offline = self._get_adb_devices()
        now = datetime.datetime.now()
        while online - original_online == set([]):
            time.sleep(1)
            if datetime.datetime.now() - now > datetime.timedelta(seconds=60):
                raise Exception("timed out waiting for emulator to start")
            online, offline = self._get_adb_devices()
        self.port = int(list(online - original_online)[0])
        self._emulator_launched = True

        self.dm = devicemanagerADB.DeviceManagerADB(adbPath=self.adb, deviceSerial="emulator-%d" % self.port)

        # bug 802877
        time.sleep(10)
        self.geo.set_default_location()
        self.screen.initialize()

        if self.logcat_dir:
            self.save_logcat()

        # setup DNS fix for networking
        self._run_adb(["shell", "setprop", "net.dns1", "10.0.2.3"])

    def wait_for_homescreen(self, marionette):
        print "waiting for homescreen..."

        created_session = False
        if not marionette.session:
            marionette.start_session()
            created_session = True

        marionette.set_context(marionette.CONTEXT_CONTENT)
        marionette.execute_async_script(
            """
log('waiting for mozbrowserloadend');
window.addEventListener('mozbrowserloadend', function loaded(aEvent) {
  log('received mozbrowserloadend for ' + aEvent.target.src);
  if (aEvent.target.src.indexOf('ftu') != -1 || aEvent.target.src.indexOf('homescreen') != -1) {
    window.removeEventListener('mozbrowserloadend', loaded);
    marionetteScriptFinished();
  }
});""",
            script_timeout=120000,
        )
        print "...done"
        if created_session:
            marionette.delete_session()
开发者ID:samjain1994,项目名称:gecko-dev,代码行数:70,代码来源:emulator.py

示例2: Emulator

# 需要导入模块: from emulator_geo import EmulatorGeo [as 别名]
# 或者: from emulator_geo.EmulatorGeo import set_default_location [as 别名]

#.........这里部分代码省略.........

        self.install_gecko()

    def start(self):
        self._check_for_b2g()
        self.start_adb()

        qemu_args = self.args[:]
        if self.copy_userdata:
            # Make a copy of the userdata.img for this instance of the emulator
            # to use.
            self._tmp_userdata = tempfile.mktemp(prefix='marionette')
            shutil.copyfile(self.dataImg, self._tmp_userdata)
            qemu_args[qemu_args.index('-data') + 1] = self._tmp_userdata

        original_online, original_offline = self._get_adb_devices()

        self.proc = subprocess.Popen(qemu_args,
                                     stdout=subprocess.PIPE,
                                     stderr=subprocess.PIPE)

        online, offline = self._get_adb_devices()
        now = datetime.datetime.now()
        while online - original_online == set([]):
            time.sleep(1)
            if datetime.datetime.now() - now > datetime.timedelta(seconds=60):
                raise Exception('timed out waiting for emulator to start')
            online, offline = self._get_adb_devices()
        self.port = int(list(online - original_online)[0])
        self._emulator_launched = True

        # bug 802877
        time.sleep(10)
        self.geo.set_default_location()

        if self.logcat_dir:
            self.save_logcat()

        # setup DNS fix for networking
        self._run_adb(['shell', 'setprop', 'net.dns1', '10.0.2.3'])

        self.install_gecko()

    def _save_logcat_proc(self, filename, cmd):
        self.logcat_proc = LogcatProc(filename, cmd)
        self.logcat_proc.run()
        self.logcat_proc.processOutput()
        self.logcat_proc.waitForFinish()
        self.logcat_proc = None

    def install_gecko(self):
        """
        Install gecko into the emulator using adb push.  Restart b2g after the
        installation.
        """
        if not self.gecko_path:
            return
        # need to remount so we can write to /system/b2g
        self._run_adb(['remount'])
        self._run_adb(['shell', 'stop', 'b2g'])
        self._run_adb(['shell', 'rm', '-rf', '/system/b2g/*.so'])
        print 'installing gecko binaries'
        self._run_adb(['push', self.gecko_path, '/system/b2g'])
        print 'restarting B2G'
        self._run_adb(['shell', 'start', 'b2g'])
开发者ID:davehunt,项目名称:marionette_client,代码行数:69,代码来源:emulator.py


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