def update_sample_state(message): dom = xml.dom.minidom.parseString(message.body) barcode = get_value(dom, 'barcode') state = get_value(dom, 'state') api_key = get_value(dom, 'api_key') log.debug('Barcode: ' + barcode) log.debug('State: ' + state) log.debug('API Key: ' + api_key) # validate if not barcode or not state or not api_key: log.debug( 'Incomplete sample_state_update message received. Sample barcode, desired state and user API key is required.' ) return # update the sample state in Galaxy db dbconnstr = config.get("app:main", "database_connection") galaxydb = GalaxyDbInterface(dbconnstr) sample_id = galaxydb.get_sample_id(field_name='bar_code', value=barcode) if sample_id == -1: log.debug('Invalid barcode.') return galaxydb.change_state(sample_id, state) # after updating the sample state, update request status request_id = galaxydb.get_request_id(sample_id) update_request(api_key, request_id)
def __init__(self, msg, config_file): log.info(msg) self.dom = xml.dom.minidom.parseString(msg) self.galaxy_host = get_value(self.dom, 'galaxy_host') self.api_key = get_value(self.dom, 'api_key') self.sequencer_host = get_value(self.dom, 'data_host') self.sequencer_username = get_value(self.dom, 'data_user') self.sequencer_password = get_value(self.dom, 'data_password') self.request_id = get_value(self.dom, 'request_id') self.sample_id = get_value(self.dom, 'sample_id') self.library_id = get_value(self.dom, 'library_id') self.folder_id = get_value(self.dom, 'folder_id') self.dataset_files = [] count = 0 while True: dataset_id = get_value_index(self.dom, 'dataset_id', count) file = get_value_index(self.dom, 'file', count) name = get_value_index(self.dom, 'name', count) if file: self.dataset_files.append( dict(name=name, dataset_id=int(dataset_id), file=file)) else: break count = count + 1 # read config variables config = ConfigParser.ConfigParser() retval = config.read(config_file) if not retval: error_msg = 'FATAL ERROR: Unable to open config file %s.' % config_file log.error(error_msg) sys.exit(1) try: self.config_id_secret = config.get("app:main", "id_secret") except ConfigParser.NoOptionError, e: self.config_id_secret = "USING THE DEFAULT IS NOT SECURE!"
def update_sample_state( message ): dom = xml.dom.minidom.parseString(message.body) barcode = get_value(dom, 'barcode') state = get_value(dom, 'state') api_key = get_value(dom, 'api_key') log.debug('Barcode: ' + barcode) log.debug('State: ' + state) log.debug('API Key: ' + api_key) # validate if not barcode or not state or not api_key: log.debug( 'Incomplete sample_state_update message received. Sample barcode, desired state and user API key is required.' ) return # update the sample state in Galaxy db dbconnstr = config.get("app:main", "database_connection") galaxydb = GalaxyDbInterface( dbconnstr ) sample_id = galaxydb.get_sample_id( field_name='bar_code', value=barcode ) if sample_id == -1: log.debug( 'Invalid barcode.' ) return galaxydb.change_state(sample_id, state) # after updating the sample state, update request status request_id = galaxydb.get_request_id(sample_id) update_request( api_key, request_id )
def __init__( self, msg, config_file ): log.info( msg ) self.dom = xml.dom.minidom.parseString( msg ) self.galaxy_host = get_value( self.dom, 'galaxy_host' ) self.api_key = get_value( self.dom, 'api_key' ) self.sequencer_host = get_value( self.dom, 'data_host' ) self.sequencer_username = get_value( self.dom, 'data_user' ) self.sequencer_password = get_value( self.dom, 'data_password' ) self.request_id = get_value( self.dom, 'request_id' ) self.sample_id = get_value( self.dom, 'sample_id' ) self.library_id = get_value( self.dom, 'library_id' ) self.folder_id = get_value( self.dom, 'folder_id' ) self.dataset_files = [] count=0 while True: dataset_id = get_value_index( self.dom, 'dataset_id', count ) file = get_value_index( self.dom, 'file', count ) name = get_value_index( self.dom, 'name', count ) if file: self.dataset_files.append( dict( name=name, dataset_id=int( dataset_id ), file=file ) ) else: break count=count+1 # read config variables config = ConfigParser.ConfigParser() retval = config.read( config_file ) if not retval: error_msg = 'FATAL ERROR: Unable to open config file %s.' % config_file log.error( error_msg ) sys.exit(1) try: self.config_id_secret = config.get( "app:main", "id_secret" ) except ConfigParser.NoOptionError,e: self.config_id_secret = "USING THE DEFAULT IS NOT SECURE!"