#NEWLINE# def take_exposures( self , filename = None ) : #NEWLINE# #INDENT# ' Take the next exposure ' #NEWLINE# try : #NEWLINE# #INDENT# exposure = next ( self . exposure_iterator ) #NEWLINE# start_time = current_time ( ) . isot #NEWLINE# fn = start_time #NEWLINE# if ( filename is not None ) : #NEWLINE# #INDENT# self . _orig_fn = filename #NEWLINE# path = filename . split ( '/' ) #NEWLINE# self . _images_dir = '/' . join ( path [ : ( - 1 ) ] ) #NEWLINE# fn = path [ ( - 1 ) ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# fn = '{:03.0f}_{:03.0f}.cr2' . format ( self . visit_num , e . exp_num ) #NEWLINE# #UNINDENT# img_files = [ ] #NEWLINE# for ( cam_name , cam ) in self . cameras . items ( ) : #NEWLINE# #INDENT# self . logger . debug ( 'Exposing for camera: {}' . format ( cam_name ) ) #NEWLINE# cam_fn = '{}/{}_{}' . format ( self . _images_dir , cam . uid , fn ) #NEWLINE# self . logger . debug ( 'Filename for camera: {}' . format ( cam_fn ) ) #NEWLINE# img_file = cam . take_exposure ( seconds = exposure . exptime , filename = cam_fn ) #NEWLINE# self . _is_exposing = True #NEWLINE# obs_info = { #NEWLINE# #INDENT# 'camera_id' : cam . uid , #NEWLINE# 'img_file' : img_file , #NEWLINE# 'filter' : exposure . filter_type , #NEWLINE# 'exptime' : exposure . exptime , #NEWLINE# 'start_time' : start_time , #NEWLINE# 'guide_image' : cam . is_guide , #NEWLINE# 'primary' : cam . is_primary , #NEWLINE# 'visit_num' : self . visit_num , #NEWLINE# 'exp_num' : self . exp_num , #NEWLINE# 'exp_total' : len ( self . exposures ) , #NEWLINE# #UNINDENT# } #NEWLINE# self . logger . debug ( '{}' . format ( obs_info ) ) #NEWLINE# exposure . images [ cam_name ] = obs_info #NEWLINE# img_files . append ( img_file ) #NEWLINE# #UNINDENT# #UNINDENT# except error . InvalidCommand as e : #NEWLINE# #INDENT# self . logger . warning ( '{} is already running a command.' . format ( cam . name ) ) #NEWLINE# self . _is_exposing = False #NEWLINE# #UNINDENT# except Exception as e : #NEWLINE# #INDENT# self . logger . warning ( "Can't take exposure from Observation: {}" . format ( e ) ) #NEWLINE# self . _is_exposing = False #NEWLINE# #UNINDENT# finally : #NEWLINE# #INDENT# return exposure . images