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 5 import tempfile 6 7 from autotest_lib.client.common_lib import file_utils 8 9 10 _URL_BASE = ('https://sites.google.com/a/chromium.org/dev/chromium-os' 11 '/testing/power-testing/pltp') 12 _PLTU_URL = _URL_BASE + '/pltu' 13 _PLTP_URL = _URL_BASE + '/pltp' 14 15 16 def _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 30 def get_username(): 31 """Returns username for load testing.""" 32 return _get_content(_PLTU_URL) 33 34 35 def get_password(): 36 """Returns password for load testing.""" 37 return _get_content(_PLTP_URL) 38