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


Python AdbWrapper.adb_root方法代码示例

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


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

示例1: get_crashreports

# 需要导入模块: from util.adb_helper import AdbWrapper [as 别名]
# 或者: from util.adb_helper.AdbWrapper import adb_root [as 别名]
    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,代码行数:32,代码来源:get_crashreports.py

示例2: set_certapps

# 需要导入模块: from util.adb_helper import AdbWrapper [as 别名]
# 或者: from util.adb_helper.AdbWrapper import adb_root [as 别名]
    def set_certapps(self, enable=True, serial=None):
        AdbWrapper.adb_root(serial=serial)
        logger.info('{} Full Privilege for WebIDE...'.format('Enabling' if enable else 'Disabling'))

        need_restart = True
        try:
            tmp_dir = tempfile.mkdtemp(prefix='enablecertapps_')
            # get profile folder name xxx.default under /data/b2g/mozilla/
            profile_dir_name, retcode = AdbWrapper.adb_shell('ls /data/b2g/mozilla/ | grep default', serial=serial)
            device_src_file = os.path.join('/data/b2g/mozilla/', profile_dir_name, 'prefs.js')
            dest_temp_file = os.path.join(tmp_dir, 'prefs.js.origin')
            try:
                logger.info('Pulling prefs.js file...')
                AdbWrapper.adb_pull(device_src_file, dest_temp_file, serial=serial)
            except:
                raise Exception('Error pulling prefs.js file.')

            dest_file = os.path.join(tmp_dir, 'prefs.js')
            with open(dest_temp_file, 'r') as fr:
                with open(dest_file, 'w') as fw:
                    match = False
                    is_forbid = 'false' if enable else 'true'
                    logger.debug('is_forbid: [{}]'.format(is_forbid))
                    for line in fr:
                        if 'devtools.debugger.forbid-certified-apps' in line:
                            logger.debug('line: [{}] to [{}]'.format(line, is_forbid))
                            if is_forbid in line:
                                # do not need to restart if the setting isn't changed
                                logger.info('The full privilege is already {}.'.format('enabled' if enable else 'disabled'))
                                need_restart = False
                                break
                            else:
                                logger.info('Changing setting of pref.js file...')
                                fw.write('user_pref("devtools.debugger.forbid-certified-apps", {});\n'.format(is_forbid))
                            match = True
                        else:
                            fw.write(line)
                    if not match:
                        if not enable:
                            # the forbid is true when there is no setting
                            logger.info('The full privilege is already disabled.')
                            need_restart = False
                        else:
                            if need_restart:
                                # adding setting when there is no setting and need to enable certapps
                                logger.info('Adding setting of pref.js file...')
                                fw.write('user_pref("devtools.debugger.forbid-certified-apps", {});\n'.format(is_forbid))
            if need_restart:
                B2GHelper.stop_b2g(serial=serial)
                try:
                    logger.info('Pushing prefs.js file...')
                    AdbWrapper.adb_push(dest_file, device_src_file, serial=serial)
                except:
                    raise Exception('Error pushing prefs.js file.')
        finally:
            if need_restart:
                B2GHelper.start_b2g(serial=serial)
            shutil.rmtree(tmp_dir)
开发者ID:Conjuror,项目名称:b2g-util-python,代码行数:60,代码来源:enable_certapps_devtools.py

示例3: get_crashreports

# 需要导入模块: from util.adb_helper import AdbWrapper [as 别名]
# 或者: from util.adb_helper.AdbWrapper import adb_root [as 别名]
    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,代码行数:18,代码来源:get_crashreports.py

示例4: prepare_step

# 需要导入模块: from util.adb_helper import AdbWrapper [as 别名]
# 或者: from util.adb_helper.AdbWrapper import adb_root [as 别名]
 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,代码行数:11,代码来源:shallow_flash.py

示例5: reset_phone

# 需要导入模块: from util.adb_helper import AdbWrapper [as 别名]
# 或者: from util.adb_helper.AdbWrapper import adb_root [as 别名]
 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,代码行数:13,代码来源:reset_phone.py

示例6: get_crashreports

# 需要导入模块: from util.adb_helper import AdbWrapper [as 别名]
# 或者: from util.adb_helper.AdbWrapper import adb_root [as 别名]
    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...')

        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:ShakoHo,项目名称:b2g-util-python,代码行数:25,代码来源:get_crashreports.py

示例7: reset_phone

# 需要导入模块: from util.adb_helper import AdbWrapper [as 别名]
# 或者: from util.adb_helper.AdbWrapper import adb_root [as 别名]
 def reset_phone(self, serial=None):
     '''
     Reset the B2G device.
     @param serial: device serial number. (optional)
     @raise exception: When no root permission for reset device.
     '''
     # checking the adb root for backup/restore
     if not AdbWrapper.adb_root(serial=serial):
         raise Exception('No root permission for reset device.')
     # 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:ShakoHo,项目名称:b2g-util-python,代码行数:18,代码来源:reset_phone.py

示例8: run

# 需要导入模块: from util.adb_helper import AdbWrapper [as 别名]
# 或者: from util.adb_helper.AdbWrapper import adb_root [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_root方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。