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


Python AdbWrapper.adb_push方法代码示例

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


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

示例1: set_certapps

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

示例2: restore_sdcard

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

示例3: _push_gecko

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

示例4: restore_sdcard

# 需要导入模块: from util.adb_helper import AdbWrapper [as 别名]
# 或者: from util.adb_helper.AdbWrapper import adb_push [as 别名]
    def restore_sdcard(self, local_dir, serial=None):
        '''
        Restore data from local folder to device's SDCard.

        @param local_dir: the source local folder, will get data from this folder and than restore to device's SDCard.
        '''
        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.error('Can not push files from {0} to {1}'.format(target_dir, self._REMOTE_DIR_SDCARD))
            logger.info('Restore SD card done.')
        else:
            logger.info('{0}: No such file or directory'.format(target_dir))
开发者ID:ShakoHo,项目名称:b2g-util-python,代码行数:19,代码来源:backup_restore_profile.py

示例5: restore_profile

# 需要导入模块: from util.adb_helper import AdbWrapper [as 别名]
# 或者: from util.adb_helper.AdbWrapper import adb_push [as 别名]
 def restore_profile(self, local_dir, serial=None):
     logger.info('Restoring profile...')
     if os.path.isdir(local_dir):
         # Restore Wifi
         wifi_file = os.path.join(local_dir, self._LOCAL_FILE_WIFI)
         if os.path.isfile(wifi_file):
             logger.info('Restoring Wifi information...')
             try:
                 AdbWrapper.adb_push(wifi_file, self._REMOTE_FILE_WIFI, serial=serial)
             except:
                 logger.warning('If you don\'t have root permission, you cannot restore Wifi information.')
             AdbWrapper.adb_shell('chown {0} {1}'.format(self._REMOTE_FILE_WIFI_OWNER, self._REMOTE_FILE_WIFI))
         # Restore profile
         b2g_mozilla_dir = os.path.join(local_dir, self._LOCAL_DIR_B2G)
         if os.path.isdir(b2g_mozilla_dir):
             logger.info('Restore from {0} to {1} ...'.format(b2g_mozilla_dir, self._REMOTE_DIR_B2G))
             AdbWrapper.adb_shell('rm -r {0}'.format(self._REMOTE_DIR_B2G))
             try:
                 AdbWrapper.adb_push(b2g_mozilla_dir, self._REMOTE_DIR_B2G, serial=serial)
             except:
                 logger.warning('Can not push files from {0} to {1}'.format(b2g_mozilla_dir, self._REMOTE_DIR_B2G))
         # Restore data/local
         datalocal_dir = os.path.join(local_dir, self._LOCAL_DIR_DATA)
         if os.path.isdir(datalocal_dir):
             logger.info('Restore from {0} to {1} ...'.format(datalocal_dir, self._REMOTE_DIR_DATA))
             AdbWrapper.adb_shell('rm -r {0}'.format(self._REMOTE_DIR_DATA))
             try:
                 AdbWrapper.adb_push(datalocal_dir, self._REMOTE_DIR_DATA, serial=serial)
             except:
                 logger.warning('Can not push files from {0} to {1}'.format(datalocal_dir, self._REMOTE_DIR_DATA))
         logger.info('Restore profile done.')
     else:
         logger.info('{0}: No such file or directory'.format(local_dir))
         return
开发者ID:Conjuror,项目名称:b2g-util-python,代码行数:36,代码来源:backup_restore_profile.py

示例6: _push_gaia

# 需要导入模块: from util.adb_helper import AdbWrapper [as 别名]
# 或者: from util.adb_helper.AdbWrapper import adb_push [as 别名]
    def _push_gaia(self, source_dir):
        # push into device
        logger.info('Pushing Gaia: Start')
        unziped_gaia_dir = os.path.join(source_dir, 'gaia')

        # push user.js
        source_user_pref_path = os.path.join(unziped_gaia_dir, 'profile', 'user.js')
        user_pref_path = os.path.join(source_dir, 'user.js')
        # prepare the user.js
        logger.debug('Prepare user.js file')
        with open(source_user_pref_path, 'r') as fin:
            with open(user_pref_path, 'w') as fout:
                for line in fin:
                    fout.write(line.replace('user_pref', 'pref'))
        user_pref_target_path = '/system/b2g/defaults/pref/'
        logger.info('push user.js...')
        logger.debug('adb push {} to {}'.format(user_pref_path, user_pref_target_path))
        AdbWrapper.adb_push(user_pref_path, user_pref_target_path, serial=self.serial)

        # push webapps
        webapps_path = os.path.join(unziped_gaia_dir, 'profile', 'webapps')
        webapps_target_path = '/system/b2g/webapps'
        logger.info('push webapps...')
        logger.debug('adb push {} to {}'.format(webapps_path, webapps_target_path))
        AdbWrapper.adb_push(webapps_path, webapps_target_path, serial=self.serial)

        # push settings.json
        settings_path = os.path.join(unziped_gaia_dir, 'profile', 'settings.json')
        settings_target_path = '/system/b2g/defaults/'
        logger.info('push settings.json...')
        logger.debug('adb push {} to {}'.format(settings_path, settings_target_path))
        AdbWrapper.adb_push(settings_path, settings_target_path, serial=self.serial)
        logger.info('Pushing Gaia: Done')
开发者ID:zapion,项目名称:b2g-util-python,代码行数:35,代码来源:shallow_flash.py

示例7: restore_profile

# 需要导入模块: from util.adb_helper import AdbWrapper [as 别名]
# 或者: from util.adb_helper.AdbWrapper import adb_push [as 别名]
    def restore_profile(self, local_dir, serial=None):
        """
        Restore B2G user profile from local folder to device.

        @param local_dir: the source local folder, the backup data will restore from this folder.
        @param serial: device serial number. (optional)
        """
        logger.info('Restoring profile...')
        if os.path.isdir(local_dir):
            # Restore Wifi
            wifi_file = os.path.join(local_dir, self._LOCAL_FILE_WIFI)
            if os.path.isfile(wifi_file):
                logger.info('Restoring Wifi information...')
                try:
                    AdbWrapper.adb_push(wifi_file, self._REMOTE_FILE_WIFI, serial=serial)
                except Exception as e:
                    logger.debug(e)
                    logger.error('If you don\'t have root permission, you cannot restore Wifi information.')
                AdbWrapper.adb_shell('chown {0} {1}'.format(self._REMOTE_FILE_WIFI_OWNER, self._REMOTE_FILE_WIFI))
            # Restore profile
            b2g_mozilla_dir = os.path.join(local_dir, self._LOCAL_DIR_B2G)
            if os.path.isdir(b2g_mozilla_dir):
                logger.info('Restore from {0} to {1} ...'.format(b2g_mozilla_dir, self._REMOTE_DIR_B2G))
                AdbWrapper.adb_shell('rm -r {0}'.format(self._REMOTE_DIR_B2G))
                try:
                    AdbWrapper.adb_push(b2g_mozilla_dir, self._REMOTE_DIR_B2G, serial=serial)
                except Exception as e:
                    logger.debug(e)
                    logger.error('Can not push files from {0} to {1}'.format(b2g_mozilla_dir, self._REMOTE_DIR_B2G))
            # Restore data/local
            datalocal_dir = os.path.join(local_dir, self._LOCAL_DIR_DATA)
            if os.path.isdir(datalocal_dir):
                logger.info('Restore from {0} to {1} ...'.format(datalocal_dir, self._REMOTE_DIR_DATA))
                AdbWrapper.adb_shell('rm -r {0}'.format(self._REMOTE_DIR_DATA))
                try:
                    AdbWrapper.adb_push(datalocal_dir, self._REMOTE_DIR_DATA, serial=serial)
                except Exception as e:
                    logger.debug(e)
                    logger.error('Can not push files from {0} to {1}'.format(datalocal_dir, self._REMOTE_DIR_DATA))
            logger.info('Restore profile done.')
        else:
            logger.info('{0}: No such file or directory'.format(local_dir))
开发者ID:zapion,项目名称:b2g-util-python,代码行数:44,代码来源:backup_restore_profile.py


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