File size: 1,457 Bytes
da3e674
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Debug _http_get"""
import sys, os
project_root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
if project_root not in sys.path:
    sys.path.insert(0, project_root)

import asyncio
import requests
import aiohttp
from space.eu_gaia_x_adapter import EUGaiaXAdapter

async def main():
    a = EUGaiaXAdapter()
    
    print(f"aiohttp available: {aiohttp is not None}")
    print(f"self._http: {a._http}")
    print(f"hasattr(a._http, 'get'): {hasattr(a._http, 'get') if a._http else 'N/A'}")
    
    url = 'https://api.openaire.eu/search/publications'
    params = {'format': 'json', 'size': 2, 'query': 'climate'}
    
    # Test with explicit requests (bypass _http_get)
    print("\n--- Direct requests.get ---")
    resp = requests.get(url, params=params, timeout=15)
    print(f"status: {resp.status_code}")
    data = resp.json()
    print(f"type: {type(data)}, keys: {list(data.keys())}")
    
    # Test _http_get
    print("\n--- _http_get ---")
    try:
        data2 = await a._http_get(url, params=params, timeout=15)
        print(f"type: {type(data2)}")
        if data2 is None:
            print("RESULT IS NONE!")
        elif isinstance(data2, dict):
            print(f"keys: {list(data2.keys())}")
        else:
            print(f"value: {data2}")
    except Exception as e:
        print(f"EXCEPTION: {type(e).__name__}: {e}")
    
    await a.close()

asyncio.run(main())