Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

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 

31 def __init__(self, configClass): 

32 self.configClass = configClass 

33 

34 def __getitem__(self, k): 

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

36 

37 

38class UserInfoConfig(pexConfig.Config): 

39 """ User information 

40 """ 

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

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

43 

44 

45class UserConfig(pexConfig.Config): 

46 """ User specific information 

47 """ 

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

49 

50 

51class CondorInfoConfig(pexConfig.Config): 

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

53 remote user logins. 

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)