hdpws 0.6.18__tar.gz → 0.6.19__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {hdpws-0.6.18 → hdpws-0.6.19}/PKG-INFO +1 -1
- {hdpws-0.6.18 → hdpws-0.6.19}/hdpws/__init__.py +1 -1
- {hdpws-0.6.18 → hdpws-0.6.19}/hdpws/__main__.py +29 -0
- {hdpws-0.6.18 → hdpws-0.6.19}/hdpws/hdpws.py +66 -0
- {hdpws-0.6.18 → hdpws-0.6.19}/hdpws/resourcetype.py +1 -0
- {hdpws-0.6.18 → hdpws-0.6.19}/hdpws.egg-info/PKG-INFO +1 -1
- {hdpws-0.6.18 → hdpws-0.6.19}/setup.py +1 -1
- {hdpws-0.6.18 → hdpws-0.6.19}/tests/test_hdpws.py +35 -0
- {hdpws-0.6.18 → hdpws-0.6.19}/LICENSE +0 -0
- {hdpws-0.6.18 → hdpws-0.6.19}/README.md +0 -0
- {hdpws-0.6.18 → hdpws-0.6.19}/hdpws/dateinterval.py +0 -0
- {hdpws-0.6.18 → hdpws-0.6.19}/hdpws/spase.py +0 -0
- {hdpws-0.6.18 → hdpws-0.6.19}/hdpws.egg-info/SOURCES.txt +0 -0
- {hdpws-0.6.18 → hdpws-0.6.19}/hdpws.egg-info/dependency_links.txt +0 -0
- {hdpws-0.6.18 → hdpws-0.6.19}/hdpws.egg-info/requires.txt +0 -0
- {hdpws-0.6.18 → hdpws-0.6.19}/hdpws.egg-info/top_level.txt +0 -0
- {hdpws-0.6.18 → hdpws-0.6.19}/setup.cfg +0 -0
- {hdpws-0.6.18 → hdpws-0.6.19}/tests/test_access_information.py +0 -0
- {hdpws-0.6.18 → hdpws-0.6.19}/tests/test_access_url.py +0 -0
- {hdpws-0.6.18 → hdpws-0.6.19}/tests/test_dateinterval.py +0 -0
|
@@ -147,6 +147,14 @@ def example(
|
|
|
147
147
|
disable_ssl_certificate_validation, user_agent='Example')
|
|
148
148
|
|
|
149
149
|
|
|
150
|
+
result = hdp.get_application_interfaces()
|
|
151
|
+
if result['HttpStatus'] == 200:
|
|
152
|
+
print('HDP ApplicationInterfaces:')
|
|
153
|
+
for value in result['ApplicationInterface']:
|
|
154
|
+
print(f' {value}')
|
|
155
|
+
else:
|
|
156
|
+
print_error('hdp.get_application_interfaces', result)
|
|
157
|
+
|
|
150
158
|
result = hdp.get_keywords()
|
|
151
159
|
if result['HttpStatus'] == 200:
|
|
152
160
|
print('HDP Keywords:')
|
|
@@ -395,6 +403,27 @@ def example(
|
|
|
395
403
|
print_error('hdp.get_spase_document', result)
|
|
396
404
|
|
|
397
405
|
|
|
406
|
+
query = {
|
|
407
|
+
'ResourceID': 'spase://CCMC/Software/Kamodo',
|
|
408
|
+
'CodeLanguage': 'Python',
|
|
409
|
+
'Description': '"space weather models and data"'
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
|
|
413
|
+
if result['HttpStatus'] == 200:
|
|
414
|
+
#print('HDP Spase:')
|
|
415
|
+
#print(ET.tostring(result['Result']))
|
|
416
|
+
print('Result Software:')
|
|
417
|
+
for software in result['Result'].findall('.//Software', namespaces=NS):
|
|
418
|
+
print(software.findall('.//ResourceID', namespaces=NS)[0].text)
|
|
419
|
+
print(' ', software.findall('.//ResourceName', namespaces=NS)[0].text)
|
|
420
|
+
#ET.indent(software)
|
|
421
|
+
#print(ET.tostring(software, encoding='unicode',
|
|
422
|
+
# default_namespace=SPASE_NS))
|
|
423
|
+
else:
|
|
424
|
+
print_error('hdp.get_spase_software', result)
|
|
425
|
+
|
|
426
|
+
|
|
398
427
|
def print_error(
|
|
399
428
|
label: str,
|
|
400
429
|
result: Dict
|
|
@@ -197,6 +197,33 @@ class HdpWs:
|
|
|
197
197
|
return self._endpoint
|
|
198
198
|
|
|
199
199
|
|
|
200
|
+
def get_application_interfaces(
|
|
201
|
+
self
|
|
202
|
+
) -> Dict:
|
|
203
|
+
"""
|
|
204
|
+
Gets all /Spase/Software/ApplicationInterface values available at HDP.
|
|
205
|
+
|
|
206
|
+
Returns
|
|
207
|
+
-------
|
|
208
|
+
Dict
|
|
209
|
+
Dictionary containing a 'ApplicationInterface' key with a value
|
|
210
|
+
of a List containing all /Spase/Software/ApplicationInterface values
|
|
211
|
+
with the addition of the following key/values:<br>
|
|
212
|
+
- HttpStatus: with the value of the HTTP status code.
|
|
213
|
+
Successful == 200.<br>
|
|
214
|
+
When HttpStatus != 200:<br>
|
|
215
|
+
- HttpText: containing a string representation of the HTTP
|
|
216
|
+
entity body.<br>
|
|
217
|
+
When HttpText is a standard HDP WS error entity body the
|
|
218
|
+
following key/values (convenience to avoid parsing
|
|
219
|
+
HttpStatus):<br>
|
|
220
|
+
- ErrorMessage: value from HttpText.<br>
|
|
221
|
+
- ErrorDescription: value from HttpText.<br>
|
|
222
|
+
"""
|
|
223
|
+
return self.__get_simple_resource('Spase/ApplicationInterface',
|
|
224
|
+
'ApplicationInterface',
|
|
225
|
+
'ApplicationInterface')
|
|
226
|
+
|
|
200
227
|
def get_keywords(
|
|
201
228
|
self
|
|
202
229
|
) -> Dict:
|
|
@@ -818,6 +845,45 @@ class HdpWs:
|
|
|
818
845
|
return self.__get_complex_resource([ResourceType.DOCUMENT], query)
|
|
819
846
|
|
|
820
847
|
|
|
848
|
+
def get_spase_software(
|
|
849
|
+
self,
|
|
850
|
+
query: Dict
|
|
851
|
+
) -> Dict:
|
|
852
|
+
"""
|
|
853
|
+
Gets the specified SPASE Software documents from HDP.
|
|
854
|
+
|
|
855
|
+
Parameters
|
|
856
|
+
----------
|
|
857
|
+
query
|
|
858
|
+
Dictionary containing query parameters and values. For
|
|
859
|
+
example,<pre>
|
|
860
|
+
query = {
|
|
861
|
+
'ResourceID': 'spase://CCMC/Software/Kamodo',
|
|
862
|
+
'CodeLanguage': 'Python',
|
|
863
|
+
'Description': '"space weather models and data"'
|
|
864
|
+
}</pre>
|
|
865
|
+
|
|
866
|
+
Returns
|
|
867
|
+
-------
|
|
868
|
+
Dict
|
|
869
|
+
Dictionary containing a 'Result' key with a value of an
|
|
870
|
+
ElementTree representation of the results as described by
|
|
871
|
+
<https://heliophysicsdata.gsfc.nasa.gov/WebServices/hdpspase.xsd>
|
|
872
|
+
with the addition of the following key/values:<br>
|
|
873
|
+
- HttpStatus: with the value of the HTTP status code.
|
|
874
|
+
Successful == 200.<br>
|
|
875
|
+
When HttpStatus != 200:<br>
|
|
876
|
+
- HttpText: containing a string representation of the HTTP
|
|
877
|
+
entity body.<br>
|
|
878
|
+
When HttpText is a standard HDP WS error entity body the
|
|
879
|
+
following key/values (convenience to avoid parsing
|
|
880
|
+
HttpStatus):<br>
|
|
881
|
+
- ErrorMessage: value from HttpText.<br>
|
|
882
|
+
- ErrorDescription: value from HttpText.<br>
|
|
883
|
+
"""
|
|
884
|
+
return self.__get_complex_resource([ResourceType.SOFTWARE], query)
|
|
885
|
+
|
|
886
|
+
|
|
821
887
|
def __get_simple_resource(
|
|
822
888
|
self,
|
|
823
889
|
resource: str,
|
|
@@ -10,7 +10,7 @@ README = (HERE / "README.md").read_text()
|
|
|
10
10
|
# This call to setup() does all the work
|
|
11
11
|
setup(
|
|
12
12
|
name="hdpws",
|
|
13
|
-
version="0.6.
|
|
13
|
+
version="0.6.19",
|
|
14
14
|
description="NASA's Heliophysics Data Portal Web Service Client Library",
|
|
15
15
|
long_description=README,
|
|
16
16
|
long_description_content_type="text/markdown",
|
|
@@ -63,6 +63,19 @@ class TestHdpWs(unittest.TestCase):
|
|
|
63
63
|
self._hdp = HdpWs(endpoint='http://localhost:8080/exist/restxq/')
|
|
64
64
|
|
|
65
65
|
|
|
66
|
+
def test_get_application_interfaces(self):
|
|
67
|
+
"""
|
|
68
|
+
Test for get_application_interfaces function.
|
|
69
|
+
"""
|
|
70
|
+
|
|
71
|
+
result = self._hdp.get_application_interfaces()
|
|
72
|
+
|
|
73
|
+
self.assertEqual(result['HttpStatus'], 200)
|
|
74
|
+
application_interfaces = result['ApplicationInterface']
|
|
75
|
+
self.assertTrue(len(application_interfaces) > 0)
|
|
76
|
+
self.assertTrue(application_interfaces[0] == 'CLI')
|
|
77
|
+
|
|
78
|
+
|
|
66
79
|
def test_get_keywords(self):
|
|
67
80
|
"""
|
|
68
81
|
Test for get_keywords function.
|
|
@@ -399,5 +412,27 @@ class TestHdpWs(unittest.TestCase):
|
|
|
399
412
|
self.assertTrue(result_ids[0] == 'spase://SMWG/Document/HPDE/Policy/HP_DataPolicy_v1.2')
|
|
400
413
|
|
|
401
414
|
|
|
415
|
+
def test_get_spase_software(self):
|
|
416
|
+
"""
|
|
417
|
+
Test for get_spase_software function.
|
|
418
|
+
"""
|
|
419
|
+
|
|
420
|
+
query = {
|
|
421
|
+
'ResourceID': 'spase://CCMC/Software/Kamodo',
|
|
422
|
+
'CodeLanguage': 'Python',
|
|
423
|
+
'Description': '"space weather models and data"'
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
result = self._hdp.get_spase_software(query)
|
|
427
|
+
|
|
428
|
+
self.assertEqual(result['HttpStatus'], 200)
|
|
429
|
+
result = result['Result']
|
|
430
|
+
result_id_elements = result.findall('.//ResourceID',
|
|
431
|
+
namespaces=NS)
|
|
432
|
+
result_ids = list(map(lambda e: e.text, result_id_elements))
|
|
433
|
+
self.assertTrue(len(result_ids) == 1)
|
|
434
|
+
self.assertTrue(result_ids[0] == 'spase://CCMC/Software/Kamodo')
|
|
435
|
+
|
|
436
|
+
|
|
402
437
|
if __name__ == '__main__':
|
|
403
438
|
unittest.main()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|