Coverage for /opt/conda/envs/apienv/lib/python3.10/site-packages/daiquiri/core/hardware/bliss/activetomoconfig.py: 88%

25 statements  

« prev     ^ index     » next       coverage.py v7.6.5, created at 2024-11-15 02:12 +0000

1#!/usr/bin/env python 

2# -*- coding: utf-8 -*- 

3from daiquiri.core.hardware.abstract.objectref import Objectref as AbstractObjectref 

4from daiquiri.core.hardware.bliss.object import BlissObject 

5from daiquiri.core.hardware.bliss.object import ObjectRefProperty 

6import logging 

7 

8try: 

9 from tomo.globals import ACTIVE_TOMOCONFIG 

10except ImportError: 

11 ACTIVE_TOMOCONFIG = None 

12 

13logger = logging.getLogger(__name__) 

14 

15 

16class _ActiveTomoConfigRefProperty(ObjectRefProperty): 

17 def __init__(self): 

18 ObjectRefProperty.__init__(self, "ACTIVE_TOMOCONFIG", compose=True) 

19 

20 @property 

21 def getter(self): 

22 return _ActiveTomoConfigRefProperty._get_ref 

23 

24 def _get_ref(self): 

25 try: 

26 active_obj = ACTIVE_TOMOCONFIG.deref_active_object() 

27 except Exception: 

28 return None 

29 if active_obj is None: 

30 return None 

31 return active_obj.name 

32 

33 

34class Activetomoconfig(BlissObject, AbstractObjectref): 

35 PROPERTY_MAP = {"ref": _ActiveTomoConfigRefProperty()}