eodms-sgdot / py-eodms-rapi

EODMS RAPI Client is a Python3 package used to access the REST API service provided by the Earth Observation Data Management System (EODMS) from Natural Resources Canada.
Other
13 stars 4 forks source link

get_results causes TypeError exception #8

Closed oducut01 closed 2 years ago

oducut01 commented 2 years ago

Snippet

from eodms_rapi import EODMSRAPI

# Create the EODMSRAPI object rapi = EODMSRAPI('eodms-username', 'eodms-password')

# Add a point to the search feat = [('intersects', "POINT (-96.47 62.4)")]

# Create a dictionary of query filters for the search filters = {'Beam Mnemonic': ('=', ['16M11', '16M13']), 'Incidence Angle': ('>=', '35')}

# Set a date range for the search dates = [{"start": "20200513_120000", "end": "20200613_150000"}]

# Submit the search to the EODMSRAPI, specifying the Collection rapi.search("RCMImageProducts", filters=filters, features=feat, dates=dates)

# Get the results from the search res = rapi.get_results('full')

# Print results rapi.print_results()

Cause

Exception has occurred: TypeError sequence item 6: expected str instance, NoneType found File "C:\code.py.", line 36, in <module> res = rapi.get_results('full')

mdkwant commented 2 years ago

This can be fixed by filtering out Nonetype messages.

In eodms.py line 99

replace
return ' '.join(self.msgs) with

return ' '.join(filter(None, self.msgs))

oducut01 commented 2 years ago

Warning now occurs: | EODMSRAPI | WARNING: Could not retrieve full metadata due to: Geospatial search results from Compusult's Web Enterprise Suite (WES) 1 1 1 RCM1_OK1352580_PK1443355_1_SC50MC_20210101_000834_HH_HV_GRD true true SHUB 2 SC50MC 1 /rcm/sar/l1/2021/noamer/med50/rcm_20210101_N6182W09616/20/c0cac1f9-5a6a-5bea-b574-0331ed955497.png Downlinked l1 17 license.pdf 1 1 GRD HH HV Medium Resolution 50m 2021-01-01T00:12:25 +0000 Ascending 2021-01-01T00:08:33 +0000 277 1900-01-01T00:00:00 +0000 4 2021-01-01T00:10:17 +0000 50 false HH HV No special handling required, use per EULA. false PASS RCM1_OK1352580_PK1443355_1_SC50MC_20210101_000834_HH_HV_GRD 20 2021-01-01T00:08:45 +0000 2 false 5 2021-01-01T00:08:41 +0000 Magnitude Detected 1443355_1 Expedited Right RCM-1 false Downlinked 2 RCM PGS 7.02 dummy value Ice GeoTIFF Ice Dailies 1598645_1667278 0 /rcm/sar/l1/2021/noamer/med50/rcm_20210101_N6182W09616/c0cac1f9-5a6a-5bea-b574-0331ed955497 Non classifié / Unclassified 88 165 ScanSAR 50m Resolution 350km Swath C RCM Dual Co/Cross https://www.eodms-sgdot.nrcan-rncan.gc.ca/wes/getArchivedMetadata?FeatureID=62f0e816-8006-4768-8f32-6ef4008e6895-8021867&MetadataFileName=/rcm/sar/l1/2021/noamer/med50/rcm_20210101_N6182W09616/c0cac1f9-5a6a-5bea-b574-0331ed955497&collectionId=RCMImageProducts&fileName=product.xml 8478.0 2 2021-01-01T00:08:33 +0000 23 rcm_20210101_N6182W09616 WGS 1984 62f0e816-8006-4768-8f32-6ef4008e6895-8021867 52 Integer 1443355_1 med50 true 8021867 RCM-1_2020-12-31T11-57-41_008478.PRED_ORBIT_SV 62f0e816-8006-4768-8f32-6ef4008e6895 <a href="http://was-eodms.compusult.net/wes/images/No_Data_Available.png"><img src="https://www.eodms-sgdot.nrcan-rncan.gc.ca/wes/getObject?FeatureID=62f0e816-8006-4768-8f32-6ef4008e6895-8021867&ObjectType=Thumbview&collectionId=RCMImageProducts&AFB=true" width="100" height="100"/></a><p>Record ID: 8021867<br/>Collection: RCM Image Products<br/>Metadata: <a href="https://www.eodms-sgdot.nrcan-rncan.gc.ca/wes/Client/?entryPoint=resultDetails&resultId=8021867&collectionId=RCMImageProducts">GUI</a> &nbsp; <a href="https://www.eodms-sgdot.nrcan-rncan.gc.ca/wes/rapi/record/RCMImageProducts/8021867">RAPI</a><br/>Order: <a href="https://www.eodms-sgdot.nrcan-rncan.gc.ca/wes/Client/?entryPoint=preview#?cseq=RCMImageProducts&record=8021867&searchId=12816276&noparentwindow=true">GUI</a> &nbsp; <a href="https://www.eodms-sgdot.nrcan-rncan.gc.ca/wes/rapi/order/direct?collection=RCMImageProducts&recordId=8021867&destination=fill_me_in">RAPI</a><br/></p> Wed, 13 Apr 2022 13:50:41 GMT 2022-04-13T13:50:41Z -99.70000789079046 61.91469972252145 -99.38637404416373 61.22094042909826 -92.68993176275733 61.72901267972718 -92.85135912223093 62.42641987062197

But otherwise continues as normal.

mvcircelli commented 2 years ago

replace return ' '.join(self.msgs) with

return ' '.join(filter(None, self.msgs))

Confirming that this fix works as expected despite the warnings.

keballantyne commented 2 years ago

Both issues mentioned here have been fixed in v1.3.3. Install latest by running "pip install py-eodms-rapi==1.3.3"

keballantyne commented 2 years ago

Fixed in e0b3550af97189280c3d01c7ff3e8f8925e4a83c