def main(): args, unknown_args = _CreateArgparser().parse_known_args() # TODO(bsheedy): Remove this once all uses of --chartjson are removed. if args.chartjson: args.output_format = 'chartjson' chartjson = _BASE_CHART.copy() if args.output_format else None with build_utils.TempDir() as base_dir, build_utils.TempDir() as diff_dir: # Run resource_sizes.py on the two APKs resource_sizes_path = os.path.join(_ANDROID_DIR, 'resource_sizes.py') shared_args = (['python', resource_sizes_path, '--output-format=chartjson'] + unknown_args) base_args = shared_args + ['--output-dir', base_dir, args.base_apk] if args.out_dir_base: base_args += ['--chromium-output-directory', args.out_dir_base] try: subprocess.check_output(base_args, stderr=subprocess.STDOUT) except subprocess.CalledProcessError as e: print e.output raise diff_args = shared_args + ['--output-dir', diff_dir, args.diff_apk] if args.out_dir_diff: diff_args += ['--chromium-output-directory', args.out_dir_diff] try: subprocess.check_output(diff_args, stderr=subprocess.STDOUT) except subprocess.CalledProcessError as e: print e.output raise # Combine the separate results base_file = os.path.join(base_dir, _CHARTJSON_FILENAME) diff_file = os.path.join(diff_dir, _CHARTJSON_FILENAME) base_results = shared_preference_utils.ExtractSettingsFromJson(base_file) diff_results = shared_preference_utils.ExtractSettingsFromJson(diff_file) DiffResults(chartjson, base_results, diff_results) if args.include_intermediate_results: AddIntermediateResults(chartjson, base_results, diff_results) if args.output_format: chartjson_path = os.path.join(os.path.abspath(args.output_dir), _CHARTJSON_FILENAME) logging.critical('Dumping diff chartjson to %s', chartjson_path) with open(chartjson_path, 'w') as outfile: json.dump(chartjson, outfile) if args.output_format == 'histograms': histogram_result = convert_chart_json.ConvertChartJson(chartjson_path) if histogram_result.returncode != 0: logging.error('chartjson conversion failed with error: %s', histogram_result.stdout) return 1 histogram_path = os.path.join(os.path.abspath(args.output_dir), 'perf_results.json') logging.critical('Dumping diff histograms to %s', histogram_path) with open(histogram_path, 'w') as json_file: json_file.write(histogram_result.stdout)
def main(): parser = argparse.ArgumentParser( description='Manually apply shared preference JSON files.') parser.add_argument('filepaths', nargs='*', help='Any number of paths to shared preference JSON ' 'files to apply.') args = parser.parse_args() all_devices = device_utils.DeviceUtils.HealthyDevices() if not all_devices: raise RuntimeError('No healthy devices attached') for filepath in args.filepaths: all_settings = shared_preference_utils.ExtractSettingsFromJson( filepath) for setting in all_settings: for device in all_devices: shared_pref = shared_prefs.SharedPrefs( device, setting['package'], setting['filename'], use_encrypted_path=setting.get('supports_encrypted_path', False)) shared_preference_utils.ApplySharedPreferenceSetting( shared_pref, setting)
def _initializeEditPrefsAttributes(self, args): if not hasattr(args, 'shared_prefs_file') or not args.shared_prefs_file: return if not isinstance(args.shared_prefs_file, str): logging.warning("Given non-string for a filepath") return self._edit_shared_prefs = shared_preference_utils.ExtractSettingsFromJson( args.shared_prefs_file)
def _ConfigureVrCore(self, filepath): """Configures VrCore using the provided settings file.""" settings = shared_preference_utils.ExtractSettingsFromJson(filepath) for setting in settings: shared_pref = self._platform.GetSharedPrefs( setting['package'], setting['filename']) shared_preference_utils.ApplySharedPreferenceSetting( shared_pref, setting)
def _ConfigureVrCore(self): settings = shared_preference_utils.ExtractSettingsFromJson( os.path.join(path_util.GetChromiumSrcDir(), self._finder_options.shared_prefs_file)) for setting in settings: shared_pref = self._platform.GetSharedPrefs( setting['package'], setting['filename']) shared_preference_utils.ApplySharedPreferenceSetting( shared_pref, setting)
def main(): args, unknown_args = _CreateArgparser().parse_known_args() chartjson = _BASE_CHART.copy() if args.chartjson else None with build_utils.TempDir() as base_dir, build_utils.TempDir() as diff_dir: # Run resource_sizes.py on the two APKs resource_sizes_path = os.path.join(_ANDROID_DIR, 'resource_sizes.py') shared_args = (['python', resource_sizes_path, '--chartjson'] + unknown_args) base_args = shared_args + ['--output-dir', base_dir, args.base_apk] if args.out_dir_base: base_args += ['--chromium-output-directory', args.out_dir_base] try: subprocess.check_output(base_args, stderr=subprocess.STDOUT) except subprocess.CalledProcessError as e: print e.output raise diff_args = shared_args + ['--output-dir', diff_dir, args.diff_apk] if args.out_dir_diff: diff_args += ['--chromium-output-directory', args.out_dir_diff] try: subprocess.check_output(diff_args, stderr=subprocess.STDOUT) except subprocess.CalledProcessError as e: print e.output raise # Combine the separate results base_file = os.path.join(base_dir, _RESULTS_FILENAME) diff_file = os.path.join(diff_dir, _RESULTS_FILENAME) base_results = shared_preference_utils.ExtractSettingsFromJson( base_file) diff_results = shared_preference_utils.ExtractSettingsFromJson( diff_file) DiffResults(chartjson, base_results, diff_results) if args.include_intermediate_results: AddIntermediateResults(chartjson, base_results, diff_results) if args.chartjson: with open( os.path.join(os.path.abspath(args.output_dir), _RESULTS_FILENAME), 'w') as outfile: json.dump(chartjson, outfile)
def _ConfigureVrCore(self, filepath): """Configures VrCore using the provided settings file.""" settings = shared_preference_utils.ExtractSettingsFromJson(filepath) for setting in settings: shared_pref = self.platform.GetSharedPrefs( setting['package'], setting['filename'], use_encrypted_path=setting.get('supports_encrypted_path', False)) shared_preference_utils.ApplySharedPreferenceSetting( shared_pref, setting)