Coverage for /opt/conda/envs/apienv/lib/python3.10/site-packages/daiquiri/core/components/tomo/scan_info_resource.py: 53%

15 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 -*- 

3import logging 

4 

5from daiquiri.core import marshal 

6from daiquiri.core.components import ComponentResource 

7 

8from .datatype import TomoScan 

9 

10 

11logger = logging.getLogger(__name__) 

12 

13 

14class TomoScanInfoResource(ComponentResource): 

15 @marshal( 

16 # out=[[200, paginated(TomoDetectorsSchema), "List of tomo scan info"]], 

17 # paged=True, 

18 ) 

19 def get(self, **kwargs): 

20 """Get a list of all last scan info""" 

21 scaninfo = self._parent.get_scaninfos() 

22 

23 def scan_info_meta(si: TomoScan): 

24 if si is None: 

25 return {} 

26 return si.to_rest() 

27 

28 result = { 

29 "lastgroup": scan_info_meta(scaninfo.last_group), 

30 "lastproj": scan_info_meta(scaninfo.last_proj), 

31 "lastflat": scan_info_meta(scaninfo.last_flat), 

32 "lastdark": scan_info_meta(scaninfo.last_dark), 

33 "lastref": scan_info_meta(scaninfo.last_ref), 

34 "lasttiling": scan_info_meta(scaninfo.last_tiling), 

35 } 

36 return result, 200