Coverage for python/lsst/sconsUtils/eupsForScons.py: 22%

36 statements  

« prev     ^ index     » next       coverage.py v6.5.0, created at 2022-11-08 21:43 -0800

1import os 

2 

3try: 

4 # Prefer to use native EUPS but if that is not available, fallback 

5 # versions are defined. Only a subset of EUPS functions are required 

6 # but all are imported to prevent warnings from redefinitions below. 

7 from eups import * # noqa F403 F401 

8 eupsLoaded = True 

9except ImportError: 

10 eupsLoaded = False 

11 

12 

13def haveEups(): 

14 return eupsLoaded 

15 

16 

17if not haveEups(): 17 ↛ 21line 17 didn't jump to line 21, because the condition on line 17 was never true

18 # 

19 # Fake what we can so sconsUtils can limp along without eups 

20 # 

21 def flavor(): 

22 from .state import env, log 

23 

24 log.warn("Unable to import eups; guessing flavor") 

25 

26 if env['PLATFORM'] == "posix": 

27 return os.uname()[0].title() 

28 else: 

29 return env['PLATFORM'].title() 

30 

31 def productDir(name): 

32 return os.environ.get("%s_DIR" % name.upper()) 

33 

34 def findSetupVersion(eupsProduct): 

35 return None, None, None, None, flavor() 

36 

37 class _Eups: 

38 def __call__(self): 

39 return self 

40 Eups = _Eups() 

41 

42 Eups.findSetupVersion = findSetupVersion 

43 

44 class _Utils: 

45 pass 

46 utils = _Utils() 

47 

48 def setupEnvNameFor(productName): 

49 return "SETUP_%s" % productName 

50 

51 utils.setupEnvNameFor = setupEnvNameFor 

52 

53 

54def getEups(): 

55 """Return a cached Eups instance, auto-creating if necessary.""" 

56 try: 

57 return getEups._eups 

58 except AttributeError: 

59 getEups._eups = Eups() 

60 return getEups._eups