def get_global(global_key, do_raise=False): if global_key not in os.environ: fileutils.load_env_file(os.path.expanduser("~/.rally/globals")) value = os.environ.get(global_key) if not value and do_raise: raise exceptions.InvalidArgumentsException("%s env is missing" % global_key) return value
def test_load_env_vile(self, mock_path): file_data = ["FAKE_ENV=fake_env\n"] with mock.patch("rally.fileutils.open", mock.mock_open(read_data=file_data), create=True) as mock_file: mock_file.return_value.readlines.return_value = file_data fileutils.load_env_file("path_to_file") self.assertIn("FAKE_ENV", os.environ) mock_file.return_value.readlines.assert_called_once_with()
def get_global(global_key, do_raise=False): if global_key not in os.environ: fileutils.load_env_file(os.path.expanduser('~/.rally/globals')) value = os.environ.get(global_key) if not value and do_raise: raise exceptions.InvalidArgumentsException('%s env is missing' % global_key) return value
def test_load_env_vile(self, mock_path): file_data = ["FAKE_ENV=fake_env\n"] with mock.patch('rally.fileutils.open', mock.mock_open(read_data=file_data), create=True) as mock_file: mock_file.return_value.readlines.return_value = file_data fileutils.load_env_file('path_to_file') self.assertIn('FAKE_ENV', os.environ) mock_file.return_value.readlines.assert_called_once_with()
def default_deployment_id(): try: deploy_id = os.environ['RALLY_DEPLOYMENT'] except KeyError: fileutils.load_env_file(os.path.expanduser('~/.rally/globals')) try: deploy_id = os.environ['RALLY_DEPLOYMENT'] except KeyError: raise exceptions.InvalidArgumentsException( "deploy-id argument is missing") return deploy_id
def get_global(global_key): if global_key not in os.environ: fileutils.load_env_file(os.path.expanduser('~/.rally/globals')) return os.environ.get(global_key)