1# Copyright 2018 The Chromium OS Authors. All rights reserved. 2# Use of this source code is governed by a BSD-style license that can be 3# found in the LICENSE file. 4 5import tempfile 6 7from autotest_lib.client.common_lib import file_utils 8 9_URL_BASE = ('https://sites.google.com/a/chromium.org/dev/chromium-os' 10 '/testing/power-testing/pltp') 11_PLTG_URL = _URL_BASE + '/pltg' 12_PLTU_URL = _URL_BASE + '/pltu' 13_PLTP_URL = _URL_BASE + '/pltp' 14 15 16def _get_content(url): 17 """Reads the content of the file at the given |URL|. 18 19 Args: 20 url: URL to be fetched. 21 22 Return: 23 The content of the fetched file. 24 """ 25 with tempfile.NamedTemporaryFile() as named_file: 26 file_utils.download_file(url, named_file.name) 27 return named_file.read().rstrip() 28 29 30def use_gaia_login(): 31 """Returns whether Gaia login should be used by default for load testing.""" 32 res = _get_content(_PLTG_URL) 33 return res == 'True' or res == 'true' 34 35 36def get_username(): 37 """Returns username for load testing.""" 38 return _get_content(_PLTU_URL) 39 40 41def get_password(): 42 """Returns password for load testing.""" 43 return _get_content(_PLTP_URL) 44