stones/scripts/moloch_dao/check_subgraph_status.py

70 lines
1.5 KiB
Python

#!/usr/bin/env python3
"""
Check DAOhaus v3 Subgraph Status
This script checks the status of the DAOhaus v3 subgraph with a simple query.
"""
import requests
import json
# Constants
SUBGRAPH_URL = "https://api.thegraph.com/subgraphs/id/HouDe2pTdyKM9CTG1aodnPPPhm7U148BCH7eJ4HHwpdQ"
def check_subgraph_status():
"""
Check the status of the subgraph
"""
# Simple query to check if subgraph is responding
query = """
query {
_meta {
block {
number
}
deployment
hasIndexingErrors
}
}
"""
print(f"Checking subgraph at {SUBGRAPH_URL}...")
try:
# Make request to subgraph
response = requests.post(
SUBGRAPH_URL,
json={"query": query}
)
# Print status code
print(f"Status code: {response.status_code}")
# Print headers
print("Headers:")
for key, value in response.headers.items():
print(f" {key}: {value}")
# Print content
print("\nContent:")
print(response.text)
# Try to parse as JSON
try:
data = response.json()
print("\nJSON data:")
print(json.dumps(data, indent=2))
except Exception as e:
print(f"\nError parsing JSON: {e}")
except Exception as e:
print(f"Exception checking subgraph: {e}")
def main():
"""Main function"""
check_subgraph_status()
return 0
if __name__ == "__main__":
main()