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


Python AdbWrapper.adb_devices方法代码示例

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


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

示例1: run

# 需要导入模块: from util.adb_helper import AdbWrapper [as 别名]
# 或者: from util.adb_helper.AdbWrapper import adb_devices [as 别名]
    def run(self):
        """
        Entry point.
        """
        # get the device's serial number
        devices = AdbWrapper.adb_devices()
        if len(devices) == 0:
            raise Exception('No device.')
        else:
            self.serial = AdbHelper.get_serial(self.serial)
            if self.serial is None:
                if len(devices) == 1:
                    logger.debug('No serial, and only one device')
                else:
                    logger.debug('No serial, but there are more than one device')
                    raise Exception('Please specify the device by --serial option.')
            else:
                logger.debug('Setup serial to [{0}]'.format(self.serial))

        if self.gaia or self.gecko:
            self.prepare_step()
            if self.serial:
                logger.info('Target device [{0}]'.format(self.serial))
            if self.gecko:
                self.shallow_flash_gecko()
            if self.gaia:
                self.shallow_flash_gaia()
            self.final_step()
开发者ID:zapion,项目名称:b2g-util-python,代码行数:30,代码来源:shallow_flash.py

示例2: run

# 需要导入模块: from util.adb_helper import AdbWrapper [as 别名]
# 或者: from util.adb_helper.AdbWrapper import adb_devices [as 别名]
    def run(self):
        """
        Entry point.
        """
        self.devices = AdbWrapper.adb_devices()
        is_no_color = self.no_color
        if 'NO_COLOR' in os.environ:
            try:
                is_no_color = bool(util.strtobool(os.environ['NO_COLOR'].lower()))
            except Exception as e:
                logger.debug(e)
                logger.error('Invalid NO_COLOR value [{0}].'.format(os.environ['NO_COLOR']))

        if len(self.devices) == 0:
            raise Exception('No device.')
        elif len(self.devices) >= 1:
            final_serial = AdbHelper.get_serial(self.serial)
            if final_serial is None:
                self.device_info_list = []
                for device, state in self.devices.items():
                    print('Serial: {0} (State: {1})'.format(device, state))
                    if state == 'device':
                        device_info = self.get_device_info(serial=device)
                        self.print_device_info(device_info, no_color=is_no_color)
                        self.device_info_list.append(device_info)
                    else:
                        print('Skipped.\n')
                        self.device_info_list.append({'Serial': device, 'Skip': True})
            else:
                print('Serial: {0} (State: {1})'.format(final_serial, self.devices[final_serial]))
                device_info = self.get_device_info(serial=final_serial)
                self.device_info_list = [device_info]
                self.print_device_info(device_info, no_color=is_no_color)
            self._output_log()
开发者ID:zapion,项目名称:b2g-util-python,代码行数:36,代码来源:check_versions.py

示例3: run

# 需要导入模块: from util.adb_helper import AdbWrapper [as 别名]
# 或者: from util.adb_helper.AdbWrapper import adb_devices [as 别名]
    def run(self):
        """
        Entry point.
        """
        self.prepare()
        devices = AdbWrapper.adb_devices()
        is_no_color = self.args.no_color
        if "NO_COLOR" in os.environ:
            try:
                is_no_color = bool(util.strtobool(os.environ["NO_COLOR"].lower()))
            except:
                logger.error("Invalid NO_COLOR value [{0}].".format(os.environ["NO_COLOR"]))

        if len(devices) == 0:
            raise Exception("No device.")
        elif len(devices) >= 1:
            final_serial = AdbHelper.get_serial(self.args.serial)
            if final_serial is None:
                device_info_list = []
                for device, state in devices.items():
                    print ("Serial: {0} (State: {1})".format(device, state))
                    if state == "device":
                        device_info = self.get_device_info(serial=device)
                        self.print_device_info(device_info, no_color=is_no_color)
                        device_info_list.append(device_info)
                    else:
                        print ("Skipped.\n")
                        device_info_list.append({"Serial": device, "Skip": True})
                self.output_log(device_info_list)
            else:
                print ("Serial: {0} (State: {1})".format(final_serial, devices[final_serial]))
                device_info = self.get_device_info(serial=final_serial)
                self.print_device_info(device_info, no_color=is_no_color)
                self.output_log([device_info])
开发者ID:ShakoHo,项目名称:b2g-util-python,代码行数:36,代码来源:check_versions.py

示例4: run

# 需要导入模块: from util.adb_helper import AdbWrapper [as 别名]
# 或者: from util.adb_helper.AdbWrapper import adb_devices [as 别名]
    def run(self):
        """
        Entry point.
        """
        self.devices = AdbWrapper.adb_devices()
        logger.debug("Devices: {}".format(self.devices))
        if len(self.devices) < 1:
            raise Exception("Can not find device, please connect your device.")
        elif len(self.devices) > 1:
            raise Exception("Find more than one device, please only connect one device.")

        # get device name
        device_name = AdbWrapper.adb_shell("getprop ro.product.device")[0]
        logger.info("Device found: {}".format(device_name))
        if device_name not in self.SUPPORT_DEVICES.keys():
            raise Exception("The {} device is not supported.".format(device_name))

        # select branch
        branch = self.select_branch()
        # select build type
        postfix = self.select_build()

        # get namespace and image artifact
        device_info = self.SUPPORT_DEVICES.get(device_name)
        namespace = self.NAMESPACE_FORMAT(branch=branch, device=device_info.get("name"), postfix=postfix)
        artifact = self.ARTIFACT_FORMAT(build_path=self.BUILD_PATH, image=device_info.get("image"))
        logger.info("Device: {}".format(device_name))
        logger.info("Namespace: {}".format(namespace))
        logger.info("Artifact: {}".format(artifact))

        ret = raw_input(
            '\nDownload "{artifact}" from "{namespace}".\nRight? [Y/n]'.format(artifact=artifact, namespace=namespace)
        )
        if len(ret) > 0 and ret.lower()[0] == "n":
            logger.info("Stop.")
            exit(0)
        # downloading image
        logger.info("Downloading image...")
        local_image = self.download(namespace, artifact)
        logger.debug("Image file: {}".format(local_image))
        # checking file
        logger.info("Checking file...")
        if not B2GHelper.check_b2g_image(local_image):
            raise Exception("This is not B2G image file: {}".format(local_image))
        # flashing image
        logger.info("Flashing image...")
        self.flash_image(local_image)
开发者ID:askeing,项目名称:b2g-util-python,代码行数:49,代码来源:quick_flash.py

示例5: run

# 需要导入模块: from util.adb_helper import AdbWrapper [as 别名]
# 或者: from util.adb_helper.AdbWrapper import adb_devices [as 别名]
    def run(self):
        devices = AdbWrapper.adb_devices()

        if len(devices) == 0:
            raise Exception('No device.')
        elif len(devices) >= 1:
            final_serial = AdbHelper.get_serial(self.args.serial)
            if final_serial is None:
                if len(devices) == 1:
                    logger.debug('No serial, and only one device')
                    self.get_crashreports(serial=final_serial)
                else:
                    logger.debug('No serial, but there are more than one device')
                    raise Exception('Please specify the device by --serial option.')
            else:
                print('Serial: {0} (State: {1})'.format(final_serial, devices[final_serial]))
                self.get_crashreports(serial=final_serial)
开发者ID:Conjuror,项目名称:b2g-util-python,代码行数:19,代码来源:get_crashreports.py

示例6: run

# 需要导入模块: from util.adb_helper import AdbWrapper [as 别名]
# 或者: from util.adb_helper.AdbWrapper import adb_devices [as 别名]
    def run(self):
        """
        Entry point.
        """
        devices = AdbWrapper.adb_devices()

        is_enable = not self.disable
        if len(devices) == 0:
            raise Exception('No device.')
        elif len(devices) >= 1:
            final_serial = AdbHelper.get_serial(self.serial)
            if final_serial is None:
                if len(devices) == 1:
                    logger.debug('No serial, and only one device')
                    self.setup_certapps(enable=is_enable, serial=final_serial)
                else:
                    logger.debug('No serial, but there are more than one device')
                    raise Exception('Please specify the device by --serial option.')
            else:
                print('Serial: {0} (State: {1})'.format(final_serial, devices[final_serial]))
                self.setup_certapps(enable=is_enable, serial=final_serial)
开发者ID:zapion,项目名称:b2g-util-python,代码行数:23,代码来源:enable_certapps_devtools.py

示例7: run

# 需要导入模块: from util.adb_helper import AdbWrapper [as 别名]
# 或者: from util.adb_helper.AdbWrapper import adb_devices [as 别名]
    def run(self):
        # get the device's serial number
        devices = AdbWrapper.adb_devices()
        if len(devices) == 0:
            raise Exception('No device.')
        else:
            device_serial = AdbHelper.get_serial(self.args.serial)
            if device_serial is None:
                if len(devices) == 1:
                    logger.debug('No serial, and only one device')
                else:
                    logger.debug('No serial, but there are more than one device')
                    raise Exception('Please specify the device by --serial option.')
            else:
                logger.debug('Setup serial to [{0}]'.format(device_serial))

        # checking the adb root for backup/restore
        if not AdbWrapper.adb_root(serial=device_serial):
            raise Exception('No root permission for backup and resotre.')

        # Backup
        if self.args.backup:
            try:
                logger.info('Target device [{0}]'.format(device_serial))
                # Create temp folder
                tmp_dir = tempfile.mkdtemp(prefix='backup_restore_')
                logger.debug('TEMP Foler: {}'.format(tmp_dir))
                # Stop B2G
                B2GHelper.stop_b2g(serial=device_serial)
                # Backup User Profile
                self.backup_profile(local_dir=tmp_dir, serial=device_serial)
                # Backup SDCard
                if self.args.sdcard:
                    self.backup_sdcard(local_dir=tmp_dir, serial=device_serial)
                # Copy backup files from temp folder to target folder
                if os.path.isdir(self.args.profile_dir):
                    logger.warning('Removing [{0}] folder...'.format(self.args.profile_dir))
                    shutil.rmtree(self.args.profile_dir)
                logger.info('Copy profile from [{0}] to [{1}].'.format(tmp_dir, self.args.profile_dir))
                shutil.copytree(tmp_dir, self.args.profile_dir)
                # Start B2G
                if not self.args.no_reboot:
                    B2GHelper.start_b2g(serial=device_serial)
            finally:
                logger.debug('Removing [{0}] folder...'.format(tmp_dir))
                shutil.rmtree(tmp_dir)
        # Restore
        elif self.args.restore:
            logger.info('Target device [{0}]'.format(device_serial))
            # Checking the Version of Profile
            if self.check_profile_version(local_dir=self.args.profile_dir, serial=device_serial):
                # Stop B2G
                B2GHelper.stop_b2g(serial=device_serial)
                # Restore User Profile
                self.restore_profile(local_dir=self.args.profile_dir, serial=device_serial)
                # Restore SDCard
                if self.args.sdcard:
                    self.restore_sdcard(local_dir=self.args.profile_dir, serial=device_serial)
                # Start B2G
                if not self.args.no_reboot:
                    B2GHelper.start_b2g(serial=device_serial)
            else:
                logger.warning('The version on device is smaller than backup\'s version.')
开发者ID:Conjuror,项目名称:b2g-util-python,代码行数:65,代码来源:backup_restore_profile.py


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