44 lines
1.2 KiB
Python
44 lines
1.2 KiB
Python
|
|
import requests
|
|
from dotenv import load_dotenv
|
|
load_dotenv()
|
|
from config import get_all_plants
|
|
from crawlers.kremc import fetch_data
|
|
from crawlers.base import create_session
|
|
|
|
def debug_kremc():
|
|
plants = get_all_plants()
|
|
# 5호기 (kremc) 찾기 - id가 kremc-05인 것
|
|
target = next((p for p in plants if p['id'] == 'kremc-05'), None)
|
|
|
|
if not target:
|
|
print("Plant kremc-05 not found")
|
|
return
|
|
|
|
print(f"Debug target: {target['name']}")
|
|
|
|
print(f"Debug target: {target['name']}")
|
|
|
|
from datetime import datetime
|
|
today = datetime.now().strftime('%Y-%m-%d')
|
|
print(f"Fetching hourly history for {today}...")
|
|
|
|
from crawlers.kremc import fetch_history_hourly
|
|
from database import save_history
|
|
try:
|
|
results = fetch_history_hourly(target, today, today)
|
|
print(f"Hourly Results ({len(results)}):")
|
|
for r in results:
|
|
print(f" {r['timestamp']}: {r['generation_kwh']} kWh")
|
|
|
|
if results:
|
|
print("Saving to DB...")
|
|
save_history(results, 'hourly')
|
|
print("Done.")
|
|
|
|
except Exception as e:
|
|
print(f"Exception: {e}")
|
|
|
|
if __name__ == "__main__":
|
|
debug_kremc()
|