本文整理汇总了Python中emulator_geo.EmulatorGeo类的典型用法代码示例。如果您正苦于以下问题:Python EmulatorGeo类的具体用法?Python EmulatorGeo怎么用?Python EmulatorGeo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了EmulatorGeo类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Emulator
class Emulator(object):
deviceRe = re.compile(r"^emulator-(\d+)(\s*)(.*)$")
_default_res = "320x480"
prefs = {"app.update.enabled": False, "app.update.staging.enabled": False, "app.update.service.enabled": False}
def __init__(
self,
homedir=None,
noWindow=False,
logcat_dir=None,
arch="x86",
emulatorBinary=None,
res=None,
sdcard=None,
symbols_path=None,
userdata=None,
):
self.port = None
self.dm = None
self._emulator_launched = False
self.proc = None
self.marionette_port = None
self.telnet = None
self._tmp_sdcard = None
self._tmp_userdata = None
self._adb_started = False
self.remote_user_js = "/data/local/user.js"
self.logcat_dir = logcat_dir
self.logcat_proc = None
self.arch = arch
self.binary = emulatorBinary
self.res = res or self._default_res
self.battery = EmulatorBattery(self)
self.geo = EmulatorGeo(self)
self.screen = EmulatorScreen(self)
self.homedir = homedir
self.sdcard = sdcard
self.symbols_path = symbols_path
self.noWindow = noWindow
if self.homedir is not None:
self.homedir = os.path.expanduser(homedir)
self.dataImg = userdata
self.copy_userdata = self.dataImg is None
def _check_for_b2g(self):
self.b2g = B2GInstance(homedir=self.homedir, emulator=True, symbols_path=self.symbols_path)
self.adb = self.b2g.adb_path
self.homedir = self.b2g.homedir
if self.arch not in ("x86", "arm"):
raise Exception("Emulator architecture must be one of x86, arm, got: %s" % self.arch)
host_dir = "linux-x86"
if platform.system() == "Darwin":
host_dir = "darwin-x86"
host_bin_dir = os.path.join("out", "host", host_dir, "bin")
if self.arch == "x86":
binary = os.path.join(host_bin_dir, "emulator-x86")
kernel = "prebuilts/qemu-kernel/x86/kernel-qemu"
sysdir = "out/target/product/generic_x86"
self.tail_args = []
else:
binary = os.path.join(host_bin_dir, "emulator")
kernel = "prebuilts/qemu-kernel/arm/kernel-qemu-armv7"
sysdir = "out/target/product/generic"
self.tail_args = ["-cpu", "cortex-a8"]
if self.sdcard:
self.mksdcard = os.path.join(self.homedir, host_bin_dir, "mksdcard")
self.create_sdcard(self.sdcard)
if not self.binary:
self.binary = os.path.join(self.homedir, binary)
self.b2g.check_file(self.binary)
self.kernelImg = os.path.join(self.homedir, kernel)
self.b2g.check_file(self.kernelImg)
self.sysDir = os.path.join(self.homedir, sysdir)
self.b2g.check_file(self.sysDir)
if not self.dataImg:
self.dataImg = os.path.join(self.sysDir, "userdata.img")
self.b2g.check_file(self.dataImg)
def __del__(self):
if self.telnet:
self.telnet.write("exit\n")
self.telnet.read_all()
@property
def args(self):
qemuArgs = [self.binary, "-kernel", self.kernelImg, "-sysdir", self.sysDir, "-data", self.dataImg]
if self._tmp_sdcard:
qemuArgs.extend(["-sdcard", self._tmp_sdcard])
if self.noWindow:
#.........这里部分代码省略.........
示例2: Emulator
class Emulator(object):
deviceRe = re.compile(r"^emulator-(\d+)(\s*)(.*)$")
def __init__(self, homedir=None, noWindow=False, logcat_dir=None,
arch="x86", emulatorBinary=None, res='480x800', sdcard=None,
userdata=None, gecko_path=None):
self.port = None
self._emulator_launched = False
self.proc = None
self.marionette_port = None
self.telnet = None
self._tmp_sdcard = None
self._tmp_userdata = None
self._adb_started = False
self.logcat_dir = logcat_dir
self.logcat_proc = None
self.arch = arch
self.binary = emulatorBinary
self.res = res
self.battery = EmulatorBattery(self)
self.geo = EmulatorGeo(self)
self.homedir = homedir
self.sdcard = sdcard
self.noWindow = noWindow
if self.homedir is not None:
self.homedir = os.path.expanduser(homedir)
self.dataImg = userdata
self.copy_userdata = self.dataImg is None
self.gecko_path = gecko_path
def _check_for_b2g(self):
if self.homedir is None:
self.homedir = os.getenv('B2G_HOME')
if self.homedir is None:
raise Exception('Must define B2G_HOME or pass the homedir parameter')
self._check_file(self.homedir)
oldstyle_homedir = os.path.join(self.homedir, 'glue', 'gonk-ics')
if os.access(oldstyle_homedir, os.F_OK):
self.homedir = oldstyle_homedir
if self.arch not in ("x86", "arm"):
raise Exception("Emulator architecture must be one of x86, arm, got: %s" %
self.arch)
host_dir = "linux-x86"
if platform.system() == "Darwin":
host_dir = "darwin-x86"
host_bin_dir = os.path.join("out", "host", host_dir, "bin")
if self.arch == "x86":
binary = os.path.join(host_bin_dir, "emulator-x86")
kernel = "prebuilts/qemu-kernel/x86/kernel-qemu"
sysdir = "out/target/product/generic_x86"
self.tail_args = []
else:
binary = os.path.join(host_bin_dir, "emulator")
kernel = "prebuilts/qemu-kernel/arm/kernel-qemu-armv7"
sysdir = "out/target/product/generic"
self.tail_args = ["-cpu", "cortex-a8"]
self._check_for_adb()
if(self.sdcard):
self.mksdcard = os.path.join(self.homedir, host_bin_dir, "mksdcard")
self.create_sdcard(self.sdcard)
if not self.binary:
self.binary = os.path.join(self.homedir, binary)
self._check_file(self.binary)
self.kernelImg = os.path.join(self.homedir, kernel)
self._check_file(self.kernelImg)
self.sysDir = os.path.join(self.homedir, sysdir)
self._check_file(self.sysDir)
if not self.dataImg:
self.dataImg = os.path.join(self.sysDir, 'userdata.img')
self._check_file(self.dataImg)
def __del__(self):
if self.telnet:
self.telnet.write('exit\n')
self.telnet.read_all()
def _check_file(self, filePath):
if not os.access(filePath, os.F_OK):
raise Exception(('File not found: %s; did you pass the B2G home '
'directory as the homedir parameter, or set '
'B2G_HOME correctly?') % filePath)
@property
def args(self):
qemuArgs = [self.binary,
'-kernel', self.kernelImg,
'-sysdir', self.sysDir,
'-data', self.dataImg]
#.........这里部分代码省略.........