Coverage for python/lsst/ctrl/execute/condorInfoConfig.py: 60%

21 statements  

« prev     ^ index     » next       coverage.py v6.5.0, created at 2023-02-02 06:34 -0800

1#!/usr/bin/env python 

2 

3# 

4# LSST Data Management System 

5# Copyright 2008-2016 LSST Corporation. 

6# 

7# This product includes software developed by the 

8# LSST Project (http://www.lsst.org/). 

9# 

10# This program is free software: you can redistribute it and/or modify 

11# it under the terms of the GNU General Public License as published by 

12# the Free Software Foundation, either version 3 of the License, or 

13# (at your option) any later version. 

14# 

15# This program is distributed in the hope that it will be useful, 

16# but WITHOUT ANY WARRANTY; without even the implied warranty of 

17# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 

18# GNU General Public License for more details. 

19# 

20# You should have received a copy of the LSST License Statement and 

21# the GNU General Public License along with this program. If not, 

22# see <http://www.lsstcorp.org/LegalNotices/>. 

23# 

24 

25import lsst.pex.config as pexConfig 

26from lsst.ctrl.execute import envString 

27 

28 

29class FakeTypeMap(dict): 

30 def __init__(self, configClass): 

31 self.configClass = configClass 

32 

33 def __getitem__(self, k): 

34 return self.setdefault(k, self.configClass) 

35 

36 

37class UserInfoConfig(pexConfig.Config): 

38 """User information""" 

39 

40 name = pexConfig.Field(doc="user login name", dtype=str, default=None) 

41 home = pexConfig.Field(doc="user home directory", dtype=str, default=None) 

42 

43 

44class UserConfig(pexConfig.Config): 

45 """User specific information""" 

46 

47 user = pexConfig.ConfigField(doc="user", dtype=UserInfoConfig) 

48 

49 

50class CondorInfoConfig(pexConfig.Config): 

51 """A pex_config file describing the platform specific information about 

52 remote user logins. 

53 """ 

54 

55 platform = pexConfig.ConfigChoiceField("platform info", FakeTypeMap(UserConfig)) 

56 

57 

58if __name__ == "__main__": 58 ↛ 59line 58 didn't jump to line 59, because the condition on line 58 was never true

59 config = CondorInfoConfig() 

60 filename = "$HOME/.lsst/condor-info.py" 

61 filename = envString.resolve(filename) 

62 config.load(filename) 

63 

64 for i in config.platform: 

65 print(i)