def check(self, order, contactid=None): ids = sensor.SensorCONST.instances.keys() lta_ls = [] lpdaac_ls = [] results = {} for key in order: l1 = '' if key in ids: inst = sensor.instance(order[key]['inputs'][0]) l1 = inst.l1_provider if l1 == 'dmid': lta_ls.extend(order[key]['inputs']) elif l1 == 'lpdaac': lpdaac_ls.extend(order[key]['inputs']) if lta_ls: if inventory.available(): results.update(self.check_dmid(lta_ls, contactid)) else: msg = 'Could not connect to Landsat data source' raise InventoryConnectionException(msg) if lpdaac_ls: if inventory.available(): logger.warn('Checking M2M Inventory for LP DAAC granules') try: results.update(self.check_dmid(lpdaac_ls, contactid)) except InventoryException: logger.warn("Unable to verify inventory with DMID") elif lpdaac.check_lpdaac_available(): try: results.update(self.check_LPDAAC(lpdaac_ls)) except InventoryException: logger.warn("Unable to verify inventory with LPDAAC") else: msg = "Could not connect to any data source to verify LPDAAC products" raise InventoryConnectionException(msg) not_avail = [] for key, val in results.items(): if not val: not_avail.append(key) if not_avail: raise InventoryException(not_avail)
def check(self, order, contactid=None): ids = sensor.SensorCONST.instances.keys() lta_ls = [] lpdaac_ls = [] results = {} for key in order: l1 = '' if key in ids: inst = sensor.instance(order[key]['inputs'][0]) l1 = inst.l1_provider if l1 == 'dmid': lta_ls.extend(order[key]['inputs']) elif l1 == 'lpdaac': lpdaac_ls.extend(order[key]['inputs']) if lta_ls: if 'LANDSAT' in os.getenv('ESPA_M2M_MODE', '') and inventory.available(): results.update(self.check_dmid(lta_ls, contactid)) else: if not lta.check_lta_available(): msg = 'Could not connect to LTA data source' raise InventoryConnectionException(msg) results.update(self.check_LTA(lta_ls)) if lpdaac_ls: if 'MODIS' in os.getenv('ESPA_M2M_MODE', '') and inventory.available(): results.update(self.check_dmid(lpdaac_ls, contactid)) else: if not lpdaac.check_lpdaac_available(): msg = 'Could not connect to LPDAAC data source' raise InventoryConnectionException(msg) results.update(self.check_LPDAAC(lpdaac_ls)) not_avail = [] for key, val in results.items(): if not val: not_avail.append(key) if not_avail: raise InventoryException(not_avail)
def test_api_available(self): self.assertTrue(inventory.available())