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

Python adb_helper.AdbWrapper类代码示例

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

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



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

示例1: backup_sdcard

    def backup_sdcard(self, local_dir, serial=None):
        """
        Backup data from device's SDCard to local folder.

        @param local_dir: the target local folder, will store data from device's SDCard to this folder.
        """
        logger.info('Backing up SD card...')
        # try to get the /sdcard folder on device
        output, retcode = AdbWrapper.adb_shell('ls -d {0}; echo $?'.format(self._REMOTE_DIR_SDCARD), serial=serial)
        output_list = [item for item in re.split(r'\n+', re.sub(r'\r+', '', output)) if item]
        ret_code = output_list[-1]
        output_list.remove(output_list[-1])
        ret_msg = '\n'.join(output_list)
        if ret_code == '0':
            target_dir = os.path.join(local_dir, self._LOCAL_DIR_SDCARD)
            os.makedirs(target_dir)
            logger.info('Backup: {0} to {1}'.format(self._REMOTE_DIR_SDCARD, target_dir))
            try:
                AdbWrapper.adb_pull(self._REMOTE_DIR_SDCARD, target_dir, serial=serial)
            except Exception as e:
                logger.debug(e)
                logger.error('Can not pull files from {0} to {1}.'.format(self._REMOTE_DIR_SDCARD, target_dir))
            logger.info('Backup SD card done.')
        else:
            logger.info(ret_msg)
开发者ID:zapion,项目名称:b2g-util-python,代码行数:25,代码来源:backup_restore_profile.py


示例2: cli

    def cli(self):
        """
        Handle the argument parse, and the return the instance itself.
        """
        # argument parser
        arg_parser = argparse.ArgumentParser(description='Check the version information of Firefox OS.',
                                             formatter_class=ArgumentDefaultsHelpFormatter)
        arg_parser.add_argument('--no-color', action='store_true', dest='no_color', default=False,
                                help='Do not print with color. NO_COLOR will overrides this option.')
        arg_parser.add_argument('-s', '--serial', action='store', dest='serial', default=None,
                                help='Directs command to the device or emulator with the given serial number. '
                                     'Overrides ANDROID_SERIAL environment variable.')
        arg_parser.add_argument('--log-text', action='store', dest='log_text', default=None, help='Text ouput.')
        arg_parser.add_argument('--log-json', action='store', dest='log_json', default=None, help='JSON output.')
        arg_parser.add_argument('-v', '--verbose', action='store_true', dest='verbose', default=False,
                                help='Turn on verbose output, with all the debug logger.')

        # parse args and setup the logging
        args = arg_parser.parse_args()
        # setup the logging config
        if args.verbose is True:
            verbose_formatter = '%(asctime)s - %(name)s - %(levelname)s - %(message)s'
            logging.basicConfig(level=logging.DEBUG, format=verbose_formatter)
        else:
            formatter = '%(levelname)s: %(message)s'
            logging.basicConfig(level=logging.INFO, format=formatter)
        # check ADB
        AdbWrapper.check_adb()
        # assign variable
        self.set_no_color(args.no_color)
        self.set_serial(args.serial)
        self.set_log_text(args.log_text)
        self.set_log_json(args.log_json)
        # return instance
        return self
开发者ID:zapion,项目名称:b2g-util-python,代码行数:35,代码来源:check_versions.py


示例3: cli

    def cli(self):
        """
        Handle the argument parse, and the return the instance itself.
        """
        # argument parser
        arg_parser = argparse.ArgumentParser(description='Reset Firefox OS Phone.',
                                             formatter_class=ArgumentDefaultsHelpFormatter)
        arg_parser.add_argument('-s', '--serial', action='store', dest='serial', default=None,
                                help='Directs command to the device or emulator with the given serial number.'
                                     'Overrides ANDROID_SERIAL environment variable.')
        arg_parser.add_argument('-v', '--verbose', action='store_true', dest='verbose', default=False,
                                help='Turn on verbose output, with all the debug logger.')

        # parse args and setup the logging
        args = arg_parser.parse_args()
        # setup the logging config
        if args.verbose is True:
            verbose_formatter = '%(asctime)s - %(name)s - %(levelname)s - %(message)s'
            logging.basicConfig(level=logging.DEBUG, format=verbose_formatter)
        else:
            formatter = '%(levelname)s: %(message)s'
            logging.basicConfig(level=logging.INFO, format=formatter)
        # check ADB
        AdbWrapper.check_adb()
        # assign the variable
        self.set_serial(args.serial)
        # return instance
        return self
开发者ID:zapion,项目名称:b2g-util-python,代码行数:28,代码来源:reset_phone.py


示例4: __init__

 def __init__(self, **kwargs):
     self.arg_parser = argparse.ArgumentParser(description='Enable Certified Apps Debugging.',
                                               formatter_class=RawTextHelpFormatter,
                                               epilog=textwrap.dedent('''\
                                               Please enable "ADB and Devtools" of device.
                                               Ref:
                                               - https://developer.mozilla.org/en-US/docs/Tools/WebIDE
                                               - https://developer.mozilla.org/en-US/docs/Tools/WebIDE/Running_and_debugging_apps#Debugging_apps
                                               '''))
     self.arg_parser.add_argument('-s', '--serial', action='store', dest='serial', default=None,
                                  help=textwrap.dedent('''\
                                  Directs command to the device or emulator with the
                                  given serial number. Overrides ANDROID_SERIAL
                                  environment variable. (default: %(default)s)
                                  '''))
     self.arg_parser.add_argument('--disable', action='store_true', dest='disable', default=False, help='Disable the privileges. (default: %(default)s)')
     self.arg_parser.add_argument('-v', '--verbose', action='store_true', dest='verbose', default=False,
                                  help=textwrap.dedent('''\
                                  Turn on verbose output, with all the debug logger.
                                  (default: %(default)s)
                                  '''))
     self.args = self.arg_parser.parse_args()
     # setup the logging config
     if self.args.verbose is True:
         verbose_formatter = '%(asctime)s - %(name)s - %(levelname)s - %(message)s'
         logging.basicConfig(level=logging.DEBUG, format=verbose_formatter)
     else:
         formatter = '%(levelname)s: %(message)s'
         logging.basicConfig(level=logging.INFO, format=formatter)
     AdbWrapper.check_adb()
开发者ID:Conjuror,项目名称:b2g-util-python,代码行数:30,代码来源:enable_certapps_devtools.py


示例5: __init__

    def __init__(self, **kwargs):
        self._FILE_PROFILE_INI = 'profiles.ini'
        self._FILE_COMPATIBILITY_INI = 'compatibility.ini'
        self._LOCAL_DIR_SDCARD = 'sdcard'
        self._LOCAL_DIR_WIFI = 'wifi'
        self._LOCAL_FILE_WIFI = 'wifi/wpa_supplicant.conf'
        self._LOCAL_DIR_B2G = 'b2g-mozilla'
        self._LOCAL_DIR_DATA = 'data-local'
        self._LOCAL_DIR_DATA_APPS = 'webapps'
        self._REMOTE_DIR_SDCARD = '/sdcard/'
        self._REMOTE_FILE_WIFI = '/data/misc/wifi/wpa_supplicant.conf'
        self._REMOTE_FILE_WIFI_OWNER = 'system:wifi'
        self._REMOTE_DIR_B2G = '/data/b2g/mozilla'
        self._REMOTE_DIR_DATA = '/data/local'

        self.arg_parser = argparse.ArgumentParser(description='Workaround for backing up and restoring Firefox OS profiles. (BETA)',
                                                  formatter_class=ArgumentDefaultsHelpFormatter)
        self.arg_parser.add_argument('-s', '--serial', action='store', dest='serial', default=None, help='Directs command to the device or emulator with the given serial number. Overrides ANDROID_SERIAL environment variable.')
        br_group = self.arg_parser.add_mutually_exclusive_group(required=True)
        br_group.add_argument('-b', '--backup', action='store_true', dest='backup', default=False, help='Backup user profile.')
        br_group.add_argument('-r', '--restore', action='store_true', dest='restore', default=False, help='Restore user profile.')
        self.arg_parser.add_argument('--sdcard', action='store_true', dest='sdcard', default=False, help='Also backup/restore SD card.')
        self.arg_parser.add_argument('--no-reboot', action='store_true', dest='no_reboot', default=False, help='Do not reboot B2G after backup/restore.')
        self.arg_parser.add_argument('-p', '--profile-dir', action='store', dest='profile_dir', default='mozilla-profile', help='Specify the profile folder.')
        self.arg_parser.add_argument('-v', '--verbose', action='store_true', dest='verbose', default=False, help='Turn on verbose output, with all the debug logger.')
        self.args = self.arg_parser.parse_args()
        # setup the logging config
        if self.args.verbose is True:
            verbose_formatter = '%(asctime)s - %(name)s - %(levelname)s - %(message)s'
            logging.basicConfig(level=logging.DEBUG, format=verbose_formatter)
        else:
            formatter = '%(levelname)s: %(message)s'
            logging.basicConfig(level=logging.INFO, format=formatter)
        AdbWrapper.check_adb()
开发者ID:Conjuror,项目名称:b2g-util-python,代码行数:34,代码来源:backup_restore_profile.py


示例6: get_crashreports

    def get_crashreports(self, serial=None):
        """
        Print the pending and submitted crash reports on device.

        The submitted crashs report will be displayed with URL link.

        @param serial: device serial number. (optional)
        """
        AdbWrapper.adb_root(serial=serial)
        logger.info('Getting Crash Reports...')

        self.pending_stdout, retcode_pending = AdbWrapper.adb_shell('ls -al "{}"'.format(self.pending_path),
                                                             serial=serial)
        print('Pending Crash Reports:\n{}\n'.format(self.pending_stdout))

        self.submitted_stdout, retcode_submitted = AdbWrapper.adb_shell('ls -al "{}"'.format(self.submitted_path),
                                                                 serial=serial)
        print('Submitted Crash Reports:\n{}\n'.format(self.submitted_stdout))
        # parse stdout for getting filepath
        self.pending_files = self._parse_stdout(self.pending_path, self.pending_stdout)
        self.submitted_files = self._parse_stdout(self.submitted_path, self.submitted_stdout)

        self.submitted_url_list = []
        if retcode_submitted == 0:
            print('The links of Submitted Crash Reports:')
            for line in self.submitted_stdout.split('\n'):
                submmited_id = re.sub(r'\.txt\s*$', '', re.sub(r'^.+bp-', '', line))
                submitted_url = 'https://crash-stats.mozilla.com/report/index/{}'.format(submmited_id)
                self.submitted_url_list.append(submitted_url)
                print(submitted_url)
开发者ID:zapion,项目名称:b2g-util-python,代码行数:30,代码来源:get_crashreports.py


示例7: prepare_step

 def prepare_step(self):
     # checking the adb root
     if not AdbWrapper.adb_root(serial=self.serial):
         raise Exception('No root permission for shallow flashing.')
     # checking the adb remount
     if not AdbWrapper.adb_remount(serial=self.serial):
         raise Exception('No permission to remount for shallow flashing.')
     # Stop B2G
     B2GHelper.stop_b2g(serial=self.serial)
开发者ID:zapion,项目名称:b2g-util-python,代码行数:9,代码来源:shallow_flash.py


示例8: _check_profile_version

    def _check_profile_version(self, local_dir, serial=None):
        """
        Check the versions of backup and device.
        The lower backup can restore to device. However the higher backup cannot.

        @param local_dir: the local backup folder.
        @param serial: device serial number. (optional)

        @return: True if backup version is lower than device's.

        @raise exception: if cannot load profiles or versions.
        """
        if self.skip_version_check:
            logger.info('Skip version check.')
            return True
        logger.info('Checking profile...')
        # get local version
        if os.path.isdir(local_dir):
            local_profile_path = self._get_profile_path(
                os.path.join(local_dir, self._LOCAL_DIR_B2G, self._FILE_PROFILE_INI))
            version_of_backup = self._get_version_from_profile(
                os.path.join(local_dir, self._LOCAL_DIR_B2G, local_profile_path, self._FILE_COMPATIBILITY_INI))
        else:
            raise Exception('Can not load profile from [{}]'.format(os.path.abspath(local_dir)))
        tmp_dir = None
        try:
            # get remote version
            tmp_dir = tempfile.mkdtemp(prefix='backup_restore_')
            logger.debug('TEMP Folder for check profile: {}'.format(tmp_dir))
            try:
                AdbWrapper.adb_pull(os.path.join(self._REMOTE_DIR_B2G, self._FILE_PROFILE_INI), tmp_dir, serial=serial)
            except:
                raise Exception(
                    'Can not pull {2} from {0} to {1}. '
                    'Please run with --skip-version-check if you want to restore.'.format(
                        self._REMOTE_DIR_B2G, tmp_dir, self._FILE_PROFILE_INI))
            remote_profile_path = self._get_profile_path(os.path.join(tmp_dir, self._FILE_PROFILE_INI))
            try:
                AdbWrapper.adb_pull(
                    os.path.join(self._REMOTE_DIR_B2G, remote_profile_path, self._FILE_COMPATIBILITY_INI), tmp_dir,
                    serial=serial)
            except:
                raise Exception(
                    'Can not pull {2} from {0} to {1}. '
                    'Please run with --skip-version-check if you want to restore.'.format(
                        self._REMOTE_DIR_B2G, tmp_dir, self._FILE_COMPATIBILITY_INI))
            version_of_device = self._get_version_from_profile(
                os.path.join(os.path.join(tmp_dir, self._FILE_COMPATIBILITY_INI)))
            # compare
            return self._compare_version(version_of_backup, version_of_device)
        finally:
            if tmp_dir:
                logger.debug('Removing [{0}] folder...'.format(tmp_dir))
                shutil.rmtree(tmp_dir)
                logger.debug('TEMP Folder for check profile removed: {}'.format(tmp_dir))
开发者ID:zapion,项目名称:b2g-util-python,代码行数:55,代码来源:backup_restore_profile.py


示例9: restore_sdcard

 def restore_sdcard(self, local_dir, serial=None):
     logger.info('Restoring SD card...')
     target_dir = os.path.join(local_dir, self._LOCAL_DIR_SDCARD)
     if os.path.isdir(target_dir):
         logger.info('Restore: {0} to {1}'.format(target_dir, self._REMOTE_DIR_SDCARD))
         try:
             AdbWrapper.adb_push(target_dir, self._REMOTE_DIR_SDCARD, serial=serial)
         except:
             logger.warning('Can not push files from {0} to {1}'.format(target_dir, self._REMOTE_DIR_SDCARD))
     else:
         logger.info('{0}: No such file or directory'.format(target_dir))
         return
     logger.info('Restore SD card done.')
开发者ID:Conjuror,项目名称:b2g-util-python,代码行数:13,代码来源:backup_restore_profile.py


示例10: prepare

 def prepare(self):
     """
     parse args and setup the logging
     """
     self.args = self.arg_parser.parse_args()
     # setup the logging config
     if self.args.verbose is True:
         verbose_formatter = "%(asctime)s - %(name)s - %(levelname)s - %(message)s"
         logging.basicConfig(level=logging.DEBUG, format=verbose_formatter)
     else:
         formatter = "%(levelname)s: %(message)s"
         logging.basicConfig(level=logging.INFO, format=formatter)
     AdbWrapper.check_adb()
开发者ID:ShakoHo,项目名称:b2g-util-python,代码行数:13,代码来源:check_versions.py


示例11: cli

    def cli(self):
        """
        Handle the argument parse, and the return the instance itself.
        """
        # argument parser
        arg_parser = argparse.ArgumentParser(
            description='Workaround for backing up and restoring Firefox OS profiles. (BETA)',
            formatter_class=ArgumentDefaultsHelpFormatter)
        arg_parser.add_argument('-s', '--serial', action='store', dest='serial', default=None,
                                help='Directs command to the device or emulator with the given serial number. '
                                     'Overrides ANDROID_SERIAL environment variable.')
        br_group = arg_parser.add_mutually_exclusive_group(required=True)
        br_group.add_argument('-b', '--backup', action='store_true', dest='backup', default=False,
                              help='Backup user profile.')
        br_group.add_argument('-r', '--restore', action='store_true', dest='restore', default=False,
                              help='Restore user profile.')
        arg_parser.add_argument('--sdcard', action='store_true', dest='sdcard', default=False,
                                help='Also backup/restore SD card.')
        arg_parser.add_argument('--no-reboot', action='store_true', dest='no_reboot', default=False,
                                help='Do not reboot B2G after backup/restore.')
        arg_parser.add_argument('-p', '--profile-dir', action='store', dest='profile_dir', default='mozilla-profile',
                                help='Specify the profile folder.')
        arg_parser.add_argument('--skip-version-check', action='store_true', dest='skip_version_check', default=False,
                                help='Turn off version check between backup profile and device.')
        arg_parser.add_argument('-v', '--verbose', action='store_true', dest='verbose', default=False,
                                help='Turn on verbose output, with all the debug logger.')

        # parse args and setup the logging
        args = arg_parser.parse_args()
        # setup the logging config
        if args.verbose is True:
            verbose_formatter = '%(asctime)s - %(name)s - %(levelname)s - %(message)s'
            logging.basicConfig(level=logging.DEBUG, format=verbose_formatter)
        else:
            formatter = '%(levelname)s: %(message)s'
            logging.basicConfig(level=logging.INFO, format=formatter)
        # check ADB
        AdbWrapper.check_adb()
        # assign the variable
        self.set_serial(args.serial)
        if args.backup:
            self.set_backup(args.backup)
        elif args.restore:
            self.set_restore(args.restore)
        self.set_sdcard(args.sdcard)
        self.set_no_reboot(args.no_reboot)
        self.set_profile_dir(args.profile_dir)
        self.set_skip_version_check(args.skip_version_check)
        # return instance
        return self
开发者ID:zapion,项目名称:b2g-util-python,代码行数:50,代码来源:backup_restore_profile.py


示例12: __init__

 def __init__(self, **kwargs):
     self.arg_parser = argparse.ArgumentParser(description='Get the Crash Reports from Firefox OS Phone.',
                                               formatter_class=ArgumentDefaultsHelpFormatter)
     self.arg_parser.add_argument('-s', '--serial', action='store', dest='serial', default=None, help='Directs command to the device or emulator with the given serial number. Overrides ANDROID_SERIAL environment variable.')
     self.arg_parser.add_argument('-v', '--verbose', action='store_true', dest='verbose', default=False, help='Turn on verbose output, with all the debug logger.')
     self.args = self.arg_parser.parse_args()
     # setup the logging config
     if self.args.verbose is True:
         verbose_formatter = '%(asctime)s - %(name)s - %(levelname)s - %(message)s'
         logging.basicConfig(level=logging.DEBUG, format=verbose_formatter)
     else:
         formatter = '%(levelname)s: %(message)s'
         logging.basicConfig(level=logging.INFO, format=formatter)
     AdbWrapper.check_adb()
开发者ID:Conjuror,项目名称:b2g-util-python,代码行数:14,代码来源:get_crashreports.py


示例13: reset_phone

 def reset_phone(self, serial=None):
     # checking the adb root for backup/restore
     if not AdbWrapper.adb_root(serial=serial):
         raise Exception('No root permission for backup and resotre.')
     # starting to reset
     logger.info('Starting to Reset Firefox OS Phone...')
     AdbWrapper.adb_shell('rm -r /cache/*', serial=serial)
     AdbWrapper.adb_shell('mkdir /cache/recovery', serial=serial)
     AdbWrapper.adb_shell('echo "--wipe_data" > /cache/recovery/command', serial=serial)
     AdbWrapper.adb_shell('reboot recovery', serial=serial)
     logger.info('Reset Firefox OS Phone done.')
开发者ID:Conjuror,项目名称:b2g-util-python,代码行数:11,代码来源:reset_phone.py


示例14: _push_gecko

 def _push_gecko(self, source_dir):
     # push into device
     logger.info('Pushing Gecko: Start')
     gecko_dir = os.path.join(source_dir, 'b2g')
     # push
     target_path = '/system/b2g/'
     logger.debug('adb push {} to {}'.format(gecko_dir, target_path))
     AdbWrapper.adb_push(gecko_dir, target_path, serial=self.serial)
     # set excutable
     source_files = os.listdir(gecko_dir)
     executable_files = [os.path.join('/system/b2g/', f) for f in source_files if os.access(os.path.join(gecko_dir, f), os.X_OK)]
     logger.debug('Add executed permission on device: {}'.format(executable_files))
     for file in executable_files:
         AdbWrapper.adb_shell('chmod 777 {}'.format(file), serial=self.serial)
     logger.info('Pushing Gecko: Done')
开发者ID:zapion,项目名称:b2g-util-python,代码行数:15,代码来源:shallow_flash.py


示例15: _clean_gaia

 def _clean_gaia(self):
     logger.info('Cleaning Gaia profile: Start')
     command_list = ['rm -r /cache/*',
                     'rm -r /data/b2g/*',
                     'rm -r /data/local/storage/persistent/*',
                     'rm -r /data/local/svoperapps',
                     'rm -r /data/local/webapps',
                     'rm -r /data/local/user.js',
                     'rm -r /data/local/permissions.sqlite*',
                     'rm -r /data/local/OfflineCache',
                     'rm -r /data/local/indexedDB',
                     'rm -r /data/local/debug_info_trigger',
                     'rm -r /system/b2g/webapps']
     for cmd in command_list:
         AdbWrapper.adb_shell(cmd, serial=self.serial)
     logger.info('Cleaning Gaia profile: Done')
开发者ID:zapion,项目名称:b2g-util-python,代码行数:16,代码来源:shallow_flash.py


示例16: run

    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,代码行数:34,代码来源:check_versions.py


示例17: get_crashreports

    def get_crashreports(self, serial=None):
        AdbWrapper.adb_root(serial=serial)
        logger.info('Getting Crash Reports...')

        pending, retcode_pending = AdbWrapper.adb_shell('ls -al /data/b2g/mozilla/Crash\ Reports/pending', serial=serial)
        print('Pending Crash Reports:\n{}\n'.format(pending))

        submitted, retcode_submitted = AdbWrapper.adb_shell('ls -al /data/b2g/mozilla/Crash\ Reports/submitted', serial=serial)
        print('Submitted Crash Reports:\n{}\n'.format(submitted))

        if retcode_submitted == 0:
            print('The links of Submitted Crash Reports:')
            for line in submitted.split('\n'):
                submmited_id = re.sub(r'\.txt\s*$', '', re.sub(r'^.+bp-', '', line))
                submitted_url = 'https://crash-stats.mozilla.com/report/index/{}'.format(submmited_id)
                print(submitted_url)
开发者ID:Conjuror,项目名称:b2g-util-python,代码行数:16,代码来源:get_crashreports.py


示例18: run

    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,代码行数:28,代码来源:shallow_flash.py


示例19: run

    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,代码行数:34,代码来源:check_versions.py


示例20: check_profile_version

 def check_profile_version(self, local_dir, serial=None):
     logger.info('Checking profile...')
     # get local version
     if os.path.isdir(local_dir):
         local_config = ConfigParser.ConfigParser()
         local_config.read(os.path.join(local_dir, self._LOCAL_DIR_B2G, self._FILE_PROFILE_INI))
         local_profile_path = local_config.get('Profile0', 'Path')
         local_config.read(os.path.join(local_dir, self._LOCAL_DIR_B2G, local_profile_path, self._FILE_COMPATIBILITY_INI))
         logger.debug('Local Profile: {}'.format(local_config._sections))
         version_of_backup = local_config.get('Compatibility', 'LastVersion')
         logger.info('The Version of Backup Profile: {}'.format(version_of_backup))
     else:
         return False
     try:
         # get remote version
         tmp_dir = tempfile.mkdtemp(prefix='backup_restore_')
         logger.debug('TEMP Folder for check profile: {}'.format(tmp_dir))
         try:
             AdbWrapper.adb_pull(os.path.join(self._REMOTE_DIR_B2G, self._FILE_PROFILE_INI), tmp_dir, serial=serial)
         except:
             logger.warning('Can not pull {2} from {0} to {1}'.format(self._REMOTE_DIR_B2G, tmp_dir, self._FILE_PROFILE_INI))
             return False
         remote_config = ConfigParser.ConfigParser()
         remote_config.read(os.path.join(tmp_dir, self._FILE_PROFILE_INI))
         logger.debug('Remote Profile to get path: {}'.format(remote_config._sections))
         remote_profile_path = remote_config.get('Profile0', 'Path')
         try:
             AdbWrapper.adb_pull(os.path.join(self._REMOTE_DIR_B2G, remote_profile_path, self._FILE_COMPATIBILITY_INI), tmp_dir, serial=serial)
         except:
             logger.warning('Can not pull {2} from {0} to {1}'.format(self._REMOTE_DIR_B2G, tmp_dir, self._FILE_COMPATIBILITY_INI))
             return False
         remote_config.read(os.path.join(tmp_dir, self._FILE_COMPATIBILITY_INI))
         logger.debug('Remote Profile: {}'.format(remote_config._sections))
         version_of_device = remote_config.get('Compatibility', 'LastVersion')
         logger.info('The Version of Device Profile: {}'.format(version_of_device))
         # compare
         version_of_backup_float = float(version_of_backup.split('.')[0])
         version_of_device_float = float(version_of_device.split('.')[0])
         logger.debug('Local Ver: {}, Remote Ver: {}'.format(version_of_backup_float, version_of_device_float))
         if version_of_device_float >= version_of_backup_float:
             return True
         else:
             return False
     finally:
         logger.debug('Removing [{0}] folder...'.format(tmp_dir))
         shutil.rmtree(tmp_dir)
         logger.debug('TEMP Folder for check profile removed: {}'.format(tmp_dir))
开发者ID:Conjuror,项目名称:b2g-util-python,代码行数:47,代码来源:backup_restore_profile.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python bad_request_rate_limiter.BadRequestRateLimiter类代码示例发布时间:2022-05-26
下一篇:
Python ObsFile.ObsFile类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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