本文整理汇总了Python中marionette.Marionette.cleanup方法的典型用法代码示例。如果您正苦于以下问题:Python Marionette.cleanup方法的具体用法?Python Marionette.cleanup怎么用?Python Marionette.cleanup使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类marionette.Marionette
的用法示例。
在下文中一共展示了Marionette.cleanup方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: MtbfJobRunner
# 需要导入模块: from marionette import Marionette [as 别名]
# 或者: from marionette.Marionette import cleanup [as 别名]
class MtbfJobRunner(BaseActionRunner):
serial = None
marionette = None
flash_params = {
'branch': 'mozilla-b2g34_v2_1-flame-kk-eng',
'build': '',
'build_id': ''
}
flashed = False
def __init__(self, **kwargs):
self.logger = logger
BaseActionRunner.__init__(self)
def setup(self):
if not self.serial or not self.port:
logger.error("Fail to get device")
raise DMError
self.marionette and self.marionette.session and self.marionette.cleanup()
self.dm = mozdevice.DeviceManagerADB(deviceSerial=self.serial, port=self.port)
self.marionette = Marionette(device_serial=self.serial, port=self.port)
self.marionette.start_session()
self.device = GaiaDevice(marionette=self.marionette, manager=self.dm)
self.apps = GaiaApps(self.marionette)
self.data_layer = GaiaData(self.marionette)
self.device.wait_for_b2g_ready()
def adb_test(self):
if not hasattr(self, 'serial') or os.system("ANDROID_SERIAL=" + self.serial + " adb shell ls") != 0:
logger.error("Device not found or can't be controlled")
return False
return True
@action(enabled=False)
def add_7mobile_action(self):
# workaround for waiting for boot
self.marionette.start_session()
self.data_layer = GaiaData(self.marionette)
self.data_layer.set_setting('ril.data.apnSettings',
[[
{"carrier": "(7-Mobile) (MMS)",
"apn": "opentalk",
"mmsc": "http://mms",
"mmsproxy": "210.241.199.199",
"mmsport": "9201",
"types": ["mms"]},
{"carrier": "(7-Mobile) (Internet)",
"apn": "opentalk",
"types": ["default", "supl"]}
]])
return True
@action(enabled=False)
def change_memory(self):
# This function only work in flame
# TODO: use native adb/fastboot command to change memory?
# Make sure it's in fastboot mode, TODO: leverage all fastboot command in one task function
memory = 512 # default set 512
if 'MEM' in os.environ:
memory = os.environ['MEM']
elif self.settings['change_memory']['enabled'] and 'memory' in self.settings['change_memory']:
memory = self.settings['change_memory']['memory']
if self.adb_test():
os.system("adb reboot bootloader")
memory = 512
mem_str = str(memory)
os.system("fastboot oem mem " + mem_str)
# Preventing from async timing of fastboot
os.system("fastboot reboot")
self.device_obj.create_adb_forward(self.port)
return True
logger.error("Can't find device")
self.marionette.wait_for_port()
self.device_obj.create_adb_forward(self.port)
return False
@action(enabled=True)
def collect_memory_report(self):
zip_utils.collect_about_memory("mtbf_driver") # TODO: give a correct path for about memory folder
def get_free_device(self):
do = device_pool.get_device(self.serial)
if do:
# Record device serial and store dp instance
self.serial = do.serial
self.device_obj = do
if do.create_adb_forward():
self.port = do.adb_forwarded_port
logger.info("Device found, ANDROID_SERIAL= " + self.serial)
return do
logger.error("Port forwarding failed")
raise DMError
logger.warning("No available device. Please retry after device released")
# TODO: more handling for no available device
def validate_flash_params(self):
## Using system environment variable as temporary solution TODO: use other way for input params
## Check if package(files)/folder exists and return, else raise exception
if not 'FLASH_BASEDIR' in os.environ:
raise AttributeError("No FLASH_BASEDIR set")
#.........这里部分代码省略.........