def __fetch_location_data(self): # Fetches the barcoded locations for the racks using the # :class:`RackLocationQuery`. self.add_debug('Fetch barcoded locations ...') all_racks = dict() for rack_barcode, scr in self.__donor_racks.iteritems(): all_racks[rack_barcode] = scr for rack_barcode, scr in self.__receiver_racks.iteritems(): all_racks[rack_barcode] = scr query = RackLocationQuery(rack_barcodes=all_racks.keys()) self._run_query(query, 'Error when trying to find rack locations ' \ 'in the DB: ') if not self.has_errors(): location_map = query.get_query_results() for rack_barcode, location_str in location_map.iteritems(): if location_str is None: continue all_racks[rack_barcode].location = location_str
def __fetch_rack_locations(self): """ Searches and adds the location for the selected candidates. """ self.add_debug('Fetch stock rack locations ...') rack_barcodes = dict() for container in self.stock_tube_containers.values(): if container.tube_candidate is None: continue rack_barcode = container.tube_candidate.rack_barcode add_list_map_element(rack_barcodes, rack_barcode, container) query = None if len(rack_barcodes) > 0: query = RackLocationQuery(rack_barcodes=rack_barcodes.keys()) self._run_query(query, base_error_msg='Error when trying to ' \ 'fetch rack locations: ') if not self.has_errors() and not query is None: results = query.get_query_results() for rack_barcode, location in results.iteritems(): for container in rack_barcodes[rack_barcode]: container.location = location