#NEWLINE# def load_fits_buffer( self , imname , chname , file_buf , num_hdu , metadata ) : #NEWLINE# #INDENT# from astropy.io import fits #NEWLINE# try : #NEWLINE# #INDENT# file_buf = binascii . a2b_base64 ( file_buf ) #NEWLINE# decompress = metadata . get ( 'decompress' , None ) #NEWLINE# if ( decompress == 'bz2' ) : #NEWLINE# #INDENT# file_buf = bz2 . decompress ( file_buf ) #NEWLINE# #UNINDENT# self . logger . info ( ( 'received data: len=%d num_hdu=%d' % ( len ( file_buf ) , num_hdu ) ) ) #NEWLINE# in_f = BytesIO ( file_buf ) #NEWLINE# with fits . open ( in_f , 'readonly' ) as fits_f : #NEWLINE# #INDENT# image = AstroImage . AstroImage ( metadata = metadata , logger = self . logger ) #NEWLINE# image . load_hdu ( fits_f [ num_hdu ] , fobj = fits_f ) #NEWLINE# #UNINDENT# image . set ( name = imname , path = None , idx = num_hdu ) #NEWLINE# #UNINDENT# except Exception as e : #NEWLINE# #INDENT# errmsg = ( "Error creating image data for '%s': %s" % ( imname , str ( e ) ) ) #NEWLINE# self . logger . error ( errmsg ) #NEWLINE# raise GingaPlugin . PluginError ( errmsg ) #NEWLINE# #UNINDENT# channel = self . fv . gui_call ( self . fv . get_channel_on_demand , chname ) #NEWLINE# self . fv . gui_do ( self . fv . change_channel , channel . name ) #NEWLINE# self . fv . gui_do ( self . fv . add_image , imname , image , chname = channel . name ) #NEWLINE# return 0