def test_image_name_dirname_changes(camera, tmp_path): image_namer = ImageNamer( "{camera.name}_{num:04d}.fits.fz", dirname=tmp_path, overwrite=True, ) image_namer._last_num = 5 assert image_namer(camera=camera) == tmp_path / "test_camera_0006.fits.fz" assert image_namer._previous_dirname is not None image_namer._previous_dirname = "/home/test" assert image_namer(camera=camera) == tmp_path / "test_camera_0001.fits.fz"
def test_image_namer_files_exist(tmp_path): (tmp_path / "test_0001.fits").touch() (tmp_path / "test_0004.fits").touch() image_namer = ImageNamer("test_{num:04d}.fits", dirname=tmp_path) assert image_namer() == tmp_path / "test_0005.fits" assert image_namer._last_num == 5
def test_image_namer_files_exist_fz(camera, tmp_path): (tmp_path / "test_camera_0001.fits.fz").touch() image_namer = ImageNamer("{camera.name}_{num:04d}.fits.fz", dirname=tmp_path) assert image_namer(camera=camera) == tmp_path / "test_camera_0002.fits.fz" assert image_namer._last_num == 2
def test_image_namer_overwrite(tmp_path): (tmp_path / "test_0001.fits").touch() image_namer = ImageNamer("test_{num:04d}.fits", dirname=tmp_path, overwrite=True) assert image_namer() == tmp_path / "test_0001.fits" assert image_namer._last_num == 1
def test_image_namer(tmp_path): image_namer = ImageNamer("test_{num:04d}.fits", dirname=tmp_path) assert image_namer() == tmp_path / "test_0001.fits" assert image_namer._last_num == 1
async def test_expose_no_filename(camera): exposure = await camera.expose(1.0) assert exposure.filename is not None await exposure.write() assert os.path.exists(exposure.filename) assert camera.name in str(exposure.filename) @pytest.mark.parametrize( "image_namer", ( ImageNamer(), { "basename": "{camera.name}-{num:04d}.fits", "dirname": EXPOSURE_DIR.name }, None, ), ) async def test_expose_image_namer(camera_system, image_namer): camera = VirtualCamera("test_camera", camera_system, image_namer=image_namer) await camera.connect() exposure = await camera.expose(1.0)
from click_default_group import DefaultGroup from basecam.exposure import ImageNamer from clu.command import TimedCommand from sdsstools import get_logger, read_yaml_file from sdsstools.daemonizer import DaemonGroup, cli_coro from flicamera import NAME, __version__ from flicamera.actor import FLIActor from flicamera.camera import FLICamera, FLICameraSystem log = get_logger(NAME) # Set default image namer FLICamera.image_namer = ImageNamer('{camera.name}-{num:04d}.fits', overwrite=False) class FLICameraWrapper(object): """A helper to store CameraSystem initialisation parameters.""" def __init__(self, *args, **kwargs): self.args = args self.kwargs = kwargs self.camera_system = None async def __aenter__(self): config_path = self.kwargs.pop('config_path', None)